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

Unified Diff: test/string_scanner_test.dart

Issue 2056933002: Add breaking changes and release 1.0.0. (Closed) Base URL: git@github.com:dart-lang/string_scanner@master
Patch Set: Created 4 years, 6 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 | « test/error_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/string_scanner_test.dart
diff --git a/test/string_scanner_test.dart b/test/string_scanner_test.dart
index 0b4d4824f0bf2bf64cb85f4799d4cdceb004fc07..55ffa0a9f0c98792aa96294071fff8f0e7a20f4b 100644
--- a/test/string_scanner_test.dart
+++ b/test/string_scanner_test.dart
@@ -261,6 +261,32 @@ void main() {
});
});
+ group('after a scan', () {
+ var scanner;
+ setUp(() {
+ scanner = new StringScanner('foo bar');
+ expect(scanner.scan('foo'), isTrue);
+ });
+
+ test('readChar returns the first character and unsets the last match', () {
+ expect(scanner.readChar(), equals($space));
+ expect(scanner.lastMatch, isNull);
+ expect(scanner.position, equals(4));
+ });
+
+ test('a matching scanChar returns true and unsets the last match', () {
+ expect(scanner.scanChar($space), isTrue);
+ expect(scanner.lastMatch, isNull);
+ expect(scanner.position, equals(4));
+ });
+
+ test('a matching expectChar returns true and unsets the last match', () {
+ scanner.expectChar($space);
+ expect(scanner.lastMatch, isNull);
+ expect(scanner.position, equals(4));
+ });
+ });
+
group('at the end of a string', () {
var scanner;
setUp(() {
@@ -346,6 +372,13 @@ void main() {
expect(scanner.rest, equals('bar'));
});
+ test('setting and resetting position clears lastMatch', () {
+ var oldPosition = scanner.position;
+ scanner.position = 1;
+ scanner.position = oldPosition;
+ expect(scanner.lastMatch, isNull);
+ });
+
test('setting position beyond the string throws an ArgumentError', () {
expect(() {
scanner.position = 8;
« no previous file with comments | « test/error_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698