Index: test/mjsunit/es6/regexp-tostring.js |
diff --git a/test/mjsunit/es6/regexp-tostring.js b/test/mjsunit/es6/regexp-tostring.js |
index 3deeeb7ed8894d440d3fabd1172da5203d829c39..23e137c7aa5e0930276f58de43f1521b9f68d9b0 100644 |
--- a/test/mjsunit/es6/regexp-tostring.js |
+++ b/test/mjsunit/es6/regexp-tostring.js |
@@ -44,3 +44,14 @@ testThrows(1); |
assertEquals("/pattern/flags", RegExp.prototype.toString.call(fake)); |
assertEquals(["p", "ps", "f", "fs"], log); |
+ |
+// Monkey-patching is also possible on RegExp instances |
+ |
+let weird = /foo/; |
+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); |