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

Unified Diff: pkg/string_scanner/test/expect_error_test.dart

Issue 222843003: Convert shelf to use the string_scanner package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | « pkg/string_scanner/test/error_test.dart ('k') | pkg/string_scanner/test/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/string_scanner/test/expect_error_test.dart
diff --git a/pkg/string_scanner/test/error_format_test.dart b/pkg/string_scanner/test/expect_error_test.dart
similarity index 78%
rename from pkg/string_scanner/test/error_format_test.dart
rename to pkg/string_scanner/test/expect_error_test.dart
index 11873440050265c107d10b6b5ccec2130e3c5379..3596e15e5cf053054edb4fb3f373fd3ff0004d39 100644
--- a/pkg/string_scanner/test/error_format_test.dart
+++ b/pkg/string_scanner/test/expect_error_test.dart
@@ -2,17 +2,19 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library string_scanner.error_format_test;
+library string_scanner.expect_error_test;
import 'package:string_scanner/string_scanner.dart';
import 'package:unittest/unittest.dart';
+import 'utils.dart';
+
void main() {
test('points to the first unconsumed character', () {
var scanner = new StringScanner('foo bar baz');
scanner.expect('foo ');
expect(() => scanner.expect('foo'), throwsFormattedError('''
-Expected "foo" on line 1, column 5.
+Error on line 1, column 5: expected "foo".
foo bar baz
^'''));
});
@@ -21,7 +23,7 @@ foo bar baz
var scanner = new StringScanner('foo bar baz\ndo re mi\nearth fire water');
scanner.expect('foo bar baz\ndo ');
expect(() => scanner.expect('foo'), throwsFormattedError('''
-Expected "foo" on line 2, column 4.
+Error on line 2, column 4: expected "foo".
do re mi
^'''));
});
@@ -29,7 +31,7 @@ do re mi
test('handles the beginning of the string correctly', () {
var scanner = new StringScanner('foo bar baz');
expect(() => scanner.expect('zap'), throwsFormattedError('''
-Expected "zap" on line 1, column 1.
+Error on line 1, column 1: expected "zap".
foo bar baz
^'''));
});
@@ -38,14 +40,14 @@ foo bar baz
var scanner = new StringScanner('foo bar baz');
scanner.expect('foo bar baz');
expect(() => scanner.expect('bang'), throwsFormattedError('''
-Expected "bang" on line 1, column 12.
+Error on line 1, column 12: expected "bang".
foo bar baz
^'''));
});
test('handles an empty string correctly', () {
expect(() => new StringScanner('').expect('foo'), throwsFormattedError('''
-Expected "foo" on line 1, column 1.
+Error on line 1, column 1: expected "foo".
^'''));
});
@@ -54,7 +56,7 @@ Expected "foo" on line 1, column 1.
test("uses the provided name", () {
expect(() => new StringScanner('').expect('foo bar', name: 'zap'),
throwsFormattedError('''
-Expected zap on line 1, column 1.
+Error on line 1, column 1: expected zap.
^'''));
});
@@ -62,7 +64,7 @@ Expected zap on line 1, column 1.
test("escapes string quotes", () {
expect(() => new StringScanner('').expect('foo"bar'),
throwsFormattedError('''
-Expected "foo\\"bar" on line 1, column 1.
+Error on line 1, column 1: expected "foo\\"bar".
^'''));
});
@@ -70,7 +72,7 @@ Expected "foo\\"bar" on line 1, column 1.
test("escapes string backslashes", () {
expect(() => new StringScanner('').expect('foo\\bar'),
throwsFormattedError('''
-Expected "foo\\\\bar" on line 1, column 1.
+Error on line 1, column 1: expected "foo\\\\bar".
^'''));
});
@@ -78,7 +80,7 @@ Expected "foo\\\\bar" on line 1, column 1.
test("prints PERL-style regexps", () {
expect(() => new StringScanner('').expect(new RegExp(r'foo')),
throwsFormattedError('''
-Expected /foo/ on line 1, column 1.
+Error on line 1, column 1: expected /foo/.
^'''));
});
@@ -86,7 +88,7 @@ Expected /foo/ on line 1, column 1.
test("escape regexp forward slashes", () {
expect(() => new StringScanner('').expect(new RegExp(r'foo/bar')),
throwsFormattedError('''
-Expected /foo\\/bar/ on line 1, column 1.
+Error on line 1, column 1: expected /foo\\/bar/.
^'''));
});
@@ -94,17 +96,9 @@ Expected /foo\\/bar/ on line 1, column 1.
test("does not escape regexp backslashes", () {
expect(() => new StringScanner('').expect(new RegExp(r'foo\bar')),
throwsFormattedError('''
-Expected /foo\\bar/ on line 1, column 1.
+Error on line 1, column 1: expected /foo\\bar/.
^'''));
});
});
}
-
-Matcher throwsFormattedError(String format) {
- return throwsA(predicate((error) {
- expect(error, isFormatException);
- expect(error.message, equals(format));
- return true;
- }));
-}
« no previous file with comments | « pkg/string_scanner/test/error_test.dart ('k') | pkg/string_scanner/test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698