| Index: tools/codemirror/dart/test/codemirror_tests.dart
|
| ===================================================================
|
| --- tools/codemirror/dart/test/codemirror_tests.dart (revision 0)
|
| +++ tools/codemirror/dart/test/codemirror_tests.dart (revision 0)
|
| @@ -0,0 +1,70 @@
|
| +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
| +// 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('codemirror_tests');
|
| +
|
| +#import('../../../../../dart/client/testing/unittest/unittest.dart');
|
| +#import('../lib/codemirror.dart');
|
| +
|
| +void main(){
|
| +
|
| + test('StringStream_basic', () {
|
| + String text = 'text';
|
| + StringStream str = stream(text);
|
| + expect(str.sol()).isTrue();
|
| + expect(str.eol()).isFalse();
|
| + for (int i=0; i < text.length; ++i){
|
| + expect(str.peek()).equals(text[i]);
|
| + expect(str.next()).equals(text[i]); //advances
|
| + }
|
| + expect(str.sol()).isFalse();
|
| + expect(str.eol()).isTrue();
|
| + });
|
| +
|
| + test('StringStream_eat', () {
|
| + StringStream str = stream('abcd');
|
| + expect(str.eat('a')).equals('a');
|
| + expect(str.peek()).equals('b');
|
| + });
|
| +
|
| + test('StringStream_eatWhile', () {
|
| + StringStream str = stream('aabc');
|
| + expect(str.eatWhile('a')).isTrue();
|
| + expect(str.peek()).equals('b');
|
| + });
|
| +
|
| + test('StringStream_eatSpace', () {
|
| + StringStream str = stream(' abcdef');
|
| + expect(str.eatSpace()).isTrue();
|
| + expect(str.peek()).equals('a');
|
| + });
|
| +
|
| + test('StringStream_skipTo', () {
|
| + StringStream str = stream('abc def');
|
| + expect(str.skipTo('d')).isTrue();
|
| + expect(str.peek()).equals('d');
|
| + });
|
| +
|
| + test('StringStream_match', () {
|
| + expect(stream('abcdef').match('abc')).isTrue();
|
| + expect(stream('abcdef').match('ABC', caseInsensitive: true)).isTrue();
|
| + expect(stream('abcdef').match('xxx')).isFalse();
|
| + StringStream str = stream('abcdef');
|
| + expect(str.match('abc', consume: true)).isTrue();
|
| + expect(str.peek()).equals('d');
|
| + str = stream('abcdef');
|
| + expect(str.match('abc', consume: false)).isTrue();
|
| + expect(str.peek()).equals('a');
|
| + });
|
| +
|
| + test('countColumn', () {
|
| + expect(countColumn('0123456789')).equals(10);
|
| + expect(countColumn('a\tb')).equals(9); //default tabCount = 8
|
| + });
|
| +
|
| +}
|
| +
|
| +StringStream stream(String str) {
|
| + return new StringStream(str);
|
| +}
|
|
|