OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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 // Dart test program for RegExp.allMatches. | 5 // Dart test program for RegExp.allMatches. |
6 | 6 |
7 class RegExpAllMatchesTest { | 7 class RegExpAllMatchesTest { |
8 static testIterator() { | 8 static testIterator() { |
9 var matches = new RegExp("foo").allMatches("foo foo"); | 9 var matches = new RegExp("foo").allMatches("foo foo"); |
10 Iterator it = matches.iterator(); | 10 Iterator it = matches.iterator(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 Expect.equals(true, matches.some((Match m) { | 80 Expect.equals(true, matches.some((Match m) { |
81 return m.group(0).startsWith("foo"); | 81 return m.group(0).startsWith("foo"); |
82 })); | 82 })); |
83 Expect.equals(false, matches.some((Match m) { | 83 Expect.equals(false, matches.some((Match m) { |
84 return m.group(0).startsWith("fooo"); | 84 return m.group(0).startsWith("fooo"); |
85 })); | 85 })); |
86 } | 86 } |
87 | 87 |
88 static testIsEmpty() { | 88 static testIsEmpty() { |
89 var matches = new RegExp("foo?").allMatches("foo fo foo fo"); | 89 var matches = new RegExp("foo?").allMatches("foo fo foo fo"); |
90 Expect.equals(false, matches.isEmpty()); | 90 Expect.equals(false, matches.isEmpty); |
91 matches = new RegExp("fooo").allMatches("foo fo foo fo"); | 91 matches = new RegExp("fooo").allMatches("foo fo foo fo"); |
92 Expect.equals(true, matches.isEmpty()); | 92 Expect.equals(true, matches.isEmpty); |
93 } | 93 } |
94 | 94 |
95 static testGetCount() { | 95 static testGetCount() { |
96 var matches = new RegExp("foo?").allMatches("foo fo foo fo"); | 96 var matches = new RegExp("foo?").allMatches("foo fo foo fo"); |
97 Expect.equals(4, matches.length); | 97 Expect.equals(4, matches.length); |
98 matches = new RegExp("fooo").allMatches("foo fo foo fo"); | 98 matches = new RegExp("fooo").allMatches("foo fo foo fo"); |
99 Expect.equals(0, matches.length); | 99 Expect.equals(0, matches.length); |
100 } | 100 } |
101 | 101 |
102 static testMain() { | 102 static testMain() { |
103 testIterator(); | 103 testIterator(); |
104 testForEach(); | 104 testForEach(); |
105 testMap(); | 105 testMap(); |
106 testFilter(); | 106 testFilter(); |
107 testEvery(); | 107 testEvery(); |
108 testSome(); | 108 testSome(); |
109 testIsEmpty(); | 109 testIsEmpty(); |
110 testGetCount(); | 110 testGetCount(); |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 main() { | 114 main() { |
115 RegExpAllMatchesTest.testMain(); | 115 RegExpAllMatchesTest.testMain(); |
116 } | 116 } |
OLD | NEW |