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

Side by Side 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 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #library('codemirror_tests');
6
7 #import('../../../../../dart/client/testing/unittest/unittest.dart');
8 #import('../lib/codemirror.dart');
9
10 void main(){
11
12 test('StringStream_basic', () {
13 String text = 'text';
14 StringStream str = stream(text);
15 expect(str.sol()).isTrue();
16 expect(str.eol()).isFalse();
17 for (int i=0; i < text.length; ++i){
18 expect(str.peek()).equals(text[i]);
19 expect(str.next()).equals(text[i]); //advances
20 }
21 expect(str.sol()).isFalse();
22 expect(str.eol()).isTrue();
23 });
24
25 test('StringStream_eat', () {
26 StringStream str = stream('abcd');
27 expect(str.eat('a')).equals('a');
28 expect(str.peek()).equals('b');
29 });
30
31 test('StringStream_eatWhile', () {
32 StringStream str = stream('aabc');
33 expect(str.eatWhile('a')).isTrue();
34 expect(str.peek()).equals('b');
35 });
36
37 test('StringStream_eatSpace', () {
38 StringStream str = stream(' abcdef');
39 expect(str.eatSpace()).isTrue();
40 expect(str.peek()).equals('a');
41 });
42
43 test('StringStream_skipTo', () {
44 StringStream str = stream('abc def');
45 expect(str.skipTo('d')).isTrue();
46 expect(str.peek()).equals('d');
47 });
48
49 test('StringStream_match', () {
50 expect(stream('abcdef').match('abc')).isTrue();
51 expect(stream('abcdef').match('ABC', caseInsensitive: true)).isTrue();
52 expect(stream('abcdef').match('xxx')).isFalse();
53 StringStream str = stream('abcdef');
54 expect(str.match('abc', consume: true)).isTrue();
55 expect(str.peek()).equals('d');
56 str = stream('abcdef');
57 expect(str.match('abc', consume: false)).isTrue();
58 expect(str.peek()).equals('a');
59 });
60
61 test('countColumn', () {
62 expect(countColumn('0123456789')).equals(10);
63 expect(countColumn('a\tb')).equals(9); //default tabCount = 8
64 });
65
66 }
67
68 StringStream stream(String str) {
69 return new StringStream(str);
70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698