From 47198c78c184fcd18687776f6cc6a76633d4cfc8 Mon Sep 17 00:00:00 2001 From: Jake Wheat Date: Sat, 13 Feb 2016 20:38:49 +0200 Subject: [PATCH] add tests for + - followed by comment edge cases --- Language/SQL/SimpleSQL/Lex.lhs | 1 - tools/Language/SQL/SimpleSQL/LexerTests.lhs | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Language/SQL/SimpleSQL/Lex.lhs b/Language/SQL/SimpleSQL/Lex.lhs index b0e85ed..7fb0bf0 100644 --- a/Language/SQL/SimpleSQL/Lex.lhs +++ b/Language/SQL/SimpleSQL/Lex.lhs @@ -370,7 +370,6 @@ which allows the last character of a multi character symbol to be + or > -- special case for parsing a single + or - symbol > singlePlusMinus = try $ do > c <- oneOf "+-" -> -- todo: make sure it deals with e.g. --- +-- +/* -/*? > notFollowedBy $ oneOf allOpSymbols > return [c] diff --git a/tools/Language/SQL/SimpleSQL/LexerTests.lhs b/tools/Language/SQL/SimpleSQL/LexerTests.lhs index c8a21ae..8f6f338 100644 --- a/tools/Language/SQL/SimpleSQL/LexerTests.lhs +++ b/tools/Language/SQL/SimpleSQL/LexerTests.lhs @@ -284,7 +284,9 @@ the + or -. > [LexerTest postgres s t | (s,t) <- postgresLexerTable] > ,Group "adhoc lexer tests" $ > [LexerTest postgres s t -> | (s,t) <- edgeCaseCommentOps ++ edgeCasePlusMinusOps ] +> | (s,t) <- edgeCaseCommentOps +> ++ edgeCasePlusMinusOps +> ++ edgeCasePlusMinusComments] > ] > where > edgeCaseCommentOps = concat @@ -298,6 +300,12 @@ the + or -. > , (x ++ "-", [Symbol x, Symbol "-"]) ] > | x <- somePostgresOpsWhichWontAddTrailingPlusMinus 2 > ] +> edgeCasePlusMinusComments = +> [("---", [LineComment "---"]) +> ,("+--", [Symbol "+", LineComment "--"]) +> ,("-/**/", [Symbol "-", BlockComment "/**/"]) +> ,("+/**/", [Symbol "+", BlockComment "/**/"]) +> ] > combos :: [a] -> Int -> [[a]]