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

Unified Diff: tools/codemirror/dart/test/codemirror_tests.dart

Issue 9034030: Codemirror dart port StringStream datatype babysteps. (Closed) Base URL: http://dart.googlecode.com/svn/experimental/
Patch Set: Created 9 years 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
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);
+}

Powered by Google App Engine
This is Rietveld 408576698