Copyright 2010 Jake Wheat Test sql by typechecking it, then running it through Postgres and comparing. Stage 1: read sql files: produce catalog using type checker load sql files into postgres using psql read catalog from psql and compare with catalog from typechecker stage 2: as above, but load via databaseloader stage 3: load using database loader dump using pg_dump attempt to compare original ast to ast of dump > module Database.HsSqlPpp.Tests.RoundtripTests (roundtripTests) where > import Test.HUnit > import Test.Framework > import Test.Framework.Providers.HUnit > import Database.HsSqlPpp.Parsing.Parser > import Database.HsSqlPpp.Ast.Environment > import Database.HsSqlPpp.Ast.TypeChecker > import Database.HsSqlPpp.Commands.CommandComponents > data Item = Group String [Item] > | Src [(String,String)] > roundtripTests :: [Test.Framework.Test] > roundtripTests = itemToTft roundtripTestData > roundtripTestData :: Item > roundtripTestData = > Group "round trip tests" [] > itemToTft :: Item -> [Test.Framework.Test] > itemToTft (Group s is) = [testGroup s $ concatMap itemToTft is] > itemToTft (Src ss) = map (uncurry testRoundtrip) ss > testRoundtrip :: String -> String -> Test.Framework.Test > testRoundtrip name sql = testCase ("test " ++ name) $ > checkStage1 > where > checkStage1 = do > cat1 <- getCatalog sql > return () > getCatalog :: String -> EitherEnvironment > getCatalog sql = > parseSql1 "" sql >>= typeCheckC defaultTemplate1Environment >>= lfst