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

Unified Diff: packages/string_scanner/test/line_scanner_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 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/string_scanner/test/error_test.dart ('k') | packages/string_scanner/test/span_scanner_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/string_scanner/test/line_scanner_test.dart
diff --git a/packages/string_scanner/test/line_scanner_test.dart b/packages/string_scanner/test/line_scanner_test.dart
index 68e5c38143b35e5ec265b55edc390dba6bf1603b..ed04b371c1e4b713e967c3c3a51c0f99a5b06095 100644
--- a/packages/string_scanner/test/line_scanner_test.dart
+++ b/packages/string_scanner/test/line_scanner_test.dart
@@ -2,8 +2,7 @@
// 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.line_scanner_test;
-
+import 'package:charcode/charcode.dart';
import 'package:string_scanner/string_scanner.dart';
import 'package:test/test.dart';
@@ -82,6 +81,39 @@ void main() {
});
});
+ group("scanChar()", () {
+ test("on a non-newline character increases the column but not the line",
+ () {
+ scanner.scanChar($f);
+ expect(scanner.line, equals(0));
+ expect(scanner.column, equals(1));
+ });
+
+ test("consuming a newline resets the column and increases the line", () {
+ scanner.expect('foo');
+ expect(scanner.line, equals(0));
+ expect(scanner.column, equals(3));
+
+ scanner.scanChar($lf);
+ expect(scanner.line, equals(1));
+ expect(scanner.column, equals(0));
+ });
+
+ test("consuming halfway through a CR LF doesn't count as a line", () {
+ scanner.expect('foo\nbar');
+ expect(scanner.line, equals(1));
+ expect(scanner.column, equals(3));
+
+ scanner.scanChar($cr);
+ expect(scanner.line, equals(1));
+ expect(scanner.column, equals(4));
+
+ scanner.scanChar($lf);
+ expect(scanner.line, equals(2));
+ expect(scanner.column, equals(0));
+ });
+ });
+
group("position=", () {
test("forward through newlines sets the line and column", () {
scanner.position = 10; // "foo\nbar\r\nb"
« no previous file with comments | « packages/string_scanner/test/error_test.dart ('k') | packages/string_scanner/test/span_scanner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698