| 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"
|
|
|