platform/packages/combinator/test/value_test.dart

16 lines
385 B
Dart
Raw Normal View History

2021-05-14 06:11:50 +00:00
import 'package:angel3_combinator/angel3_combinator.dart';
2021-03-17 23:04:36 +00:00
import 'package:test/test.dart';
import 'common.dart';
2021-05-14 06:11:50 +00:00
void main() {
2021-03-17 23:04:36 +00:00
var parser = match('hello').value((r) => 'world');
test('sets value', () {
2021-03-31 06:33:31 +00:00
expect(parser.parse(scan('hello world')).value, 'world');
2021-03-17 23:04:36 +00:00
});
test('no value if no match', () {
2021-03-31 06:33:31 +00:00
expect(parser.parse(scan('goodbye world')).value, isNull);
2021-03-17 23:04:36 +00:00
});
}