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

Unified Diff: test/mjsunit/es6/pattern-brand-check.js

Issue 1840723002: String.prototype.{match,search} should do only one RegExp brand check (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « src/js/string.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/pattern-brand-check.js
diff --git a/test/mjsunit/es6/pattern-brand-check.js b/test/mjsunit/es6/pattern-brand-check.js
new file mode 100644
index 0000000000000000000000000000000000000000..9b0c0111ef13b906955f47487990b23bd39e6801
--- /dev/null
+++ b/test/mjsunit/es6/pattern-brand-check.js
@@ -0,0 +1,54 @@
+// 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.
+
+// Flags: --harmony-regexp-subclass
+
+function createNonRegExp(calls) {
+ return {
+ get [Symbol.match]() {
+ calls.push("@@match");
+ return undefined;
+ },
+ get [Symbol.replace]() {
+ calls.push("@@replace");
+ return undefined;
+ },
+ get [Symbol.search]() {
+ calls.push("@@search");
+ return undefined;
+ },
+ get [Symbol.split]() {
+ calls.push("@@split");
+ return undefined;
+ },
+ [Symbol.toPrimitive]() {
+ calls.push("@@toPrimitive");
+ return "";
+ }
+ };
+}
+
+(function testStringMatchBrandCheck() {
+ var calls = [];
+ "".match(createNonRegExp(calls));
+ assertEquals(["@@match", "@@toPrimitive"], calls);
+})();
+
+(function testStringSearchBrandCheck() {
+ var calls = [];
+ "".search(createNonRegExp(calls));
+ assertEquals(["@@search", "@@toPrimitive"], calls);
+})();
+
+(function testStringSplitBrandCheck() {
+ var calls = [];
+ "".split(createNonRegExp(calls));
+ assertEquals(["@@split", "@@toPrimitive"], calls);
+})();
+
+(function testStringReplaceBrandCheck() {
+ var calls = [];
+ "".replace(createNonRegExp(calls), "");
+ assertEquals(["@@replace", "@@toPrimitive"], calls);
+})();
« no previous file with comments | « src/js/string.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698