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

Unified Diff: test/mjsunit/harmony/string-contains.js

Issue 227113005: Make `String.prototype.contains` throw when passing a regular expression (Closed) Base URL: git@github.com:v8/v8.git@master
Patch Set: Fix test-mark-compact/BootUpMemoryUse on x64 Created 6 years, 8 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 | « test/cctest/test-mark-compact.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/string-contains.js
diff --git a/test/mjsunit/harmony/string-contains.js b/test/mjsunit/harmony/string-contains.js
index 700a6ed6bc1ab4edcca1a5d1bf0a6d849fb9b96b..b853ed99f783fb5525af0c964317c2d59360caf4 100644
--- a/test/mjsunit/harmony/string-contains.js
+++ b/test/mjsunit/harmony/string-contains.js
@@ -77,8 +77,6 @@ var TEST_INPUT = [{
}, {
msg: "Boolean false", val: false
}, {
- msg: "Regular expression /\d+/", val: /\d+/
-}, {
msg: "Empty array []", val: []
}, {
msg: "Empty object {}", val: {}
@@ -126,7 +124,7 @@ assertTrue("abc".contains("ab", NaN));
assertFalse("abc".contains("cd", NaN));
assertFalse("xyzzy".contains("zy\0", 2));
-var dots = Array(10000).join('.');
+var dots = Array(10000).join(".");
assertFalse(dots.contains("\x01", 10000));
assertFalse(dots.contains("\0", 10000));
@@ -149,3 +147,20 @@ myobj = {
},
contains: String.prototype.contains
};
+
+assertEquals("foo[a-z]+(bar)?".contains("[a-z]+"), true);
+assertThrows("'foo[a-z]+(bar)?'.contains(/[a-z]+/)", TypeError);
+assertThrows("'foo/[a-z]+/(bar)?'.contains(/[a-z]+/)", TypeError);
+assertEquals("foo[a-z]+(bar)?".contains("(bar)?"), true);
+assertThrows("'foo[a-z]+(bar)?'.contains(/(bar)?/)", TypeError);
+assertThrows("'foo[a-z]+/(bar)?/'.contains(/(bar)?/)", TypeError);
+
+assertThrows("String.prototype.contains.call({ 'toString': function() { " +
+ "throw RangeError(); } }, /./)", RangeError);
+assertThrows("String.prototype.contains.call({ 'toString': function() { " +
+ "return 'abc'; } }, /./)", TypeError);
+
+assertThrows("String.prototype.contains.apply({ 'toString': function() { " +
+ "throw RangeError(); } }, [/./])", RangeError);
+assertThrows("String.prototype.contains.apply({ 'toString': function() { " +
+ "return 'abc'; } }, [/./])", TypeError);
« no previous file with comments | « test/cctest/test-mark-compact.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698