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

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

Issue 299973002: Add LineScanner and SpanScanner classes to string_scanner. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 7 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/span_scanner_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/string_scanner_test.dart
diff --git a/pkg/string_scanner/test/string_scanner_test.dart b/pkg/string_scanner/test/string_scanner_test.dart
index 0cab6273ebf2e2975bf374b26b7f14574abd76f2..6144bf9c007c3dcc30b09684d9899df46c8ddf68 100644
--- a/pkg/string_scanner/test/string_scanner_test.dart
+++ b/pkg/string_scanner/test/string_scanner_test.dart
@@ -31,6 +31,18 @@ void main() {
expect(scanner.position, equals(0));
});
+ test("readChar fails and doesn't change the state", () {
+ expect(scanner.readChar, throwsFormatException);
+ expect(scanner.lastMatch, isNull);
+ expect(scanner.position, equals(0));
+ });
+
+ test("peekChar returns null and doesn't change the state", () {
+ expect(scanner.peekChar(), isNull);
+ expect(scanner.lastMatch, isNull);
+ expect(scanner.position, equals(0));
+ });
+
test("scan returns false and doesn't change the state", () {
expect(scanner.scan(new RegExp('.')), isFalse);
expect(scanner.lastMatch, isNull);
@@ -85,6 +97,24 @@ void main() {
expect(scanner.position, equals(0));
});
+ test('readChar returns the first character and moves forward', () {
+ expect(scanner.readChar(), equals(0x66));
+ expect(scanner.lastMatch, isNull);
+ expect(scanner.position, equals(1));
+ });
+
+ test('peekChar returns the first character', () {
+ expect(scanner.peekChar(), equals(0x66));
+ expect(scanner.lastMatch, isNull);
+ expect(scanner.position, equals(0));
+ });
+
+ test('peekChar with an argument returns the nth character', () {
+ expect(scanner.peekChar(4), equals(0x62));
+ expect(scanner.lastMatch, isNull);
+ expect(scanner.position, equals(0));
+ });
+
test("a matching scan returns true and changes the state", () {
expect(scanner.scan(new RegExp('f(..)')), isTrue);
expect(scanner.lastMatch[1], equals('oo'));
@@ -200,6 +230,18 @@ void main() {
expect(scanner.position, equals(7));
});
+ test("readChar fails and doesn't change the state", () {
+ expect(scanner.readChar, throwsFormatException);
+ expect(scanner.lastMatch, isNotNull);
+ expect(scanner.position, equals(7));
+ });
+
+ test("peekChar returns null and doesn't change the state", () {
+ expect(scanner.peekChar(), isNull);
+ expect(scanner.lastMatch, isNotNull);
+ expect(scanner.position, equals(7));
+ });
+
test("scan returns false and sets lastMatch to null", () {
expect(scanner.scan(new RegExp('.')), isFalse);
expect(scanner.lastMatch, isNull);
« no previous file with comments | « pkg/string_scanner/test/span_scanner_test.dart ('k') | pkg/string_scanner/test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698