Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: test/mjsunit/es6/regexp-tostring.js

Issue 1679123007: [regexp] implement RegExp.prototype.toString for non-RegExp receiver. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/js/regexp.js ('K') | « src/js/regexp.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/regexp-tostring.js
diff --git a/test/mjsunit/es6/regexp-tostring.js b/test/mjsunit/es6/regexp-tostring.js
new file mode 100644
index 0000000000000000000000000000000000000000..d2e39eaab21ace4176f0f23e8450ae1284547ff6
--- /dev/null
+++ b/test/mjsunit/es6/regexp-tostring.js
@@ -0,0 +1,30 @@
+// 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.
+
+var log = [];
+
+var fake = {
+ pattern: function() {
+ log.push("p");
+ return {
+ toString: function() {
+ log.push("ps");
+ return "pattern";
+ }
+ };
+ },
+ flags: function() {
+ log.push("f");
+ return {
+ toString: function() {
+ log.push("fs");
+ return "flags";
+ }
+ };
+ }
+}
+
+assertThrows(() => RegExp.prototype.toString.call(1));
+assertEquals("/pattern/flags", RegExp.prototype.toString.call(fake));
+assertEquals(["p", "ps", "f", "fs"], log);
« src/js/regexp.js ('K') | « src/js/regexp.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698