blob: 1a0ed64412e628f4eaae7bc0dc773f47ac79d11b [file] [log] [blame]
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001// 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
3// found in the LICENSE file.
4
5// Escape '/'.
6function testEscapes(expected, regexp) {
7 assertEquals(expected, regexp.source);
8 assertEquals("/" + expected + "/", regexp.toString());
9}
10
11testEscapes("\\/", /\//);
12testEscapes("\\/\\/", /\/\//);
13testEscapes("\\/", new RegExp("/"));
14testEscapes("\\/", new RegExp("\\/"));
15testEscapes("\\\\/", new RegExp("\\\\/"));
16testEscapes("\\/\\/", new RegExp("\\/\\/"));
17testEscapes("\\/\\/\\/\\/", new RegExp("////"));
18testEscapes("\\/\\/\\/\\/", new RegExp("\\//\\//"));
19testEscapes("(?:)", new RegExp(""));
20testEscapes("(?:)", RegExp.prototype);
21
22// Read-only property.
23var r = /\/\//;
24testEscapes("\\/\\/", r);
25r.source = "garbage";
26testEscapes("\\/\\/", r);