summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Set/prototype/difference/receiver-not-set.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Set/prototype/difference/receiver-not-set.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Set/prototype/difference/receiver-not-set.js')
-rw-r--r--js/src/tests/test262/built-ins/Set/prototype/difference/receiver-not-set.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Set/prototype/difference/receiver-not-set.js b/js/src/tests/test262/built-ins/Set/prototype/difference/receiver-not-set.js
new file mode 100644
index 0000000000..83e66706af
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Set/prototype/difference/receiver-not-set.js
@@ -0,0 +1,47 @@
+// |reftest| skip -- set-methods is not supported
+// Copyright (C) 2023 Anthony Frehner and Kevin Gibbons. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-set.prototype.difference
+description: Set.prototype.difference throws when receiver is not a Set
+features: [set-methods]
+---*/
+
+class MySetLike {
+ constructor() {
+ this.size = 2;
+ this.has = () => {};
+ this.keys = function* keys() {
+ yield 2;
+ yield 3;
+ };
+ }
+}
+
+const s1 = new MySetLike();
+const s2 = new Set();
+assert.throws(
+ TypeError,
+ () => {
+ Set.prototype.difference.call(s1, s2);
+ },
+ "Set-like class"
+);
+
+const s3 = {
+ size: 2,
+ has: () => {},
+ keys: function* keys() {
+ yield 2;
+ yield 3;
+ },
+};
+assert.throws(
+ TypeError,
+ () => {
+ Set.prototype.difference.call(s3, s2);
+ },
+ "Set-like object"
+);
+
+reportCompare(0, 0);