OLD | NEW |
1 // Copyright (c) 2012, 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 main() { | 5 main() { |
6 var list = "a b c".split(const RegExp(" ")); | 6 var list = "a b c".split(new RegExp(" ")); |
7 Expect.equals(3, list.length); | 7 Expect.equals(3, list.length); |
8 Expect.equals("a", list[0]); | 8 Expect.equals("a", list[0]); |
9 Expect.equals("b", list[1]); | 9 Expect.equals("b", list[1]); |
10 Expect.equals("c", list[2]); | 10 Expect.equals("c", list[2]); |
11 | 11 |
12 list = "adbdc".split(const RegExp("[dz]")); | 12 list = "adbdc".split(new RegExp("[dz]")); |
13 Expect.equals(3, list.length); | 13 Expect.equals(3, list.length); |
14 Expect.equals("a", list[0]); | 14 Expect.equals("a", list[0]); |
15 Expect.equals("b", list[1]); | 15 Expect.equals("b", list[1]); |
16 Expect.equals("c", list[2]); | 16 Expect.equals("c", list[2]); |
17 | 17 |
18 list = "addbddc".split(new RegExp("dd")); | 18 list = "addbddc".split(new RegExp("dd")); |
19 Expect.equals(3, list.length); | 19 Expect.equals(3, list.length); |
20 Expect.equals("a", list[0]); | 20 Expect.equals("a", list[0]); |
21 Expect.equals("b", list[1]); | 21 Expect.equals("b", list[1]); |
22 Expect.equals("c", list[2]); | 22 Expect.equals("c", list[2]); |
23 | 23 |
24 list = "abc".split(new RegExp(r"b$")); | 24 list = "abc".split(new RegExp(r"b$")); |
25 Expect.equals(1, list.length); | 25 Expect.equals(1, list.length); |
26 Expect.equals("abc", list[0]); | 26 Expect.equals("abc", list[0]); |
27 | 27 |
28 list = "abc".split(new RegExp("")); | 28 list = "abc".split(new RegExp("")); |
29 Expect.equals(3, list.length); | 29 Expect.equals(3, list.length); |
30 Expect.equals("a", list[0]); | 30 Expect.equals("a", list[0]); |
31 Expect.equals("b", list[1]); | 31 Expect.equals("b", list[1]); |
32 Expect.equals("c", list[2]); | 32 Expect.equals("c", list[2]); |
33 | 33 |
34 list = " ".split(new RegExp("[ ]")); | 34 list = " ".split(new RegExp("[ ]")); |
35 Expect.equals(4, list.length); | 35 Expect.equals(4, list.length); |
36 Expect.equals("", list[0]); | 36 Expect.equals("", list[0]); |
37 Expect.equals("", list[1]); | 37 Expect.equals("", list[1]); |
38 Expect.equals("", list[2]); | 38 Expect.equals("", list[2]); |
39 Expect.equals("", list[3]); | 39 Expect.equals("", list[3]); |
40 | 40 |
41 list = "aaa".split(const RegExp(r"a$")); | 41 list = "aaa".split(new RegExp(r"a$")); |
42 Expect.equals(2, list.length); | 42 Expect.equals(2, list.length); |
43 Expect.equals("aa", list[0]); | 43 Expect.equals("aa", list[0]); |
44 Expect.equals("", list[1]); | 44 Expect.equals("", list[1]); |
45 } | 45 } |
OLD | NEW |