lex: expressions
This commit is contained in:
parent
471de1c68a
commit
43be9e3f7f
2 changed files with 61 additions and 9 deletions
51
test/Spec.hs
51
test/Spec.hs
|
|
@ -18,20 +18,23 @@ main = hspec $ do
|
|||
describe "Lexer" do
|
||||
describe "minimal" do
|
||||
it "handles unicode" unicode
|
||||
it "escapes" escaping
|
||||
it "emphasis" emphatic
|
||||
it "bold" bolded
|
||||
it "monospace" monospace
|
||||
it "module names" modules
|
||||
it "labeled link" labeledLink
|
||||
it "markdown link" link
|
||||
it "anchors" anchor
|
||||
it "images" images
|
||||
it "maths" math
|
||||
it "numeric entity" numericEntity
|
||||
it "monospace" monospace
|
||||
it "code blocks" codeBlocks
|
||||
it "anchors" anchor
|
||||
it "bird tracks" birdTracks
|
||||
it "expressions" expressions
|
||||
|
||||
it "escapes" escaping
|
||||
it "space chars" space
|
||||
it "bare string" someString
|
||||
it "emphasis" emphatic
|
||||
it "labeled link" labeledLink
|
||||
it "markdown link" link
|
||||
it "bird tracks" birdTracks
|
||||
it "module names" modules
|
||||
it "quotes" quotes
|
||||
it "ignores nesting" ignoreNesting
|
||||
|
||||
|
|
@ -142,6 +145,30 @@ ignoreNesting =
|
|||
`shouldLexTo` [ (1, 1, Token ">/foo/")
|
||||
]
|
||||
|
||||
expressions :: Expectation
|
||||
expressions = do
|
||||
"""
|
||||
>>> expression
|
||||
result line 1
|
||||
result line 2
|
||||
|
||||
"""
|
||||
`shouldLexTo` [ (1, 1, Expression)
|
||||
, (1, 5, Token "expression")
|
||||
, (2, 1, ResultLine "result line 1")
|
||||
, (3, 1, ResultLine "result line 2")
|
||||
]
|
||||
"""
|
||||
>>> expression
|
||||
result line 3
|
||||
result line 4
|
||||
"""
|
||||
`shouldLexTo` [ (1, 1, Expression)
|
||||
, (1, 5, Token "expression")
|
||||
, (2, 1, ResultLine "result line 3")
|
||||
, (3, 1, ResultLine "result line 4")
|
||||
]
|
||||
|
||||
birdTracks :: Expectation
|
||||
birdTracks =
|
||||
">> code"
|
||||
|
|
@ -200,6 +227,14 @@ monospace =
|
|||
, (1, 6, MonospaceClose)
|
||||
]
|
||||
|
||||
bolded :: Expectation
|
||||
bolded =
|
||||
"__bold text__"
|
||||
`shouldLexTo` [ (1, 1, BoldOpen)
|
||||
, (1, 3, Token "bold text")
|
||||
, (1, 12, BoldClose)
|
||||
]
|
||||
|
||||
emphatic :: Expectation
|
||||
emphatic =
|
||||
"/emphatic/"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue