OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 assertEquals("t", "123456789t".replace(re, "$10"), "$10"); | 237 assertEquals("t", "123456789t".replace(re, "$10"), "$10"); |
238 assertEquals("15", "123456789t".replace(re, "$15"), "$10"); | 238 assertEquals("15", "123456789t".replace(re, "$15"), "$10"); |
239 assertEquals("1", "123456789t".replace(re, "$01"), "$01"); | 239 assertEquals("1", "123456789t".replace(re, "$01"), "$01"); |
240 assertEquals("$001", "123456789t".replace(re, "$001"), "$001"); | 240 assertEquals("$001", "123456789t".replace(re, "$001"), "$001"); |
241 re = new RegExp("foo(.)"); | 241 re = new RegExp("foo(.)"); |
242 assertEquals("bar$0", "foox".replace(re, "bar$0"), "$0"); | 242 assertEquals("bar$0", "foox".replace(re, "bar$0"), "$0"); |
243 assertEquals("bar$00", "foox".replace(re, "bar$00"), "$00"); | 243 assertEquals("bar$00", "foox".replace(re, "bar$00"), "$00"); |
244 assertEquals("bar$000", "foox".replace(re, "bar$000"), "$000"); | 244 assertEquals("bar$000", "foox".replace(re, "bar$000"), "$000"); |
245 assertEquals("barx", "foox".replace(re, "bar$01"), "$01 2"); | 245 assertEquals("barx", "foox".replace(re, "bar$01"), "$01 2"); |
246 assertEquals("barx5", "foox".replace(re, "bar$15"), "$15"); | 246 assertEquals("barx5", "foox".replace(re, "bar$15"), "$15"); |
| 247 |
| 248 assertFalse(/()foo$\1/.test("football"), "football1"); |
| 249 assertFalse(/foo$(?=ball)/.test("football"), "football2"); |
| 250 assertFalse(/foo$(?!bar)/.test("football"), "football3"); |
| 251 assertTrue(/()foo$\1/.test("foo"), "football4"); |
| 252 assertTrue(/foo$(?=(ball)?)/.test("foo"), "football5"); |
| 253 assertTrue(/()foo$(?!bar)/.test("foo"), "football6"); |
| 254 assertFalse(/(x?)foo$\1/.test("football"), "football7"); |
| 255 assertFalse(/foo$(?=ball)/.test("football"), "football8"); |
| 256 assertFalse(/foo$(?!bar)/.test("football"), "football9"); |
| 257 assertTrue(/(x?)foo$\1/.test("foo"), "football10"); |
| 258 assertTrue(/foo$(?=(ball)?)/.test("foo"), "football11"); |
| 259 assertTrue(/foo$(?!bar)/.test("foo"), "football12"); |
| 260 |
| 261 // Check that the back reference has two successors. See |
| 262 // BackReferenceNode::PropagateForward. |
| 263 assertFalse(/f(o)\b\1/.test('foo')); |
| 264 assertTrue(/f(o)\B\1/.test('foo')); |
| 265 |
| 266 assertFalse(/f(o)$\1/.test('foo'), "backref detects at_end"); |
OLD | NEW |