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

Side by Side Diff: tests/corelib/src/StringSplitTest.dart

Issue 9352016: Fix split with regexp for frog. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use existing style. Created 8 years, 10 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
« frog/world.dart ('K') | « tests/corelib/corelib.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class StringSplitTest { 5 splitString() {
kasperl 2012/02/07 12:32:30 testSplitString?
floitsch 2012/02/07 15:06:29 kept original file as is.
6 static testMain() { 6 var list = "a b c".split(" ");
7 var list = "a b c".split(" "); 7 Expect.equals(3, list.length);
8 Expect.equals(3, list.length); 8 Expect.equals("a", list[0]);
9 Expect.equals("a", list[0]); 9 Expect.equals("b", list[1]);
10 Expect.equals("b", list[1]); 10 Expect.equals("c", list[2]);
11 Expect.equals("c", list[2]);
12 11
13 list = "adbdc".split("d"); 12 list = "adbdc".split("d");
14 Expect.equals(3, list.length); 13 Expect.equals(3, list.length);
15 Expect.equals("a", list[0]); 14 Expect.equals("a", list[0]);
16 Expect.equals("b", list[1]); 15 Expect.equals("b", list[1]);
17 Expect.equals("c", list[2]); 16 Expect.equals("c", list[2]);
18 17
19 list = "addbddc".split("dd"); 18 list = "addbddc".split("dd");
20 Expect.equals(3, list.length); 19 Expect.equals(3, list.length);
21 Expect.equals("a", list[0]); 20 Expect.equals("a", list[0]);
22 Expect.equals("b", list[1]); 21 Expect.equals("b", list[1]);
23 Expect.equals("c", list[2]); 22 Expect.equals("c", list[2]);
24 23
25 list = "abc".split(" "); 24 list = "abc".split(" ");
26 Expect.equals(1, list.length); 25 Expect.equals(1, list.length);
27 Expect.equals("abc", list[0]); 26 Expect.equals("abc", list[0]);
28 27
29 list = "abc".split(""); 28 list = "abc".split("");
30 Expect.equals(3, list.length); 29 Expect.equals(3, list.length);
31 Expect.equals("a", list[0]); 30 Expect.equals("a", list[0]);
32 Expect.equals("b", list[1]); 31 Expect.equals("b", list[1]);
33 Expect.equals("c", list[2]); 32 Expect.equals("c", list[2]);
34 33
35 list = " ".split(" "); 34 list = " ".split(" ");
36 Expect.equals(4, list.length); 35 Expect.equals(4, list.length);
37 Expect.equals("", list[0]); 36 Expect.equals("", list[0]);
38 Expect.equals("", list[1]); 37 Expect.equals("", list[1]);
39 Expect.equals("", list[2]); 38 Expect.equals("", list[2]);
40 Expect.equals("", list[3]); 39 Expect.equals("", list[3]);
41 } 40 }
41
42 splitRegExp() {
kasperl 2012/02/07 12:32:30 testSplitRegExp?
kasperl 2012/02/07 12:34:09 Maybe it would be even better to add this in a new
floitsch 2012/02/07 15:06:29 Done.
floitsch 2012/02/07 15:06:29 now in main().
43 var list = "a b c".split(const RegExp(" "));
44 Expect.equals(3, list.length);
45 Expect.equals("a", list[0]);
46 Expect.equals("b", list[1]);
47 Expect.equals("c", list[2]);
48
49 list = "adbdc".split(const RegExp("[dz]"));
50 Expect.equals(3, list.length);
51 Expect.equals("a", list[0]);
52 Expect.equals("b", list[1]);
53 Expect.equals("c", list[2]);
54
55 list = "addbddc".split(new RegExp("dd"));
56 Expect.equals(3, list.length);
57 Expect.equals("a", list[0]);
58 Expect.equals("b", list[1]);
59 Expect.equals("c", list[2]);
60
61 list = "abc".split(new RegExp(@"b$"));
62 Expect.equals(1, list.length);
63 Expect.equals("abc", list[0]);
64
65 list = "abc".split(new RegExp(""));
66 Expect.equals(3, list.length);
67 Expect.equals("a", list[0]);
68 Expect.equals("b", list[1]);
69 Expect.equals("c", list[2]);
70
71 list = " ".split(const RegExp("[ ]"));
72 Expect.equals(4, list.length);
73 Expect.equals("", list[0]);
74 Expect.equals("", list[1]);
75 Expect.equals("", list[2]);
76 Expect.equals("", list[3]);
77
78 list = "aaa".split(const RegExp(@"a$"));
79 Expect.equals(2, list.length);
80 Expect.equals("aa", list[0]);
81 Expect.equals("", list[1]);
42 } 82 }
43 83
44 main() { 84 main() {
45 StringSplitTest.testMain(); 85 splitString();
86 splitRegExp();
46 } 87 }
OLDNEW
« frog/world.dart ('K') | « tests/corelib/corelib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698