| // Copyright 2016 the V8 project authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| RegExp.prototype.toString.call(x); |
| assertTrue(/incompatible receiver/.test(e.message)); |
| Number.prototype.source = "a"; |
| Number.prototype.flags = "b"; |
| assertEquals("/pattern/flags", RegExp.prototype.toString.call(fake)); |
| assertEquals(["p", "ps", "f", "fs"], log); |
| // Monkey-patching is also possible on RegExp instances |
| Object.defineProperty(weird, 'flags', {value: 'bar'}); |
| Object.defineProperty(weird, 'source', {value: 'baz'}); |
| assertEquals('/baz/bar', weird.toString()); |
| assertEquals('/(?:)/', RegExp.prototype.toString()); |
| assertEquals('(?:)', RegExp.prototype.source); |
| assertEquals('', RegExp.prototype.flags); |