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 = 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)
> | (s,t) <- lexerTable
> , (s1,t1) <- lexerTable
@ -74,10 +74,12 @@ number number (todo: double check more carefully)
> , isGood $ t ++ t1
> ]
> ++ map (uncurry $ LexerTest SQL2011)
> ,Group "adhoc lexer tests" $
> map (uncurry $ LexerTest SQL2011)
> [("", [])
> ,("-- line com\nstuff", [LineComment "-- line com\n",Identifier "stuff"])
> ]
> ]
> where
> isGood :: [Token] -> Bool

View file

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

View file

@ -6,11 +6,14 @@ Converts the test data to asciidoc
> import Control.Monad.State
> import Language.SQL.SimpleSQL.Parser
> import Language.SQL.SimpleSQL.Lexer
> import Data.List
> data TableItem = Heading Int String
> | Row String String
> doc :: Int -> TestItem -> [TableItem]
> -- filter out some groups of tests
> doc n (Group nm _) | "generated" `isInfixOf` nm = []
> doc n (Group nm is) =
> Heading n nm
> : concatMap (doc (n + 1)) is
@ -30,14 +33,7 @@ Converts the test data to asciidoc
> [Row str (ppShow $ parseValueExpr d "" Nothing str)]
> doc _ (LexerTest d str t) =
> -- todo: figure out how to handle this:
> -- 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
> [Row str (ppShow $ lexSQL d "" Nothing str)]
TODO: should put the dialect in the html output