Home | History | Annotate | Download | only in es6
      1 // Copyright 2015 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 var pattern = {
      6   [Symbol.replace]: (string, newValue) => string + newValue
      7 };
      8 // Check object coercible fails.
      9 assertThrows(() => String.prototype.replace.call(null, pattern, "x"),
     10              TypeError);
     11 // Override is called.
     12 assertEquals("abcdex", "abcde".replace(pattern, "x"));
     13 // Non-callable override.
     14 pattern[Symbol.replace] = "dumdidum";
     15 assertThrows(() => "abcde".replace(pattern, "x"), TypeError);
     16 
     17 assertEquals("[Symbol.replace]", RegExp.prototype[Symbol.replace].name);
     18