summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/GeneratorPrototype/return/this-val-not-object.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/GeneratorPrototype/return/this-val-not-object.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/GeneratorPrototype/return/this-val-not-object.js')
-rw-r--r--js/src/tests/test262/built-ins/GeneratorPrototype/return/this-val-not-object.js116
1 files changed, 116 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/GeneratorPrototype/return/this-val-not-object.js b/js/src/tests/test262/built-ins/GeneratorPrototype/return/this-val-not-object.js
new file mode 100644
index 0000000000..707d11e5e6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/GeneratorPrototype/return/this-val-not-object.js
@@ -0,0 +1,116 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-generator.prototype.return
+description: >
+ A TypeError should be thrown from GeneratorValidate (25.3.3.2) if the "this"
+ value of `return` is not an object.
+info: |
+ [...]
+ 3. Return ? GeneratorResumeAbrupt(g, C).
+
+ 25.3.3.4 GeneratorResumeAbrupt
+
+ 1. Let state be ? GeneratorValidate(generator).
+
+ 25.3.3.2 GeneratorValidate
+
+ 1. If Type(generator) is not Object, throw a TypeError exception.
+features: [generators, Symbol]
+---*/
+
+function* g() {}
+var GeneratorPrototype = Object.getPrototypeOf(g).prototype;
+var symbol = Symbol();
+
+assert.throws(
+ TypeError,
+ function() {
+ GeneratorPrototype.return.call(undefined);
+ },
+ 'undefined (without value)'
+);
+assert.throws(
+ TypeError,
+ function() {
+ GeneratorPrototype.return.call(undefined, 1);
+ },
+ 'undefined (with value)'
+);
+
+assert.throws(
+ TypeError,
+ function() {
+ GeneratorPrototype.return.call(null);
+ },
+ 'null (without value)'
+);
+assert.throws(
+ TypeError,
+ function() {
+ GeneratorPrototype.return.call(null, 1);
+ },
+ 'null (with value)'
+);
+
+assert.throws(
+ TypeError,
+ function() {
+ GeneratorPrototype.return.call(true);
+ },
+ 'boolean (without value)'
+);
+assert.throws(
+ TypeError,
+ function() {
+ GeneratorPrototype.return.call(true, 1);
+ },
+ 'boolean (with value)'
+);
+
+assert.throws(
+ TypeError,
+ function() {
+ GeneratorPrototype.return.call('s');
+ },
+ 'string (without value)'
+);
+assert.throws(
+ TypeError,
+ function() {
+ GeneratorPrototype.return.call('s', 1);
+ },
+ 'string (with value)'
+);
+
+assert.throws(
+ TypeError,
+ function() {
+ GeneratorPrototype.return.call(1);
+ },
+ 'number (without value)'
+);
+assert.throws(
+ TypeError,
+ function() {
+ GeneratorPrototype.return.call(1, 1);
+ },
+ 'number (with value)'
+);
+
+assert.throws(
+ TypeError,
+ function() {
+ GeneratorPrototype.return.call(symbol);
+ },
+ 'symbol (without value)'
+);
+assert.throws(
+ TypeError,
+ function() {
+ GeneratorPrototype.return.call(symbol, 1);
+ },
+ 'symbol (with value)'
+);
+
+reportCompare(0, 0);