summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/this-is-not-object-throws.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/this-is-not-object-throws.js')
-rw-r--r--js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/this-is-not-object-throws.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/this-is-not-object-throws.js b/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/this-is-not-object-throws.js
new file mode 100644
index 0000000000..3d587339c9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/this-is-not-object-throws.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: pending
+description: Throws TypeError when `this` is not an Object
+info: |
+ %RegExpStringIteratorPrototype%.next ( )
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+features: [Symbol.matchAll]
+---*/
+
+var RegExpStringIteratorProto = Object.getPrototypeOf(/./[Symbol.matchAll](''));
+
+var thisValue;
+var callNext = function() {
+ RegExpStringIteratorProto.next.call(thisValue);
+};
+
+thisValue = null;
+assert.throws(TypeError, callNext, 'this value is null');
+
+thisValue = true;
+assert.throws(TypeError, callNext, 'this value is Boolean');
+
+thisValue = '';
+assert.throws(TypeError, callNext, 'this value is String');
+
+thisValue = Symbol();
+assert.throws(TypeError, callNext, 'this value is Symbol');
+
+thisValue = 1;
+assert.throws(TypeError, callNext, 'this value is Number');
+
+
+reportCompare(0, 0);