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

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
« no previous file with comments | « tools/codemirror/dart/lib/codemirror.dart ('k') | tools/codemirror/dart/test/index.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // This source code is licensed under the terms described in the LICENSE file.
2
3 #library('codemirror_tests');
4
5 #import('../../../../../dart/client/testing/unittest/unittest.dart');
6 #import('../lib/codemirror.dart');
7
8 void main(){
9
10 test('StringStream_basic', () {
11 String text = 'text';
12 StringStream str = stream(text);
13 expect(str.sol()).isTrue();
14 expect(str.eol()).isFalse();
15 for (int i=0; i < text.length; ++i){
16 expect(str.peek()).equals(text[i]);
17 expect(str.next()).equals(text[i]); //advances
18 }
19 expect(str.sol()).isFalse();
20 expect(str.eol()).isTrue();
21 });
22
23 test('StringStream_eat', () {
24 StringStream str = stream('abcd');
25 expect(str.eat('a')).equals('a');
26 expect(str.peek()).equals('b');
27 });
28
29 test('StringStream_eatWhile', () {
30 StringStream str = stream('aabc');
31 expect(str.eatWhile('a')).isTrue();
32 expect(str.peek()).equals('b');
33 });
34
35 test('StringStream_eatSpace', () {
36 StringStream str = stream(' abcdef');
37 expect(str.eatSpace()).isTrue();
38 expect(str.peek()).equals('a');
39 });
40
41 test('StringStream_skipTo', () {
42 StringStream str = stream('abc def');
43 expect(str.skipTo('d')).isTrue();
44 expect(str.peek()).equals('d');
45 });
46
47 test('StringStream_match', () {
48 expect(stream('abcdef').match('abc')).isTrue();
49 expect(stream('abcdef').match('ABC', caseInsensitive: true)).isTrue();
50 expect(stream('abcdef').match('xxx')).isFalse();
51 StringStream str = stream('abcdef');
52 expect(str.match('abc', consume: true)).isTrue();
53 expect(str.peek()).equals('d');
54 str = stream('abcdef');
55 expect(str.match('abc', consume: false)).isTrue();
56 expect(str.peek()).equals('a');
57 });
58
59 test('countColumn', () {
60 expect(countColumn('0123456789')).equals(10);
61 expect(countColumn('a\tb')).equals(9); //default tabCount = 8
62 });
63
64 }
65
66 StringStream stream(String str) {
67 return new StringStream(str);
68 }
OLDNEW
« no previous file with comments | « tools/codemirror/dart/lib/codemirror.dart ('k') | tools/codemirror/dart/test/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698