Chromium Code Reviews| Index: tests/corelib/src/RegExpAllMatchesTest.dart |
| =================================================================== |
| --- tests/corelib/src/RegExpAllMatchesTest.dart (revision 5311) |
| +++ tests/corelib/src/RegExpAllMatchesTest.dart (working copy) |
| @@ -31,22 +31,22 @@ |
| static testForEach() { |
| var matches = new RegExp("foo").allMatches("foo foo"); |
| - var str = ""; |
| + var strbuf = new StringBuffer(); |
| matches.forEach((Match m) { |
| - str += m.group(0); |
| + strbuf.add(m.group(0)); |
| }); |
| - Expect.equals("foofoo", str); |
| + Expect.equals("foofoo", strbuf.toString()); |
| } |
| static testMap() { |
| var matches = new RegExp("foo?").allMatches("foo fo foo fo"); |
| - var mapped = matches.map((Match m) => m.group(0) + "bar"); |
| + var mapped = matches.map((Match m) => m.group(0).concat("bar")); |
|
kasperl
2012/03/12 06:55:42
I'd suggest using string interpolation here:
=
Ivan Posva
2012/04/11 14:26:00
Done.
|
| Expect.equals(4, mapped.length); |
| - var str = ""; |
| + var strbuf = new StringBuffer(); |
| for (String s in mapped) { |
| - str += s; |
| + strbuf.add(s); |
| } |
| - Expect.equals("foobarfobarfoobarfobar", str); |
| + Expect.equals("foobarfobarfoobarfobar", strbuf.toString()); |
| } |
| static testFilter() { |
| @@ -55,11 +55,11 @@ |
| return m.group(0) == 'foo'; |
| }); |
| Expect.equals(2, filtered.length); |
| - var str = ""; |
| + var strbuf = new StringBuffer(); |
| for (Match m in filtered) { |
| - str += m.group(0); |
| + strbuf.add(m.group(0)); |
| } |
| - Expect.equals("foofoo", str); |
| + Expect.equals("foofoo", strbuf.toString()); |
| } |
| static testEvery() { |