summaryrefslogtreecommitdiff
path: root/tests/Language/GraphQL/AST/LexerSpec.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2024-10-14 20:50:34 +0200
committerEugen Wissner <belka@caraus.de>2024-10-14 20:50:34 +0200
commitb056b4256f883c4b52c32d7df9568f8dd12dcfab (patch)
treef436c3a8cd14f7d2d7e48f9c00ff425b90e6fc27 /tests/Language/GraphQL/AST/LexerSpec.hs
parentba07f8298bda9b18ea0408988cc2cd2239ce9726 (diff)
downloadgraphql-b056b4256f883c4b52c32d7df9568f8dd12dcfab.tar.gz
Replace gql in Encoder tests with multiline string
Diffstat (limited to 'tests/Language/GraphQL/AST/LexerSpec.hs')
-rw-r--r--tests/Language/GraphQL/AST/LexerSpec.hs51
1 files changed, 25 insertions, 26 deletions
diff --git a/tests/Language/GraphQL/AST/LexerSpec.hs b/tests/Language/GraphQL/AST/LexerSpec.hs
index e22c6b0..3cfa22e 100644
--- a/tests/Language/GraphQL/AST/LexerSpec.hs
+++ b/tests/Language/GraphQL/AST/LexerSpec.hs
@@ -1,5 +1,4 @@
{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE QuasiQuotes #-}
module Language.GraphQL.AST.LexerSpec
( spec
) where
@@ -7,7 +6,6 @@ module Language.GraphQL.AST.LexerSpec
import Data.Text (Text)
import Data.Void (Void)
import Language.GraphQL.AST.Lexer
-import Language.GraphQL.TH
import Test.Hspec (Spec, context, describe, it)
import Test.Hspec.Megaparsec (shouldParse, shouldFailOn, shouldSucceedOn)
import Text.Megaparsec (ParseErrorBundle, parse)
@@ -19,38 +17,39 @@ spec = describe "Lexer" $ do
parse unicodeBOM "" `shouldSucceedOn` "\xfeff"
it "lexes strings" $ do
- parse string "" [gql|"simple"|] `shouldParse` "simple"
- parse string "" [gql|" white space "|] `shouldParse` " white space "
- parse string "" [gql|"quote \""|] `shouldParse` [gql|quote "|]
- parse string "" [gql|"escaped \n"|] `shouldParse` "escaped \n"
- parse string "" [gql|"slashes \\ \/"|] `shouldParse` [gql|slashes \ /|]
- parse string "" [gql|"unicode \u1234\u5678\u90AB\uCDEF"|]
+ parse string "" "\"simple\"" `shouldParse` "simple"
+ parse string "" "\" white space \"" `shouldParse` " white space "
+ parse string "" "\"quote \\\"\"" `shouldParse` "quote \""
+ parse string "" "\"escaped \\n\"" `shouldParse` "escaped \n"
+ parse string "" "\"slashes \\\\ \\/\"" `shouldParse` "slashes \\ /"
+ parse string "" "\"unicode \\u1234\\u5678\\u90AB\\uCDEF\""
`shouldParse` "unicode ሴ噸邫췯"
it "lexes block string" $ do
- parse blockString "" [gql|"""simple"""|] `shouldParse` "simple"
- parse blockString "" [gql|""" white space """|]
+ parse blockString "" "\"\"\"simple\"\"\"" `shouldParse` "simple"
+ parse blockString "" "\"\"\" white space \"\"\""
`shouldParse` " white space "
- parse blockString "" [gql|"""contains " quote"""|]
- `shouldParse` [gql|contains " quote|]
- parse blockString "" [gql|"""contains \""" triplequote"""|]
- `shouldParse` [gql|contains """ triplequote|]
+ parse blockString "" "\"\"\"contains \" quote\"\"\""
+ `shouldParse` "contains \" quote"
+ parse blockString "" "\"\"\"contains \\\"\"\" triplequote\"\"\""
+ `shouldParse` "contains \"\"\" triplequote"
parse blockString "" "\"\"\"multi\nline\"\"\"" `shouldParse` "multi\nline"
parse blockString "" "\"\"\"multi\rline\r\nnormalized\"\"\""
`shouldParse` "multi\nline\nnormalized"
parse blockString "" "\"\"\"multi\rline\r\nnormalized\"\"\""
`shouldParse` "multi\nline\nnormalized"
- parse blockString "" [gql|"""unescaped \n\r\b\t\f\u1234"""|]
- `shouldParse` [gql|unescaped \n\r\b\t\f\u1234|]
- parse blockString "" [gql|"""slashes \\ \/"""|]
- `shouldParse` [gql|slashes \\ \/|]
- parse blockString "" [gql|"""
-
- spans
- multiple
- lines
-
- """|] `shouldParse` "spans\n multiple\n lines"
+ parse blockString "" "\"\"\"unescaped \\n\\r\\b\\t\\f\\u1234\"\"\""
+ `shouldParse` "unescaped \\n\\r\\b\\t\\f\\u1234"
+ parse blockString "" "\"\"\"slashes \\\\ \\/\"\"\""
+ `shouldParse` "slashes \\\\ \\/"
+ parse blockString "" "\"\"\"\n\
+ \\n\
+ \ spans\n\
+ \ multiple\n\
+ \ lines\n\
+ \\n\
+ \\"\"\""
+ `shouldParse` "spans\n multiple\n lines"
it "lexes numbers" $ do
parse integer "" "4" `shouldParse` (4 :: Int)
@@ -84,7 +83,7 @@ spec = describe "Lexer" $ do
context "Implementation tests" $ do
it "lexes empty block strings" $
- parse blockString "" [gql|""""""|] `shouldParse` ""
+ parse blockString "" "\"\"\"\"\"\"" `shouldParse` ""
it "lexes ampersand" $
parse amp "" "&" `shouldParse` "&"
it "lexes schema extensions" $