summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/RegExp/RegExpExec-return.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--js/src/tests/non262/RegExp/RegExpExec-return.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/js/src/tests/non262/RegExp/RegExpExec-return.js b/js/src/tests/non262/RegExp/RegExpExec-return.js
new file mode 100644
index 0000000000..1148aac07f
--- /dev/null
+++ b/js/src/tests/non262/RegExp/RegExpExec-return.js
@@ -0,0 +1,31 @@
+var BUGNUMBER = 887016;
+var summary = "RegExpExec should throw if returned value is not an object nor null.";
+
+print(BUGNUMBER + ": " + summary);
+
+for (var ret of [null, {}, [], /a/]) {
+ assertEq(RegExp.prototype[Symbol.match].call({
+ get global() {
+ return false;
+ },
+ exec(S) {
+ return ret;
+ }
+ }, "foo"), ret);
+}
+
+for (ret of [undefined, 1, true, false, Symbol.iterator]) {
+ assertThrowsInstanceOf(() => {
+ RegExp.prototype[Symbol.match].call({
+ get global() {
+ return false;
+ },
+ exec(S) {
+ return ret;
+ }
+ }, "foo");
+ }, TypeError);
+}
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);