summaryrefslogtreecommitdiff
path: root/source/Test/Unit/Token.hs
diff options
context:
space:
mode:
Diffstat (limited to 'source/Test/Unit/Token.hs')
-rw-r--r--source/Test/Unit/Token.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/source/Test/Unit/Token.hs b/source/Test/Unit/Token.hs
index b676f55..d399e2a 100644
--- a/source/Test/Unit/Token.hs
+++ b/source/Test/Unit/Token.hs
@@ -22,6 +22,8 @@ unitTests = testGroup "Lexer"
, testCase "braces inside text do not close the text frame" textBraceNesting
, testCase "cases is tokenized as an environment only inside math" casesOnlyInsideMath
, testCase "imports retain source locations and POSIX spellings" locatedImports
+ , testCase "commented environment starts are ignored"
+ ignoresCommentedEnvironmentStart
, testCase "empty inputs construct empty lexical syntax"
constructsEmptyLexicalSyntax
, testCase "extracts exact source fixity pragmas"
@@ -130,6 +132,24 @@ locatedImports = do
Right imports ->
assertFailure ("expected two imports, got " <> show imports)
+ignoresCommentedEnvironmentStart :: Assertion
+ignoresCommentedEnvironmentStart = do
+ let raw = Text.unlines
+ [ "% \\begin{signature}"
+ , "ordinary text"
+ , "\\begin{struct}"
+ , " an ordered set $X$ is a onesorted structure."
+ , "\\end{struct}"
+ ]
+ (_, chunks) <-
+ either
+ (assertFailure . errorBundlePretty)
+ pure
+ (runLexer (FileId maxBound) "commented-environment" raw)
+ case chunks of
+ [Located{unLocated = BeginEnv "struct"} : _] -> pure ()
+ _ -> assertFailure ("expected the real structure environment, got " <> show chunks)
+
constructsEmptyLexicalSyntax :: Assertion
constructsEmptyLexicalSyntax =
forM_