Skip to content

Commit

Permalink
Add example for #177.
Browse files Browse the repository at this point in the history
  • Loading branch information
renggli committed Sep 20, 2024
1 parent dc3ed82 commit e8eeeb6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/regression_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -618,4 +618,19 @@ void main() {
isParseFailure('(0.53,00)', position: 5, message: 'remove comma'));
});
});
group('github.com/petitparser/dart-petitparser/discussions/177', () {
test('continuation', () {
final variables = ['first', 'second'];
final parser = failure<String>().callCC((continuation, context) =>
variables
.map((each) => each.toParser())
.toChoiceParser()
.parseOn(context));
expect(parser, isParseSuccess('first'));
expect(parser, isParseSuccess('second'));
expect(parser, isParseFailure('third'));
variables.add('third');
expect(parser, isParseSuccess('third'));
});
});
}

0 comments on commit e8eeeb6

Please sign in to comment.