Skip to content

Commit

Permalink
Merge pull request #146 from inhabitedtype/fix-choice-commit
Browse files Browse the repository at this point in the history
fix-choice-commit: check parser_committed_bytes
  • Loading branch information
seliopou authored Jun 9, 2018
2 parents c914dbc + b556d3d commit 4dd75af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ module Choice = struct
* of the committed input, then calling the failure continuation will
* have the effect of unwinding all choices and collecting marks along
* the way. *)
if pos < Input.client_committed_bytes input' then
if pos < Input.parser_committed_bytes input' then
fail input' pos' more marks msg
else
q.run input' pos more' fail succ in
Expand Down
14 changes: 14 additions & 0 deletions lib_test/test_angstrom.ml
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,19 @@ let count_while_regression =
(take_while1 (fun _ -> true) <* end_of_input) ["asdf"; ""] "asdf";
end ]

let choice_commit =
[ "", `Quick, begin fun () ->
let p =
choice [ string "@@" *> commit *> char '*'
; string "@" *> commit *> char '!' ]
in
Alcotest.(check (result reject string))
"commit to branch"
(Error ": char '*'")
(parse_string p "@@^");
end ]


let () =
Alcotest.run "test suite"
[ "basic constructors" , basic_constructors
Expand All @@ -358,4 +371,5 @@ let () =
; "combinators" , combinators
; "incremental input" , incremental
; "count_while regression", count_while_regression
; "choice and commit" , choice_commit
]

0 comments on commit 4dd75af

Please sign in to comment.