Home | History | Annotate | Download | only in regress
      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
      3 // found in the LICENSE file.
      4 
      5 // Escape '/'.
      6 function testEscapes(expected, regexp) {
      7   assertEquals(expected, regexp.source);
      8   assertEquals("/" + expected + "/", regexp.toString());
      9 }
     10 
     11 testEscapes("\\/", /\//);
     12 testEscapes("\\/\\/", /\/\//);
     13 testEscapes("\\/", new RegExp("/"));
     14 testEscapes("\\/", new RegExp("\\/"));
     15 testEscapes("\\\\/", new RegExp("\\\\/"));
     16 testEscapes("\\/\\/", new RegExp("\\/\\/"));
     17 testEscapes("\\/\\/\\/\\/", new RegExp("////"));
     18 testEscapes("\\/\\/\\/\\/", new RegExp("\\//\\//"));
     19 testEscapes("(?:)", new RegExp(""));
     20 
     21 // Read-only property.
     22 var r = /\/\//;
     23 testEscapes("\\/\\/", r);
     24 r.source = "garbage";
     25 testEscapes("\\/\\/", r);
     26