File tree Expand file tree Collapse file tree
tests/src/Test/Compiler/Parse Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,8 +171,8 @@ term =
171171 |> Parser.skip (Parser.chompChar '(' (ExpectedChar '('))
172172 |> Parser.skip spaceParser
173173 |> Parser.keep expression
174- |> Parser.keep Parser.getPosition
175174 |> Parser.skip (Parser.chompChar ')' (ExpectedChar ')'))
175+ |> Parser.keep Parser.getPosition
176176 , Parser.succeed (\record end -> SourcePosition.at start end record)
177177 |> Parser.keep recordParser
178178 |> Parser.keep Parser.getPosition
Original file line number Diff line number Diff line change @@ -91,6 +91,19 @@ tests =
9191 { row = 1, col = 3 }
9292 (AST.TVar "a")
9393 )
94+ , test "Parenthesized end position includes closing paren" <| \_ ->
95+ Parser.run PT.expression Context.empty "(a)"
96+ |> expectLocatedExpression
97+ (SourcePosition.at
98+ { row = 1, col = 1 }
99+ { row = 1, col = 4 }
100+ (AST.TParens <|
101+ SourcePosition.at
102+ { row = 1, col = 2 }
103+ { row = 1, col = 3 }
104+ (AST.TVar "a")
105+ )
106+ )
94107 , test "Empty Record" <| \_ ->
95108 Parser.run PT.expression Context.empty "{ }"
96109 |> expectExpression
@@ -286,3 +299,13 @@ expectExpression expected result =
286299
287300 Ok { value } ->
288301 Expect.equal expected value
302+
303+
304+ expectLocatedExpression : (SourcePosition.Located a) -> Result (Array (Parser.DeadEnd c e)) (SourcePosition.Located a) -> Expectation
305+ expectLocatedExpression expected result =
306+ when result is
307+ Err err ->
308+ Expect.fail (Debug.toString err)
309+
310+ Ok value ->
311+ Expect.equal expected value
You can’t perform that action at this time.
0 commit comments