1
Fork 0

rearrange tests slightly and hide/show tests in the website a bit better

This commit is contained in:
Jake Wheat 2015-08-15 19:04:29 +03:00
parent 63a23cabf4
commit 91875b7e7e
3 changed files with 25 additions and 20 deletions

View file

@ -57,8 +57,8 @@ Test for the lexer
> lexerTests :: TestItem > lexerTests :: TestItem
> lexerTests = Group "lexerTests" $ > lexerTests = Group "lexerTests" $
> [LexerTest SQL2011 s t | (s,t) <- lexerTable] > [Group "lexer token tests" $ [LexerTest SQL2011 s t | (s,t) <- lexerTable]
> ++ > ,Group "generated combination lexer tests" $
> [ LexerTest SQL2011 (s ++ s1) (t ++ t1) > [ LexerTest SQL2011 (s ++ s1) (t ++ t1)
> | (s,t) <- lexerTable > | (s,t) <- lexerTable
> , (s1,t1) <- lexerTable > , (s1,t1) <- lexerTable
@ -74,10 +74,12 @@ number number (todo: double check more carefully)
> , isGood $ t ++ t1 > , isGood $ t ++ t1
> ] > ]
> ++ map (uncurry $ LexerTest SQL2011) > ,Group "adhoc lexer tests" $
> map (uncurry $ LexerTest SQL2011)
> [("", []) > [("", [])
> ,("-- line com\nstuff", [LineComment "-- line com\n",Identifier "stuff"]) > ,("-- line com\nstuff", [LineComment "-- line com\n",Identifier "stuff"])
> ] > ]
> ]
> where > where
> isGood :: [Token] -> Bool > isGood :: [Token] -> Bool

View file

@ -1024,11 +1024,10 @@ new multipliers
create a list of type name variations: create a list of type name variations:
> typeNames :: [(String,TypeName)] > typeNames :: ([(String,TypeName)],[(String,TypeName)])
> typeNames = > typeNames =
> basicTypes > (basicTypes, concatMap makeArray basicTypes
> ++ concatMap makeArray basicTypes > ++ map makeMultiset basicTypes)
> ++ map makeMultiset basicTypes
> where > where
> makeArray (s,t) = [(s ++ " array", ArrayTypeName t Nothing) > makeArray (s,t) = [(s ++ " array", ArrayTypeName t Nothing)
> ,(s ++ " array[5]", ArrayTypeName t (Just 5))] > ,(s ++ " array[5]", ArrayTypeName t (Just 5))]
@ -1188,13 +1187,21 @@ Now test each variation in both cast expression and typed literal
expression expression
> typeNameTests :: TestItem > typeNameTests :: TestItem
> typeNameTests = Group "type names" $ map (uncurry (TestValueExpr SQL2011)) > typeNameTests = Group "type names"
> $ concatMap makeTests typeNames > [Group "type names" $ map (uncurry (TestValueExpr SQL2011))
> $ concatMap makeSimpleTests $ fst typeNames
> ,Group "generated casts" $ map (uncurry (TestValueExpr SQL2011))
> $ concatMap makeCastTests $ fst typeNames
> ,Group "generated typename" $ map (uncurry (TestValueExpr SQL2011))
> $ concatMap makeTests $ snd typeNames]
> where > where
> makeTests (ctn, stn) = > makeSimpleTests (ctn, stn) =
> [("cast('test' as " ++ ctn ++ ")", Cast (StringLit "test") stn) > [(ctn ++ " 'test'", TypedLit stn "test")
> ,(ctn ++ " 'test'", TypedLit stn "test")
> ] > ]
> makeCastTests (ctn, stn) =
> [("cast('test' as " ++ ctn ++ ")", Cast (StringLit "test") stn)
> ]
> makeTests a = makeSimpleTests a ++ makeCastTests a
== 6.2 <field definition> == 6.2 <field definition>

View file

@ -6,11 +6,14 @@ Converts the test data to asciidoc
> import Control.Monad.State > import Control.Monad.State
> import Language.SQL.SimpleSQL.Parser > import Language.SQL.SimpleSQL.Parser
> import Language.SQL.SimpleSQL.Lexer > import Language.SQL.SimpleSQL.Lexer
> import Data.List
> data TableItem = Heading Int String > data TableItem = Heading Int String
> | Row String String > | Row String String
> doc :: Int -> TestItem -> [TableItem] > doc :: Int -> TestItem -> [TableItem]
> -- filter out some groups of tests
> doc n (Group nm _) | "generated" `isInfixOf` nm = []
> doc n (Group nm is) = > doc n (Group nm is) =
> Heading n nm > Heading n nm
> : concatMap (doc (n + 1)) is > : concatMap (doc (n + 1)) is
@ -30,14 +33,7 @@ Converts the test data to asciidoc
> [Row str (ppShow $ parseValueExpr d "" Nothing str)] > [Row str (ppShow $ parseValueExpr d "" Nothing str)]
> doc _ (LexerTest d str t) = > doc _ (LexerTest d str t) =
> -- todo: figure out how to handle this: > [Row str (ppShow $ lexSQL d "" Nothing str)]
> -- too many entries, but want to show the lexing
> -- a bit
> -- [Row str (ppShow $ lexSQL d "" Nothing str)]
> []
> -- should probably think about doing something similar
> -- with other generated combination tests such as the typename
> -- tests
TODO: should put the dialect in the html output TODO: should put the dialect in the html output