blob: 419cade8cd9c27266cd68120e7f00512713993da [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(""));
Emily Bernierd0a1eb72015-03-24 16:35:39 -040020
21// Read-only property.
22var r = /\/\//;
23testEscapes("\\/\\/", r);
24r.source = "garbage";
25testEscapes("\\/\\/", r);