OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. All rights reserved. | 1 // Copyright (c) 2014, the Dart project authors. All rights reserved. |
2 // Copyright 2008 the V8 project authors. All rights reserved. | 2 // Copyright 2008 the V8 project authors. All rights reserved. |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following | 10 // copyright notice, this list of conditions and the following |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 var length = matches[idx][1]; | 43 var length = matches[idx][1]; |
44 var expected = str.substring(from, from + length); | 44 var expected = str.substring(from, from + length); |
45 var name = "$str[$from..${from+length}]"; | 45 var name = "$str[$from..${from+length}]"; |
46 assertEquals(expected, result[idx].group(0), name); | 46 assertEquals(expected, result[idx].group(0), name); |
47 } | 47 } |
48 } else { | 48 } else { |
49 assertTrue(result.isEmpty); | 49 assertTrue(result.isEmpty); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 CheckMatch(new RegExp(r"abc"), "xxxabcxxxabcxxx", [[3, 3], [9, 3]]); | 53 CheckMatch(new RegExp(r"abc"), "xxxabcxxxabcxxx", [ |
54 CheckMatch(new RegExp(r"abc"), "abcabcabc", [[0, 3], [3, 3], [6, 3]]); | 54 [3, 3], |
55 CheckMatch(new RegExp(r"aba"), "ababababa", [[0, 3], [4, 3]]); | 55 [9, 3] |
56 CheckMatch(new RegExp(r"foo"), "ofooofoooofofooofo", [[1, 3], [5, 3], [12, 3]]
); | 56 ]); |
| 57 CheckMatch(new RegExp(r"abc"), "abcabcabc", [ |
| 58 [0, 3], |
| 59 [3, 3], |
| 60 [6, 3] |
| 61 ]); |
| 62 CheckMatch(new RegExp(r"aba"), "ababababa", [ |
| 63 [0, 3], |
| 64 [4, 3] |
| 65 ]); |
| 66 CheckMatch(new RegExp(r"foo"), "ofooofoooofofooofo", [ |
| 67 [1, 3], |
| 68 [5, 3], |
| 69 [12, 3] |
| 70 ]); |
57 CheckMatch(new RegExp(r"foobarbaz"), "xx", []); | 71 CheckMatch(new RegExp(r"foobarbaz"), "xx", []); |
58 CheckMatch(new RegExp(r"abc"), "abababa", []); | 72 CheckMatch(new RegExp(r"abc"), "abababa", []); |
59 | 73 |
60 assertEquals("xxxdefxxxdefxxx", "xxxabcxxxabcxxx".replaceAll(new RegExp(r"abc"
), "def")); | 74 assertEquals("xxxdefxxxdefxxx", |
61 assertEquals("o-o-oofo-ofo", "ofooofoooofofooofo".replaceAll(new RegExp(r"foo"
), "-")); | 75 "xxxabcxxxabcxxx".replaceAll(new RegExp(r"abc"), "def")); |
| 76 assertEquals( |
| 77 "o-o-oofo-ofo", "ofooofoooofofooofo".replaceAll(new RegExp(r"foo"), "-")); |
62 assertEquals("deded", "deded".replaceAll(new RegExp(r"x"), "-")); | 78 assertEquals("deded", "deded".replaceAll(new RegExp(r"x"), "-")); |
63 assertEquals("-a-b-c-d-e-f-", "abcdef".replaceAll(new RegExp(""), "-")); | 79 assertEquals("-a-b-c-d-e-f-", "abcdef".replaceAll(new RegExp(""), "-")); |
64 | 80 |
65 CheckMatch(new RegExp(r"a(.)"), "xyzzyabxyzzyacxyzzy", [[5, 2], [12, 2]]); | 81 CheckMatch(new RegExp(r"a(.)"), "xyzzyabxyzzyacxyzzy", [ |
| 82 [5, 2], |
| 83 [12, 2] |
| 84 ]); |
66 | 85 |
67 CheckMatch(new RegExp(r"a|(?:)"), "aba", [[0, 1], [1, 0], [2, 1], [3, 0]]); | 86 CheckMatch(new RegExp(r"a|(?:)"), "aba", [ |
68 CheckMatch(new RegExp(r"a|(?:)"), "baba", [[0, 0], [1, 1], [2, 0], [3, 1], [4,
0]]); | 87 [0, 1], |
69 CheckMatch(new RegExp(r"a|(?:)"), "bab", [[0, 0], [1, 1], [2, 0], [3, 0]]); | 88 [1, 0], |
| 89 [2, 1], |
| 90 [3, 0] |
| 91 ]); |
| 92 CheckMatch(new RegExp(r"a|(?:)"), "baba", [ |
| 93 [0, 0], |
| 94 [1, 1], |
| 95 [2, 0], |
| 96 [3, 1], |
| 97 [4, 0] |
| 98 ]); |
| 99 CheckMatch(new RegExp(r"a|(?:)"), "bab", [ |
| 100 [0, 0], |
| 101 [1, 1], |
| 102 [2, 0], |
| 103 [3, 0] |
| 104 ]); |
70 } | 105 } |
OLD | NEW |