OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Escape '/'. | 5 // Escape '/'. |
6 function testEscapes(expected, regexp) { | 6 function testEscapes(expected, regexp) { |
7 assertEquals(expected, regexp.source); | 7 assertEquals(expected, regexp.source); |
8 assertEquals("/" + expected + "/", regexp.toString()); | 8 assertEquals("/" + expected + "/", regexp.toString()); |
9 } | 9 } |
10 | 10 |
11 testEscapes("\\/", /\//); | 11 testEscapes("\\/", /\//); |
12 testEscapes("\\/\\/", /\/\//); | 12 testEscapes("\\/\\/", /\/\//); |
13 testEscapes("\\/", new RegExp("/")); | 13 testEscapes("\\/", new RegExp("/")); |
14 testEscapes("\\/", new RegExp("\\/")); | 14 testEscapes("\\/", new RegExp("\\/")); |
15 testEscapes("\\\\/", new RegExp("\\\\/")); | 15 testEscapes("\\\\\\/", new RegExp("\\\\/")); |
16 testEscapes("\\/\\/", new RegExp("\\/\\/")); | 16 testEscapes("\\/\\/", new RegExp("\\/\\/")); |
17 testEscapes("\\/\\/\\/\\/", new RegExp("////")); | 17 testEscapes("\\/\\/\\/\\/", new RegExp("////")); |
18 testEscapes("\\/\\/\\/\\/", new RegExp("\\//\\//")); | 18 testEscapes("\\/\\/\\/\\/", new RegExp("\\//\\//")); |
19 testEscapes("(?:)", new RegExp("")); | 19 testEscapes("(?:)", new RegExp("")); |
20 | 20 |
21 // Read-only property. | 21 // Read-only property. |
22 var r = /\/\//; | 22 var r = /\/\//; |
23 testEscapes("\\/\\/", r); | 23 testEscapes("\\/\\/", r); |
24 r.source = "garbage"; | 24 r.source = "garbage"; |
25 testEscapes("\\/\\/", r); | 25 testEscapes("\\/\\/", r); |
OLD | NEW |