Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2251)

Unified Diff: packages/petitparser/test/test_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/petitparser/test/smalltalk_test.dart ('k') | packages/petitparser/tool/travis.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/petitparser/test/test_test.dart
diff --git a/packages/petitparser/test/test_test.dart b/packages/petitparser/test/test_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3122aca1b0828fba57398b9cde20157c312bba2b
--- /dev/null
+++ b/packages/petitparser/test/test_test.dart
@@ -0,0 +1,72 @@
+library petitparser.test.test_test;
+
+import 'package:test/test.dart';
+
+import 'package:petitparser/petitparser.dart';
+import 'package:petitparser/test.dart';
+
+void main() {
+ group('accept', () {
+ test('success', () {
+ var matcher = accept(char('a'));
+ var state = new Map();
+ expect(matcher.matches('a', state), isTrue);
+ expect(state, isEmpty);
+ var description = new StringDescription();
+ matcher.describe(description);
+ expect(description.toString(), '"Instance of \'CharacterParser\'["a" expected]" accepts input');
+ });
+ test('failure', () {
+ var matcher = accept(char('a'));
+ var state = new Map();
+ expect(matcher.matches('b', state), isFalse);
+ expect(state, isNot(isEmpty));
+ var description = new StringDescription();
+ matcher.describeMismatch('b', description, state, false);
+ expect(description.toString(), '"Instance of \'CharacterParser\'["a" expected]" produces "Failure[1:1]: "a" expected" which is not accepted');
+ });
+ });
+ group('parse', () {
+ test('success', () {
+ var matcher = parse(char('a'), 'a');
+ var state = new Map();
+ expect(matcher.matches('a', state), isTrue);
+ expect(state, isEmpty);
+ var description = new StringDescription();
+ matcher.describe(description);
+ expect(description.toString(), '"Instance of \'CharacterParser\'["a" expected]" '
+ 'accepts \'a\'');
+ });
+ test('failure', () {
+ var matcher = parse(char('a'), 'a');
+ var state = new Map();
+ expect(matcher.matches('b', state), isFalse);
+ expect(state, isNot(isEmpty));
+ var description = new StringDescription();
+ matcher.describeMismatch('b', description, state, false);
+ expect(description.toString(), '"Instance of \'CharacterParser\'["a" expected]" '
+ 'produces "Failure[1:1]: "a" expected" which is not accepted');
+ });
+ test('matcher', () {
+ var matcher = parse(char('a'), 'b');
+ var state = new Map();
+ expect(matcher.matches('a', state), isFalse);
+ expect(state, isNot(isEmpty));
+ var description = new StringDescription();
+ matcher.describeMismatch('a', description, state, false);
+ expect(description.toString(), '"Instance of \'CharacterParser\'["a" expected]" '
+ 'produces "Success[1:2]: a" which parse result is different.\n'
+ 'Expected: b\n Actual: a\n ^\n Differ at offset 0');
+ });
+ test('position', () {
+ var matcher = parse(char('a'), 'a', 0);
+ var state = new Map();
+ expect(matcher.matches('a', state), isFalse);
+ expect(state, isNot(isEmpty));
+ var description = new StringDescription();
+ matcher.describeMismatch('a', description, state, false);
+ expect(description.toString(), '"Instance of \'CharacterParser\'["a" expected]" '
+ 'produces "Success[1:2]: a" that consumes input to 1 instead of 0');
+ });
+ });
+}
« no previous file with comments | « packages/petitparser/test/smalltalk_test.dart ('k') | packages/petitparser/tool/travis.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698