From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../built-ins/Set/Symbol.species/browser.js | 0 .../test262/built-ins/Set/Symbol.species/length.js | 34 ++ .../built-ins/Set/Symbol.species/return-value.js | 16 + .../test262/built-ins/Set/Symbol.species/shell.js | 0 .../Set/Symbol.species/symbol-species-name.js | 22 ++ .../built-ins/Set/Symbol.species/symbol-species.js | 23 ++ .../built-ins/Set/bigint-number-same-value.js | 46 +++ js/src/tests/test262/built-ins/Set/browser.js | 0 js/src/tests/test262/built-ins/Set/constructor.js | 12 + .../test262/built-ins/Set/is-a-constructor.js | 26 ++ js/src/tests/test262/built-ins/Set/length.js | 19 + js/src/tests/test262/built-ins/Set/name.js | 19 + .../Set/properties-of-the-set-prototype-object.js | 19 + .../test262/built-ins/Set/proto-from-ctor-realm.js | 31 ++ .../test262/built-ins/Set/prototype-of-set.js | 16 + .../built-ins/Set/prototype/Symbol.iterator.js | 22 ++ .../Set/prototype/Symbol.iterator/browser.js | 0 .../prototype/Symbol.iterator/not-a-constructor.js | 35 ++ .../Set/prototype/Symbol.iterator/shell.js | 0 .../built-ins/Set/prototype/Symbol.toStringTag.js | 23 ++ .../Set/prototype/Symbol.toStringTag/browser.js | 0 .../Symbol.toStringTag/property-descriptor.js | 25 ++ .../Set/prototype/Symbol.toStringTag/shell.js | 0 .../test262/built-ins/Set/prototype/add/add.js | 23 ++ .../test262/built-ins/Set/prototype/add/browser.js | 0 .../does-not-have-setdata-internal-slot-array.js | 23 ++ .../add/does-not-have-setdata-internal-slot-map.js | 23 ++ .../does-not-have-setdata-internal-slot-object.js | 23 ++ ...not-have-setdata-internal-slot-set-prototype.js | 23 ++ .../does-not-have-setdata-internal-slot-weakset.js | 23 ++ .../test262/built-ins/Set/prototype/add/length.js | 19 + .../test262/built-ins/Set/prototype/add/name.js | 19 + .../Set/prototype/add/not-a-constructor.js | 31 ++ .../Set/prototype/add/preserves-insertion-order.js | 24 ++ .../add/returns-this-when-ignoring-duplicate.js | 21 ++ .../built-ins/Set/prototype/add/returns-this.js | 18 + .../test262/built-ins/Set/prototype/add/shell.js | 0 .../prototype/add/this-not-object-throw-boolean.js | 22 ++ .../prototype/add/this-not-object-throw-null.js | 22 ++ .../prototype/add/this-not-object-throw-number.js | 22 ++ .../prototype/add/this-not-object-throw-string.js | 22 ++ .../prototype/add/this-not-object-throw-symbol.js | 23 ++ .../add/this-not-object-throw-undefined.js | 22 ++ ...ill-not-add-duplicate-entry-initial-iterable.js | 27 ++ ...will-not-add-duplicate-entry-normalizes-zero.js | 31 ++ .../prototype/add/will-not-add-duplicate-entry.js | 28 ++ .../test262/built-ins/Set/prototype/browser.js | 0 .../built-ins/Set/prototype/clear/browser.js | 0 .../test262/built-ins/Set/prototype/clear/clear.js | 23 ++ .../clear/clears-all-contents-from-iterable.js | 28 ++ .../Set/prototype/clear/clears-all-contents.js | 30 ++ .../Set/prototype/clear/clears-an-empty-set.js | 23 ++ .../does-not-have-setdata-internal-slot-array.js | 23 ++ .../does-not-have-setdata-internal-slot-map.js | 23 ++ .../does-not-have-setdata-internal-slot-object.js | 23 ++ ...not-have-setdata-internal-slot-set.prototype.js | 23 ++ .../does-not-have-setdata-internal-slot-weakset.js | 23 ++ .../built-ins/Set/prototype/clear/length.js | 19 + .../test262/built-ins/Set/prototype/clear/name.js | 19 + .../Set/prototype/clear/not-a-constructor.js | 31 ++ .../Set/prototype/clear/returns-undefined.js | 17 + .../test262/built-ins/Set/prototype/clear/shell.js | 0 .../clear/this-not-object-throw-boolean.js | 22 ++ .../prototype/clear/this-not-object-throw-null.js | 22 ++ .../clear/this-not-object-throw-number.js | 22 ++ .../clear/this-not-object-throw-string.js | 22 ++ .../clear/this-not-object-throw-symbol.js | 23 ++ .../clear/this-not-object-throw-undefined.js | 22 ++ .../built-ins/Set/prototype/constructor/browser.js | 0 .../set-prototype-constructor-intrinsic.js | 18 + .../constructor/set-prototype-constructor.js | 17 + .../built-ins/Set/prototype/constructor/shell.js | 0 .../built-ins/Set/prototype/delete/browser.js | 0 .../delete/delete-entry-initial-iterable.js | 28 ++ .../delete/delete-entry-normalizes-zero.js | 27 ++ .../built-ins/Set/prototype/delete/delete-entry.js | 32 ++ .../built-ins/Set/prototype/delete/delete.js | 23 ++ .../does-not-have-setdata-internal-slot-array.js | 23 ++ .../does-not-have-setdata-internal-slot-map.js | 23 ++ .../does-not-have-setdata-internal-slot-object.js | 23 ++ ...not-have-setdata-internal-slot-set-prototype.js | 23 ++ .../does-not-have-setdata-internal-slot-weakset.js | 23 ++ .../built-ins/Set/prototype/delete/length.js | 19 + .../test262/built-ins/Set/prototype/delete/name.js | 19 + .../Set/prototype/delete/not-a-constructor.js | 31 ++ .../delete/returns-false-when-delete-is-noop.js | 17 + .../returns-true-when-delete-operation-occurs.js | 24 ++ .../built-ins/Set/prototype/delete/shell.js | 0 .../delete/this-not-object-throw-boolean.js | 22 ++ .../prototype/delete/this-not-object-throw-null.js | 22 ++ .../delete/this-not-object-throw-number.js | 22 ++ .../delete/this-not-object-throw-string.js | 22 ++ .../delete/this-not-object-throw-symbol.js | 23 ++ .../delete/this-not-object-throw-undefined.js | 22 ++ .../built-ins/Set/prototype/entries/browser.js | 0 .../does-not-have-setdata-internal-slot-array.js | 29 ++ .../does-not-have-setdata-internal-slot-map.js | 28 ++ .../does-not-have-setdata-internal-slot-object.js | 28 ++ ...not-have-setdata-internal-slot-set-prototype.js | 28 ++ .../does-not-have-setdata-internal-slot-weakset.js | 29 ++ .../built-ins/Set/prototype/entries/entries.js | 23 ++ .../built-ins/Set/prototype/entries/length.js | 19 + .../built-ins/Set/prototype/entries/name.js | 19 + .../Set/prototype/entries/not-a-constructor.js | 35 ++ .../prototype/entries/returns-iterator-empty.js | 27 ++ .../Set/prototype/entries/returns-iterator.js | 58 +++ .../built-ins/Set/prototype/entries/shell.js | 0 .../entries/this-not-object-throw-boolean.js | 28 ++ .../entries/this-not-object-throw-null.js | 27 ++ .../entries/this-not-object-throw-number.js | 27 ++ .../entries/this-not-object-throw-string.js | 27 ++ .../entries/this-not-object-throw-symbol.js | 28 ++ .../entries/this-not-object-throw-undefined.js | 27 ++ .../built-ins/Set/prototype/forEach/browser.js | 0 .../forEach/callback-not-callable-boolean.js | 22 ++ .../forEach/callback-not-callable-null.js | 22 ++ .../forEach/callback-not-callable-number.js | 22 ++ .../forEach/callback-not-callable-string.js | 22 ++ .../forEach/callback-not-callable-symbol.js | 23 ++ .../forEach/callback-not-callable-undefined.js | 22 ++ .../does-not-have-setdata-internal-slot-array.js | 23 ++ .../does-not-have-setdata-internal-slot-map.js | 23 ++ .../does-not-have-setdata-internal-slot-object.js | 23 ++ ...not-have-setdata-internal-slot-set-prototype.js | 23 ++ .../does-not-have-setdata-internal-slot-weakset.js | 23 ++ .../built-ins/Set/prototype/forEach/forEach.js | 23 ++ .../forEach/iterates-in-insertion-order.js | 31 ++ .../forEach/iterates-in-iterable-entry-order.js | 29 ++ .../iterates-values-added-after-foreach-begins.js | 44 +++ .../iterates-values-deleted-then-readded.js | 47 +++ .../forEach/iterates-values-not-deleted.js | 36 ++ ...iterates-values-revisits-after-delete-re-add.js | 47 +++ .../built-ins/Set/prototype/forEach/length.js | 19 + .../built-ins/Set/prototype/forEach/name.js | 19 + .../Set/prototype/forEach/not-a-constructor.js | 35 ++ .../Set/prototype/forEach/returns-undefined.js | 21 ++ .../built-ins/Set/prototype/forEach/shell.js | 0 ...-explicit-cannot-override-lexical-this-arrow.js | 28 ++ .../Set/prototype/forEach/this-arg-explicit.js | 24 ++ .../Set/prototype/forEach/this-non-strict.js | 26 ++ .../forEach/this-not-object-throw-boolean.js | 22 ++ .../forEach/this-not-object-throw-null.js | 22 ++ .../forEach/this-not-object-throw-number.js | 22 ++ .../forEach/this-not-object-throw-string.js | 22 ++ .../forEach/this-not-object-throw-symbol.js | 23 ++ .../forEach/this-not-object-throw-undefined.js | 22 ++ .../Set/prototype/forEach/this-strict-strict.js | 26 ++ .../forEach/throws-when-callback-throws.js | 28 ++ .../test262/built-ins/Set/prototype/has/browser.js | 0 .../does-not-have-setdata-internal-slot-array.js | 23 ++ .../has/does-not-have-setdata-internal-slot-map.js | 23 ++ .../does-not-have-setdata-internal-slot-object.js | 23 ++ ...not-have-setdata-internal-slot-set-prototype.js | 23 ++ .../does-not-have-setdata-internal-slot-weakset.js | 23 ++ .../test262/built-ins/Set/prototype/has/has.js | 23 ++ .../test262/built-ins/Set/prototype/has/length.js | 19 + .../test262/built-ins/Set/prototype/has/name.js | 19 + .../Set/prototype/has/not-a-constructor.js | 31 ++ ...ndefined-added-deleted-not-present-undefined.js | 23 ++ ...returns-false-when-value-not-present-boolean.js | 17 + .../returns-false-when-value-not-present-nan.js | 17 + .../returns-false-when-value-not-present-null.js | 17 + .../returns-false-when-value-not-present-number.js | 17 + .../returns-false-when-value-not-present-string.js | 17 + .../returns-false-when-value-not-present-symbol.js | 18 + ...turns-false-when-value-not-present-undefined.js | 17 + .../has/returns-true-when-value-present-boolean.js | 21 ++ .../has/returns-true-when-value-present-nan.js | 21 ++ .../has/returns-true-when-value-present-null.js | 21 ++ .../has/returns-true-when-value-present-number.js | 21 ++ .../has/returns-true-when-value-present-string.js | 21 ++ .../has/returns-true-when-value-present-symbol.js | 23 ++ .../returns-true-when-value-present-undefined.js | 21 ++ .../test262/built-ins/Set/prototype/has/shell.js | 0 .../prototype/has/this-not-object-throw-boolean.js | 22 ++ .../prototype/has/this-not-object-throw-null.js | 22 ++ .../prototype/has/this-not-object-throw-number.js | 22 ++ .../prototype/has/this-not-object-throw-string.js | 22 ++ .../prototype/has/this-not-object-throw-symbol.js | 23 ++ .../has/this-not-object-throw-undefined.js | 22 ++ .../built-ins/Set/prototype/keys/browser.js | 0 .../test262/built-ins/Set/prototype/keys/keys.js | 17 + .../test262/built-ins/Set/prototype/keys/shell.js | 0 .../tests/test262/built-ins/Set/prototype/shell.js | 0 .../built-ins/Set/prototype/size/browser.js | 0 .../test262/built-ins/Set/prototype/size/length.js | 22 ++ .../test262/built-ins/Set/prototype/size/name.js | 25 ++ ...nt-of-present-values-before-after-add-delete.js | 27 ++ ...returns-count-of-present-values-by-insertion.js | 27 ++ .../returns-count-of-present-values-by-iterable.js | 19 + .../test262/built-ins/Set/prototype/size/shell.js | 0 .../test262/built-ins/Set/prototype/size/size.js | 29 ++ .../built-ins/Set/prototype/values/browser.js | 0 .../does-not-have-setdata-internal-slot-array.js | 29 ++ .../does-not-have-setdata-internal-slot-map.js | 28 ++ .../does-not-have-setdata-internal-slot-object.js | 28 ++ ...not-have-setdata-internal-slot-set-prototype.js | 28 ++ .../does-not-have-setdata-internal-slot-weakset.js | 29 ++ .../built-ins/Set/prototype/values/length.js | 19 + .../test262/built-ins/Set/prototype/values/name.js | 19 + .../Set/prototype/values/not-a-constructor.js | 31 ++ .../Set/prototype/values/returns-iterator-empty.js | 16 + .../Set/prototype/values/returns-iterator.js | 43 +++ .../built-ins/Set/prototype/values/shell.js | 0 .../values/this-not-object-throw-boolean.js | 28 ++ .../prototype/values/this-not-object-throw-null.js | 27 ++ .../values/this-not-object-throw-number.js | 27 ++ .../values/this-not-object-throw-string.js | 27 ++ .../values/this-not-object-throw-symbol.js | 28 ++ .../values/this-not-object-throw-undefined.js | 27 ++ .../prototype/values/values-iteration-mutable.js | 48 +++ .../built-ins/Set/prototype/values/values.js | 23 ++ .../set-does-not-throw-when-add-is-not-callable.js | 35 ++ .../built-ins/Set/set-get-add-method-failure.js | 30 ++ .../built-ins/Set/set-iterable-calls-add.js | 41 +++ .../Set/set-iterable-empty-does-not-call-add.js | 41 +++ ...set-iterable-throws-when-add-is-not-callable.js | 36 ++ js/src/tests/test262/built-ins/Set/set-iterable.js | 33 ++ .../Set/set-iterator-close-after-add-failure.js | 50 +++ .../built-ins/Set/set-iterator-next-failure.js | 32 ++ .../built-ins/Set/set-iterator-value-failure.js | 39 +++ .../tests/test262/built-ins/Set/set-newtarget.js | 32 ++ .../tests/test262/built-ins/Set/set-no-iterable.js | 23 ++ .../built-ins/Set/set-undefined-newtarget.js | 23 ++ js/src/tests/test262/built-ins/Set/set.js | 17 + js/src/tests/test262/built-ins/Set/shell.js | 24 ++ js/src/tests/test262/built-ins/Set/valid-values.js | 390 +++++++++++++++++++++ 227 files changed, 5318 insertions(+) create mode 100644 js/src/tests/test262/built-ins/Set/Symbol.species/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/Symbol.species/length.js create mode 100644 js/src/tests/test262/built-ins/Set/Symbol.species/return-value.js create mode 100644 js/src/tests/test262/built-ins/Set/Symbol.species/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/Symbol.species/symbol-species-name.js create mode 100644 js/src/tests/test262/built-ins/Set/Symbol.species/symbol-species.js create mode 100644 js/src/tests/test262/built-ins/Set/bigint-number-same-value.js create mode 100644 js/src/tests/test262/built-ins/Set/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/constructor.js create mode 100644 js/src/tests/test262/built-ins/Set/is-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Set/length.js create mode 100644 js/src/tests/test262/built-ins/Set/name.js create mode 100644 js/src/tests/test262/built-ins/Set/properties-of-the-set-prototype-object.js create mode 100644 js/src/tests/test262/built-ins/Set/proto-from-ctor-realm.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype-of-set.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/property-descriptor.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/add.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-array.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-map.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-object.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-set-prototype.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-weakset.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/length.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/name.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/preserves-insertion-order.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/returns-this-when-ignoring-duplicate.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/returns-this.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-boolean.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-null.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-number.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-string.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-symbol.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-undefined.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry-initial-iterable.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry-normalizes-zero.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/clear.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents-from-iterable.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/clears-an-empty-set.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/length.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/name.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/returns-undefined.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-boolean.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-null.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-number.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-string.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-symbol.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-undefined.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/constructor/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/constructor/set-prototype-constructor-intrinsic.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/constructor/set-prototype-constructor.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/constructor/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry-initial-iterable.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry-normalizes-zero.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/delete.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-array.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-map.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-object.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-set-prototype.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-weakset.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/length.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/name.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/returns-false-when-delete-is-noop.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/returns-true-when-delete-operation-occurs.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-boolean.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-null.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-number.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-string.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-symbol.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-undefined.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-array.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-map.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-object.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-set-prototype.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-weakset.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/entries.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/length.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/name.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/returns-iterator-empty.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/returns-iterator.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-boolean.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-null.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-number.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-string.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-symbol.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-undefined.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-boolean.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-null.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-number.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-string.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-symbol.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-undefined.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-array.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-map.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-object.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-set-prototype.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-weakset.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/forEach.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-in-insertion-order.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-in-iterable-entry-order.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-deleted-then-readded.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-not-deleted.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-revisits-after-delete-re-add.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/length.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/name.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/returns-undefined.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/this-arg-explicit-cannot-override-lexical-this-arrow.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/this-arg-explicit.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/this-non-strict.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-boolean.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-null.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-number.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-string.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-symbol.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-undefined.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/this-strict-strict.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/forEach/throws-when-callback-throws.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-array.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-map.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-object.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-set-prototype.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-weakset.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/has.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/length.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/name.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-undefined-added-deleted-not-present-undefined.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-boolean.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-nan.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-null.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-number.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-string.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-symbol.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-undefined.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-boolean.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-nan.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-null.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-number.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-string.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-symbol.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-undefined.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-boolean.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-null.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-number.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-string.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-symbol.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-undefined.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/keys/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/keys/keys.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/keys/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/size/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/size/length.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/size/name.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-before-after-add-delete.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-by-insertion.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-by-iterable.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/size/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/size/size.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/browser.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-array.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-map.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-object.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-set-prototype.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-weakset.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/length.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/name.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/returns-iterator-empty.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/returns-iterator.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-boolean.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-null.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-number.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-string.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-symbol.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-undefined.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/values-iteration-mutable.js create mode 100644 js/src/tests/test262/built-ins/Set/prototype/values/values.js create mode 100644 js/src/tests/test262/built-ins/Set/set-does-not-throw-when-add-is-not-callable.js create mode 100644 js/src/tests/test262/built-ins/Set/set-get-add-method-failure.js create mode 100644 js/src/tests/test262/built-ins/Set/set-iterable-calls-add.js create mode 100644 js/src/tests/test262/built-ins/Set/set-iterable-empty-does-not-call-add.js create mode 100644 js/src/tests/test262/built-ins/Set/set-iterable-throws-when-add-is-not-callable.js create mode 100644 js/src/tests/test262/built-ins/Set/set-iterable.js create mode 100644 js/src/tests/test262/built-ins/Set/set-iterator-close-after-add-failure.js create mode 100644 js/src/tests/test262/built-ins/Set/set-iterator-next-failure.js create mode 100644 js/src/tests/test262/built-ins/Set/set-iterator-value-failure.js create mode 100644 js/src/tests/test262/built-ins/Set/set-newtarget.js create mode 100644 js/src/tests/test262/built-ins/Set/set-no-iterable.js create mode 100644 js/src/tests/test262/built-ins/Set/set-undefined-newtarget.js create mode 100644 js/src/tests/test262/built-ins/Set/set.js create mode 100644 js/src/tests/test262/built-ins/Set/shell.js create mode 100644 js/src/tests/test262/built-ins/Set/valid-values.js (limited to 'js/src/tests/test262/built-ins/Set') diff --git a/js/src/tests/test262/built-ins/Set/Symbol.species/browser.js b/js/src/tests/test262/built-ins/Set/Symbol.species/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/Symbol.species/length.js b/js/src/tests/test262/built-ins/Set/Symbol.species/length.js new file mode 100644 index 0000000000..a4fc6ac666 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/Symbol.species/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-set-@@species +description: > + get Set [ @@species ].length is 0. +info: | + get Set [ @@species ] + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.species] +---*/ + +var desc = Object.getOwnPropertyDescriptor(Set, Symbol.species); + +assert.sameValue(desc.get.length, 0); + +verifyNotEnumerable(desc.get, "length"); +verifyNotWritable(desc.get, "length"); +verifyConfigurable(desc.get, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/Symbol.species/return-value.js b/js/src/tests/test262/built-ins/Set/Symbol.species/return-value.js new file mode 100644 index 0000000000..db57da9a59 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/Symbol.species/return-value.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-set-@@species +description: Return value of @@species accessor method +info: | + 1. Return the this value. +features: [Symbol.species] +---*/ + +var thisVal = {}; +var accessor = Object.getOwnPropertyDescriptor(Set, Symbol.species).get; + +assert.sameValue(accessor.call(thisVal), thisVal); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/Symbol.species/shell.js b/js/src/tests/test262/built-ins/Set/Symbol.species/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/Symbol.species/symbol-species-name.js b/js/src/tests/test262/built-ins/Set/Symbol.species/symbol-species-name.js new file mode 100644 index 0000000000..4cbeaf5be9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/Symbol.species/symbol-species-name.js @@ -0,0 +1,22 @@ +// 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-get-set-@@species +description: > + Set[Symbol.species] accessor property get name +info: | + 23.2.2.2 get Set [ @@species ] + + ... + The value of the name property of this function is "get [Symbol.species]". +features: [Symbol.species] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(Set, Symbol.species); + +assert.sameValue( + descriptor.get.name, + 'get [Symbol.species]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/Symbol.species/symbol-species.js b/js/src/tests/test262/built-ins/Set/Symbol.species/symbol-species.js new file mode 100644 index 0000000000..8f80342ab9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/Symbol.species/symbol-species.js @@ -0,0 +1,23 @@ +// Copyright 2015 Cubane Canada, Inc. All rights reserved. +// See LICENSE for details. + +/*--- +esid: sec-get-set-@@species +description: Set[Symbol.species] exists per spec +info: | + Set has a property at `Symbol.species` +author: Sam Mikes +includes: [propertyHelper.js] +features: [Symbol.species] +---*/ + +var desc = Object.getOwnPropertyDescriptor(Set, Symbol.species); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, 'function'); + +verifyNotWritable(Set, Symbol.species, Symbol.species); +verifyNotEnumerable(Set, Symbol.species); +verifyConfigurable(Set, Symbol.species); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/bigint-number-same-value.js b/js/src/tests/test262/built-ins/Set/bigint-number-same-value.js new file mode 100644 index 0000000000..23406648c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/bigint-number-same-value.js @@ -0,0 +1,46 @@ +// Copyright (C) 2021 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.add +description: > + Observing the expected behavior of keys when a BigInt and Number have + the same value. +info: | + Set.prototype.add ( value ) + + ... + For each element e of entries, do + If e is not empty and SameValueZero(e, value) is true, then + Return S. + If value is -0, set value to +0. + Append value as the last element of entries. + ... + +features: [BigInt] +---*/ + +const number = 9007199254740991; +const bigint = 9007199254740991n; + +const s = new Set([ + number, + bigint, +]); + +assert.sameValue(s.size, 2); +assert.sameValue(s.has(number), true); +assert.sameValue(s.has(bigint), true); + +s.delete(number); +assert.sameValue(s.size, 1); +assert.sameValue(s.has(number), false); +s.delete(bigint); +assert.sameValue(s.size, 0); +assert.sameValue(s.has(bigint), false); + +s.add(number); +assert.sameValue(s.size, 1); +s.add(bigint); +assert.sameValue(s.size, 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/browser.js b/js/src/tests/test262/built-ins/Set/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/constructor.js b/js/src/tests/test262/built-ins/Set/constructor.js new file mode 100644 index 0000000000..0492e56a31 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/constructor.js @@ -0,0 +1,12 @@ +// 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-set-constructor +description: > + The Set constructor is the %Set% intrinsic object and the + initial value of the Set property of the global object. +---*/ + +assert.sameValue(typeof Set, "function", "`typeof Set` is `'function'`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/is-a-constructor.js b/js/src/tests/test262/built-ins/Set/is-a-constructor.js new file mode 100644 index 0000000000..d14acb2132 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/is-a-constructor.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + The Set constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct, Set] +---*/ + +assert.sameValue(isConstructor(Set), true, 'isConstructor(Set) must return true'); +new Set(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/length.js b/js/src/tests/test262/built-ins/Set/length.js new file mode 100644 index 0000000000..7e42877423 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/length.js @@ -0,0 +1,19 @@ +// 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-set-constructor +description: > + Properties of the Set Constructor + + Besides the length property (whose value is 0) + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.length, 0, "The value of `Set.length` is `0`"); + +verifyNotEnumerable(Set, "length"); +verifyNotWritable(Set, "length"); +verifyConfigurable(Set, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/name.js b/js/src/tests/test262/built-ins/Set/name.js new file mode 100644 index 0000000000..c4f6ac72ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/name.js @@ -0,0 +1,19 @@ +// 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-set-constructor +description: > + Set ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.name, "Set", "The value of `Set.name` is `'Set'`"); + +verifyNotEnumerable(Set, "name"); +verifyNotWritable(Set, "name"); +verifyConfigurable(Set, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/properties-of-the-set-prototype-object.js b/js/src/tests/test262/built-ins/Set/properties-of-the-set-prototype-object.js new file mode 100644 index 0000000000..056b3ab72d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/properties-of-the-set-prototype-object.js @@ -0,0 +1,19 @@ +// 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-properties-of-the-set-prototype-object +description: > + The Set prototype object is the intrinsic object %SetPrototype%. + The value of the [[Prototype]] internal slot of the Set prototype + object is the intrinsic object %ObjectPrototype% (19.1.3). The Set + prototype object is an ordinary object. It does not have a + [[SetData]] internal slot. +---*/ + +assert.sameValue( + Object.getPrototypeOf(Set.prototype), + Object.prototype, + "`Object.getPrototypeOf(Set.prototype)` returns `Object.prototype`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/Set/proto-from-ctor-realm.js new file mode 100644 index 0000000000..44dd8cee4d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/proto-from-ctor-realm.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set-iterable +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%SetPrototype%", + « [[SetData]] »). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var o = Reflect.construct(Set, [], C); + +assert.sameValue(Object.getPrototypeOf(o), other.Set.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype-of-set.js b/js/src/tests/test262/built-ins/Set/prototype-of-set.js new file mode 100644 index 0000000000..8b74372d0f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype-of-set.js @@ -0,0 +1,16 @@ +// 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-properties-of-the-set-constructor +description: > + The value of the [[Prototype]] internal slot of the Set constructor + is the intrinsic object %FunctionPrototype% (19.2.3). +---*/ + +assert.sameValue( + Object.getPrototypeOf(Set), + Function.prototype, + "`Object.getPrototypeOf(Set)` returns `Function.prototype`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator.js new file mode 100644 index 0000000000..d52cbf391e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator.js @@ -0,0 +1,22 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set.prototype-@@iterator +description: Initial state of the Symbol.iterator property +info: | + The initial value of the @@iterator property is the same function object as + the initial value of the values property. + + Per ES6 section 17, the method should exist on the Set prototype, and it + should be writable and configurable, but not enumerable. +includes: [propertyHelper.js] +features: [Symbol.iterator] +---*/ + +assert.sameValue(Set.prototype[Symbol.iterator], Set.prototype.values); +verifyNotEnumerable(Set.prototype, Symbol.iterator); +verifyWritable(Set.prototype, Symbol.iterator); +verifyConfigurable(Set.prototype, Symbol.iterator); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/browser.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/not-a-constructor.js new file mode 100644 index 0000000000..8db788f9c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Set.prototype[Symbol.iterator] does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, Symbol, Symbol.iterator, Set, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Set.prototype[Symbol.iterator]), + false, + 'isConstructor(Set.prototype[Symbol.iterator]) must return false' +); + +assert.throws(TypeError, () => { + let s = new Set([]); new s[Symbol.iterator](); +}, '`let s = new Set([]); new s[Symbol.iterator]()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/shell.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag.js new file mode 100644 index 0000000000..c1defb8041 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag.js @@ -0,0 +1,23 @@ +// 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-set.prototype-@@tostringtag +description: > + `Symbol.toStringTag` property descriptor +info: | + The initial value of the @@toStringTag property is the String value + "Set". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.toStringTag] +---*/ + +assert.sameValue(Set.prototype[Symbol.toStringTag], 'Set'); + +verifyNotEnumerable(Set.prototype, Symbol.toStringTag); +verifyNotWritable(Set.prototype, Symbol.toStringTag); +verifyConfigurable(Set.prototype, Symbol.toStringTag); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/browser.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/property-descriptor.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/property-descriptor.js new file mode 100644 index 0000000000..5926763343 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/property-descriptor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set.prototype-@@tostringtag +description: > + `Object.prototype.getOwnPropertyDescriptor` should reflect the value and + writability of the @@toStringTag attribute. +includes: [propertyHelper.js] +features: [Symbol.toStringTag] +---*/ + +var SetProto = Object.getPrototypeOf(new Set()); + +assert.sameValue( + SetProto[Symbol.toStringTag], + 'Set', + "The value of `SetProto[Symbol.toStringTag]` is `'Set'`" +); + +verifyNotEnumerable(SetProto, Symbol.toStringTag); +verifyNotWritable(SetProto, Symbol.toStringTag); +verifyConfigurable(SetProto, Symbol.toStringTag); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/shell.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/add.js b/js/src/tests/test262/built-ins/Set/prototype/add/add.js new file mode 100644 index 0000000000..159a0ef029 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/add.js @@ -0,0 +1,23 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.add, + "function", + "`typeof Set.prototype.add` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "add"); +verifyWritable(Set.prototype, "add"); +verifyConfigurable(Set.prototype, "add"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/browser.js b/js/src/tests/test262/built-ins/Set/prototype/add/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..e28138f16f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,23 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call([], 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call([], 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..4049431f04 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,23 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(new Map(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(new Map(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..b40f08509a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,23 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call({}, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call({}, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-set-prototype.js b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 0000000000..373a9c8583 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-set-prototype.js @@ -0,0 +1,23 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(Set.prototype, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(Set.prototype, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..42c33b2a27 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,23 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(new WeakSet(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(new WeakSet(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/length.js b/js/src/tests/test262/built-ins/Set/prototype/add/length.js new file mode 100644 index 0000000000..88b79c7dae --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/length.js @@ -0,0 +1,19 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.add.length, 1, "The value of `Set.prototype.add.length` is `1`"); + +verifyNotEnumerable(Set.prototype.add, "length"); +verifyNotWritable(Set.prototype.add, "length"); +verifyConfigurable(Set.prototype.add, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/name.js b/js/src/tests/test262/built-ins/Set/prototype/add/name.js new file mode 100644 index 0000000000..f8f5441845 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/name.js @@ -0,0 +1,19 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.add.name, "add", "The value of `Set.prototype.add.name` is `'add'`"); + +verifyNotEnumerable(Set.prototype.add, "name"); +verifyNotWritable(Set.prototype.add, "name"); +verifyConfigurable(Set.prototype.add, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/add/not-a-constructor.js new file mode 100644 index 0000000000..c1ba69377d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Set.prototype.add does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, Set, arrow-function] +---*/ + +assert.sameValue(isConstructor(Set.prototype.add), false, 'isConstructor(Set.prototype.add) must return false'); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.add(); +}, '`let s = new Set([]); new s.add()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/preserves-insertion-order.js b/js/src/tests/test262/built-ins/Set/prototype/add/preserves-insertion-order.js new file mode 100644 index 0000000000..1cef6a0cc7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/preserves-insertion-order.js @@ -0,0 +1,24 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + ... + 7. Append value as the last element of entries. + ... +---*/ + +var s = new Set(); +var expects = [1, 2, 3]; + +s.add(1).add(2).add(3); + +s.forEach(function(value) { + assert.sameValue(value, expects.shift()); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/returns-this-when-ignoring-duplicate.js b/js/src/tests/test262/built-ins/Set/prototype/add/returns-this-when-ignoring-duplicate.js new file mode 100644 index 0000000000..5635af8eb6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/returns-this-when-ignoring-duplicate.js @@ -0,0 +1,21 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + 1. Let S be this value. + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + ... + +---*/ + +var s = new Set([1]); + +assert.sameValue(s.add(1), s, "`s.add(1)` returns `s`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/returns-this.js b/js/src/tests/test262/built-ins/Set/prototype/add/returns-this.js new file mode 100644 index 0000000000..da84ccde06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/returns-this.js @@ -0,0 +1,18 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + 1. Let S be this value. + ... + 8. Return S. + +---*/ + +var s = new Set(); + +assert.sameValue(s.add(1), s, "`s.add(1)` returns `s`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/shell.js b/js/src/tests/test262/built-ins/Set/prototype/add/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..f21abae912 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-boolean.js @@ -0,0 +1,22 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(false, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(false, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-null.js new file mode 100644 index 0000000000..e99e6729d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-null.js @@ -0,0 +1,22 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(null, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(null, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-number.js new file mode 100644 index 0000000000..d5abae701c --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-number.js @@ -0,0 +1,22 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(0, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(0, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-string.js new file mode 100644 index 0000000000..bf2e69fc91 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-string.js @@ -0,0 +1,22 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call("", 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call("", 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..5e6996de64 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-symbol.js @@ -0,0 +1,23 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(Symbol(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(Symbol(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..3d301c001f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-undefined.js @@ -0,0 +1,22 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(undefined, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(undefined, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry-initial-iterable.js b/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry-initial-iterable.js new file mode 100644 index 0000000000..5b078d29bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry-initial-iterable.js @@ -0,0 +1,27 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + 6. If value is −0, let value be +0. + 7. Append value as the last element of entries. + ... + +---*/ + +var s = new Set([1]); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); + +s.add(1); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry-normalizes-zero.js b/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry-normalizes-zero.js new file mode 100644 index 0000000000..9cc7167351 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry-normalizes-zero.js @@ -0,0 +1,31 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + 6. If value is −0, let value be +0. + 7. Append value as the last element of entries. + ... + +---*/ + +var s = new Set([-0]); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); + +s.add(-0); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(-0)`"); + +s.add(0); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(0)`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry.js b/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry.js new file mode 100644 index 0000000000..28d5c75759 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry.js @@ -0,0 +1,28 @@ +// 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-set.prototype.add +description: > + Set.prototype.add ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + 6. If value is −0, let value be +0. + 7. Append value as the last element of entries. + ... + +---*/ + +var s = new Set(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); + +s.add(1); +s.add(1); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(1); s.add(1);`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/browser.js b/js/src/tests/test262/built-ins/Set/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/browser.js b/js/src/tests/test262/built-ins/Set/prototype/clear/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/clear.js b/js/src/tests/test262/built-ins/Set/prototype/clear/clear.js new file mode 100644 index 0000000000..802c67227a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/clear.js @@ -0,0 +1,23 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.clear, + "function", + "`typeof Set.prototype.clear` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "clear"); +verifyWritable(Set.prototype, "clear"); +verifyConfigurable(Set.prototype, "clear"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents-from-iterable.js b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents-from-iterable.js new file mode 100644 index 0000000000..5b0c5adbd4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents-from-iterable.js @@ -0,0 +1,28 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. Replace the element of entries whose value is e with an element whose value is empty. + ... + +---*/ + +var s = new Set([1, 2, 3]); + +assert.sameValue(s.size, 3, "The value of `s.size` is `3`"); + +var result = s.clear(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.clear()`"); +assert.sameValue(s.has(1), false, "`s.has(1)` returns `false`"); +assert.sameValue(s.has(2), false, "`s.has(2)` returns `false`"); +assert.sameValue(s.has(3), false, "`s.has(3)` returns `false`"); +assert.sameValue(result, undefined, "The result of `s.clear()` is `undefined`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents.js b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents.js new file mode 100644 index 0000000000..44c4ecf59b --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents.js @@ -0,0 +1,30 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. Replace the element of entries whose value is e with an element whose value is empty. + ... + +---*/ + +var s = new Set(); + +s.add(1).add(2).add(3); + +assert.sameValue(s.size, 3, "The value of `s.size` is `3`"); + +var result = s.clear(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.clear()`"); +assert.sameValue(s.has(1), false, "`s.has(1)` returns `false`"); +assert.sameValue(s.has(2), false, "`s.has(2)` returns `false`"); +assert.sameValue(s.has(3), false, "`s.has(3)` returns `false`"); +assert.sameValue(result, undefined, "The result of `s.clear()` is `undefined`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/clears-an-empty-set.js b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-an-empty-set.js new file mode 100644 index 0000000000..47fe4dd05b --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-an-empty-set.js @@ -0,0 +1,23 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. Replace the element of entries whose value is e with an element whose value is empty. + ... + +---*/ + +var s = new Set(); + +var result = s.clear(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); +assert.sameValue(result, undefined, "The result of `s.clear()` is `undefined`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..a892c1d9d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,23 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call([]); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..4177ce9c6d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,23 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(new Map()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(new Map()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..fc0ac57bd8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,23 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call({}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js new file mode 100644 index 0000000000..b13aee60b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js @@ -0,0 +1,23 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(Set.prototype); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(Set.prototype); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..e693c1e5bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,23 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(new WeakSet()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(new WeakSet()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/length.js b/js/src/tests/test262/built-ins/Set/prototype/clear/length.js new file mode 100644 index 0000000000..84e1dd1146 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/length.js @@ -0,0 +1,19 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.clear.length, 0, "The value of `Set.prototype.clear.length` is `0`"); + +verifyNotEnumerable(Set.prototype.clear, "length"); +verifyNotWritable(Set.prototype.clear, "length"); +verifyConfigurable(Set.prototype.clear, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/name.js b/js/src/tests/test262/built-ins/Set/prototype/clear/name.js new file mode 100644 index 0000000000..722a8af8f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/name.js @@ -0,0 +1,19 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.clear.name, "clear", "The value of `Set.prototype.clear.name` is `'clear'`"); + +verifyNotEnumerable(Set.prototype.clear, "name"); +verifyNotWritable(Set.prototype.clear, "name"); +verifyConfigurable(Set.prototype.clear, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/clear/not-a-constructor.js new file mode 100644 index 0000000000..16f0ebd97c --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Set.prototype.clear does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, Set, arrow-function] +---*/ + +assert.sameValue(isConstructor(Set.prototype.clear), false, 'isConstructor(Set.prototype.clear) must return false'); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.clear(); +}, '`let s = new Set([]); new s.clear()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/returns-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/clear/returns-undefined.js new file mode 100644 index 0000000000..8857aa8a85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/returns-undefined.js @@ -0,0 +1,17 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 6. Return undefined. + +---*/ + +var s = new Set(); + +assert.sameValue(s.clear(), undefined, "`s.clear()` returns `undefined`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/shell.js b/js/src/tests/test262/built-ins/Set/prototype/clear/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..8b8a18b1ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-boolean.js @@ -0,0 +1,22 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(false); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(false); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-null.js new file mode 100644 index 0000000000..c21931f3e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-null.js @@ -0,0 +1,22 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(null); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-number.js new file mode 100644 index 0000000000..211fa883ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-number.js @@ -0,0 +1,22 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(0); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-string.js new file mode 100644 index 0000000000..8097a19afa --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-string.js @@ -0,0 +1,22 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(""); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(""); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..3b284170fb --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-symbol.js @@ -0,0 +1,23 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(Symbol()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..35b9fc665a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-undefined.js @@ -0,0 +1,22 @@ +// 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-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(undefined); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/constructor/browser.js b/js/src/tests/test262/built-ins/Set/prototype/constructor/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/constructor/set-prototype-constructor-intrinsic.js b/js/src/tests/test262/built-ins/Set/prototype/constructor/set-prototype-constructor-intrinsic.js new file mode 100644 index 0000000000..356342fe06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/constructor/set-prototype-constructor-intrinsic.js @@ -0,0 +1,18 @@ +// 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-ecmascript-standard-built-in-objects +description: > + Set.prototype.constructor + + The initial value of Set.prototype.constructor is the intrinsic object %Set%. + +---*/ + +assert.sameValue( + Set.prototype.constructor, + Set, + "The value of `Set.prototype.constructor` is `Set`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/constructor/set-prototype-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/constructor/set-prototype-constructor.js new file mode 100644 index 0000000000..0c48222b34 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/constructor/set-prototype-constructor.js @@ -0,0 +1,17 @@ +// 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-ecmascript-standard-built-in-objects +description: > + Set ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Set.prototype, "constructor"); +verifyWritable(Set.prototype, "constructor"); +verifyConfigurable(Set.prototype, "constructor"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/constructor/shell.js b/js/src/tests/test262/built-ins/Set/prototype/constructor/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/browser.js b/js/src/tests/test262/built-ins/Set/prototype/delete/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry-initial-iterable.js b/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry-initial-iterable.js new file mode 100644 index 0000000000..688b467b30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry-initial-iterable.js @@ -0,0 +1,28 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + b. Replace the element of entries whose value is e with an element whose value is empty. + c. Return true. + ... + + +---*/ + +var s = new Set([1]); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); + +var result = s.delete(1); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(1)`"); +assert.sameValue(result, true, "The result of `s.delete(1)` is `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry-normalizes-zero.js b/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry-normalizes-zero.js new file mode 100644 index 0000000000..fb17ea0e00 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry-normalizes-zero.js @@ -0,0 +1,27 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + b. Replace the element of entries whose value is e with an element whose value is empty. + c. Return true. + ... + +---*/ + +var s = new Set([-0]); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); + +var result = s.delete(+0); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(-0)`"); +assert.sameValue(result, true, "The result of `s.delete(+0)` is `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry.js b/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry.js new file mode 100644 index 0000000000..cc84a3a368 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry.js @@ -0,0 +1,32 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + 6. If value is −0, let value be +0. + 7. Append value as the last element of entries. + ... + +---*/ + +var s = new Set(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); + +s.add(1); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(1)`"); + +var result = s.delete(1); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(1)`"); +assert.sameValue(result, true, "The result of `s.delete(1)` is `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/delete.js b/js/src/tests/test262/built-ins/Set/prototype/delete/delete.js new file mode 100644 index 0000000000..1cea6e6103 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/delete.js @@ -0,0 +1,23 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.delete, + "function", + "`typeof Set.prototype.delete` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "delete"); +verifyWritable(Set.prototype, "delete"); +verifyConfigurable(Set.prototype, "delete"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..b69fc404d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,23 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call([], 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call([], 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..9ac5ce0e03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,23 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(new Map(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(new Map(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..0bf57e4ce0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,23 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call({}, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call({}, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-set-prototype.js b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 0000000000..6c564ec064 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-set-prototype.js @@ -0,0 +1,23 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(Set.prototype, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(Set.prototype, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..60e1ef49e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,23 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(new WeakSet(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(new WeakSet(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/length.js b/js/src/tests/test262/built-ins/Set/prototype/delete/length.js new file mode 100644 index 0000000000..5d28a0ad40 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/length.js @@ -0,0 +1,19 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.delete.length, 1, "The value of `Set.prototype.delete.length` is `1`"); + +verifyNotEnumerable(Set.prototype.delete, "length"); +verifyNotWritable(Set.prototype.delete, "length"); +verifyConfigurable(Set.prototype.delete, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/name.js b/js/src/tests/test262/built-ins/Set/prototype/delete/name.js new file mode 100644 index 0000000000..538d7b4370 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/name.js @@ -0,0 +1,19 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.delete.name, "delete", "The value of `Set.prototype.delete.name` is `'delete'`"); + +verifyNotEnumerable(Set.prototype.delete, "name"); +verifyNotWritable(Set.prototype.delete, "name"); +verifyConfigurable(Set.prototype.delete, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/delete/not-a-constructor.js new file mode 100644 index 0000000000..3c978d44f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Set.prototype.delete does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, Set, arrow-function] +---*/ + +assert.sameValue(isConstructor(Set.prototype.delete), false, 'isConstructor(Set.prototype.delete) must return false'); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.delete(); +}, '`let s = new Set([]); new s.delete()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/returns-false-when-delete-is-noop.js b/js/src/tests/test262/built-ins/Set/prototype/delete/returns-false-when-delete-is-noop.js new file mode 100644 index 0000000000..8a8e69e886 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/returns-false-when-delete-is-noop.js @@ -0,0 +1,17 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +assert.sameValue(s.delete(1), false, "`s.delete(1)` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/returns-true-when-delete-operation-occurs.js b/js/src/tests/test262/built-ins/Set/prototype/delete/returns-true-when-delete-operation-occurs.js new file mode 100644 index 0000000000..e622e9bc17 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/returns-true-when-delete-operation-occurs.js @@ -0,0 +1,24 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + b. Replace the element of entries whose value is e with an element whose value is empty. + c. Return true. + ... + +---*/ + +var s = new Set(); + +s.add(1); + +assert.sameValue(s.delete(1), true, "`s.delete(1)` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/shell.js b/js/src/tests/test262/built-ins/Set/prototype/delete/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..3f40763571 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-boolean.js @@ -0,0 +1,22 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(false, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(false, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-null.js new file mode 100644 index 0000000000..11415e35c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-null.js @@ -0,0 +1,22 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(null, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(null, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-number.js new file mode 100644 index 0000000000..4dfc55488e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-number.js @@ -0,0 +1,22 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(0, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(0, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-string.js new file mode 100644 index 0000000000..5d97d8fb2a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-string.js @@ -0,0 +1,22 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call("", 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call("", 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..cf01f94cb3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-symbol.js @@ -0,0 +1,23 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(Symbol(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(Symbol(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..ffa90305f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-undefined.js @@ -0,0 +1,22 @@ +// 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-set.prototype.delete +description: > + Set.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(undefined, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(undefined, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/browser.js b/js/src/tests/test262/built-ins/Set/prototype/entries/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..771d461f65 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,29 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.entries.call([]); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..5326a8eb6b --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,28 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.entries.call(new Map()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(new Map()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..37e0b7f7a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,28 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.entries.call({}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-set-prototype.js b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 0000000000..588d45aee6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-set-prototype.js @@ -0,0 +1,28 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.entries.call(Set.prototype); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(Set.prototype); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..b8b7c97974 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,29 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.entries.call(new WeakSet()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(new WeakSet()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/entries.js b/js/src/tests/test262/built-ins/Set/prototype/entries/entries.js new file mode 100644 index 0000000000..2dc649d63a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/entries.js @@ -0,0 +1,23 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.entries, + "function", + "`typeof Set.prototype.entries` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "entries"); +verifyWritable(Set.prototype, "entries"); +verifyConfigurable(Set.prototype, "entries"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/length.js b/js/src/tests/test262/built-ins/Set/prototype/entries/length.js new file mode 100644 index 0000000000..5f7ab9dd4c --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/length.js @@ -0,0 +1,19 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.entries.length, 0, "The value of `Set.prototype.entries.length` is `0`"); + +verifyNotEnumerable(Set.prototype.entries, "length"); +verifyNotWritable(Set.prototype.entries, "length"); +verifyConfigurable(Set.prototype.entries, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/name.js b/js/src/tests/test262/built-ins/Set/prototype/entries/name.js new file mode 100644 index 0000000000..ffcfec6df1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/name.js @@ -0,0 +1,19 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.entries.name, "entries", "The value of `Set.prototype.entries.name` is `'entries'`"); + +verifyNotEnumerable(Set.prototype.entries, "name"); +verifyNotWritable(Set.prototype.entries, "name"); +verifyConfigurable(Set.prototype.entries, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/entries/not-a-constructor.js new file mode 100644 index 0000000000..cd385a7077 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Set.prototype.entries does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, Set, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Set.prototype.entries), + false, + 'isConstructor(Set.prototype.entries) must return false' +); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.entries(); +}, '`let s = new Set([]); new s.entries()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/returns-iterator-empty.js b/js/src/tests/test262/built-ins/Set/prototype/entries/returns-iterator-empty.js new file mode 100644 index 0000000000..306b48546f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/returns-iterator-empty.js @@ -0,0 +1,27 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 7. Return iterator. + + +---*/ + +var set = new Set(); +var iterator = set.entries(); +var result = iterator.next(); + +assert.sameValue(result.value, undefined, "The value of `result.value` is `undefined`"); +assert.sameValue(result.done, true, "The value of `result.done` is `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/returns-iterator.js b/js/src/tests/test262/built-ins/Set/prototype/entries/returns-iterator.js new file mode 100644 index 0000000000..8193ffd31f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/returns-iterator.js @@ -0,0 +1,58 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.entries +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 7. Return iterator. + + +---*/ + +var set = new Set(); +set.add(1); +set.add(2); +set.add(3); + +var iterator = set.entries(); +var result; + +result = iterator.next(); +assert.sameValue(result.value[0], 1, 'First result `value` ("key")'); +assert.sameValue(result.value[1], 1, 'First result `value` ("value")'); +assert.sameValue(result.value.length, 2, 'First result `value` (length)'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value[0], 2, 'Second result `value` ("key")'); +assert.sameValue(result.value[1], 2, 'Second result `value` ("value")'); +assert.sameValue(result.value.length, 2, 'Second result `value` (length)'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value[0], 3, 'Third result `value` ("key")'); +assert.sameValue(result.value[1], 3, 'Third result `value` ("value")'); +assert.sameValue(result.value.length, 2, 'Third result `value` (length)'); +assert.sameValue(result.done, false, 'Third result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); + +result = iterator.next(); +assert.sameValue( + result.value, undefined, 'Exhausted result `value` (repeated request)' +); +assert.sameValue( + result.done, true, 'Exhausted result `done` flag (repeated request)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/shell.js b/js/src/tests/test262/built-ins/Set/prototype/entries/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..d3ebbfdc38 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-boolean.js @@ -0,0 +1,28 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.entries.call(false); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(false); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-null.js new file mode 100644 index 0000000000..93613ac76d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-null.js @@ -0,0 +1,27 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.entries.call(null); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-number.js new file mode 100644 index 0000000000..6d03bbba3e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-number.js @@ -0,0 +1,27 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.entries.call(0); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-string.js new file mode 100644 index 0000000000..8230c391d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-string.js @@ -0,0 +1,27 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.entries.call(""); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(""); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..cddd8e20f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-symbol.js @@ -0,0 +1,28 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.entries.call(Symbol()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..cbae89d89d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-undefined.js @@ -0,0 +1,27 @@ +// 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-set.prototype.entries +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.entries.call(undefined); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/browser.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-boolean.js new file mode 100644 index 0000000000..f24c6d0ade --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-boolean.js @@ -0,0 +1,22 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `false` as callback + +---*/ + +var s = new Set([1]); + +assert.throws(TypeError, function() { + s.forEach(false); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-null.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-null.js new file mode 100644 index 0000000000..89b29d2737 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-null.js @@ -0,0 +1,22 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `null` as callback + +---*/ + +var s = new Set([1]); + +assert.throws(TypeError, function() { + s.forEach(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-number.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-number.js new file mode 100644 index 0000000000..38740e4dd0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-number.js @@ -0,0 +1,22 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `number` as callback + +---*/ + +var s = new Set([1]); + +assert.throws(TypeError, function() { + s.forEach(0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-string.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-string.js new file mode 100644 index 0000000000..071fd839e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-string.js @@ -0,0 +1,22 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `string` as callback + +---*/ + +var s = new Set([1]); + +assert.throws(TypeError, function() { + s.forEach(""); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-symbol.js new file mode 100644 index 0000000000..0fccfd438a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-symbol.js @@ -0,0 +1,23 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `symbol` as callback + +features: [Symbol] +---*/ + +var s = new Set([1]); + +assert.throws(TypeError, function() { + s.forEach(Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-undefined.js new file mode 100644 index 0000000000..40afeda4db --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-undefined.js @@ -0,0 +1,22 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `undefined` as callback + +---*/ + +var s = new Set([1]); + +assert.throws(TypeError, function() { + s.forEach(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..d462ba579b --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,23 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call([], function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call([], function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..50f6171e36 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,23 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(new Map(), function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(new Map(), function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..a8f2bb3d1e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,23 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call({}, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call({}, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-set-prototype.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 0000000000..8ec937a84c --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-set-prototype.js @@ -0,0 +1,23 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(Set.prototype, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(Set.prototype, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..e407f5e46c --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,23 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(new WeakSet(), function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(new WeakSet(), function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/forEach.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/forEach.js new file mode 100644 index 0000000000..e1ec73eb15 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/forEach.js @@ -0,0 +1,23 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.forEach, + "function", + "`typeof Set.prototype.forEach` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "forEach"); +verifyWritable(Set.prototype, "forEach"); +verifyConfigurable(Set.prototype, "forEach"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-in-insertion-order.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-in-insertion-order.js new file mode 100644 index 0000000000..594b2c0735 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-in-insertion-order.js @@ -0,0 +1,31 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... +---*/ + +var s = new Set(); +var expects = [1, 2, 3]; + +s.add(1).add(2).add(3); + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-in-iterable-entry-order.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-in-iterable-entry-order.js new file mode 100644 index 0000000000..920de93dff --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-in-iterable-entry-order.js @@ -0,0 +1,29 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... +---*/ + +var expects = [1, 2, 3]; +var s = new Set(expects); + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js new file mode 100644 index 0000000000..4a6eb0a13e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js @@ -0,0 +1,44 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... + + NOTE: + + ... + New values added after the call to forEach begins are visited. + +---*/ + + +var s = new Set([1]); +var expects = [1, 2, 3]; + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + if (value === 1) { + set.add(2); + } + + if (value === 2) { + set.add(3); + } + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-deleted-then-readded.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-deleted-then-readded.js new file mode 100644 index 0000000000..b764598d72 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-deleted-then-readded.js @@ -0,0 +1,47 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... + + NOTE: + + ... + Values that are deleted after the call to forEach begins and before being visited are not visited unless the value is added again before the forEach call completes. + ... + +---*/ + + +var s = new Set([1, 2, 3]); +var expects = [1, 3, 2]; + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + // Delete `2` before being visited + if (value === 1) { + set.delete(2); + } + + // Re-add `2` before forEach call completes + if (value === 3) { + set.add(2); + } + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-not-deleted.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-not-deleted.js new file mode 100644 index 0000000000..97f5bde079 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-not-deleted.js @@ -0,0 +1,36 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... + + NOTE: + + callbackfn should be a function that accepts three arguments. forEach calls callbackfn once for each value present in the set object, in value insertion order. callbackfn is called only for values of the Set which actually exist; it is not called for keys that have been deleted from the set. + +---*/ + +var expects = [1, 3]; +var s = new Set([1, 2, 3]); + +s.delete(2); + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "`forEach` is not a no-op"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-revisits-after-delete-re-add.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-revisits-after-delete-re-add.js new file mode 100644 index 0000000000..11de01c1be --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-revisits-after-delete-re-add.js @@ -0,0 +1,47 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... + + NOTE: + + ... + a value will be revisited if it is deleted after it has been visited and then re-added before the forEach call completes. + ... + +---*/ + + +var s = new Set([1, 2, 3]); +var expects = [1, 2, 3, 1]; + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + // Delete `1` after visit + if (value === 2) { + set.delete(1); + } + + // Re-add `1` + if (value === 3) { + set.add(1); + } + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/length.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/length.js new file mode 100644 index 0000000000..8304c78447 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/length.js @@ -0,0 +1,19 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + The length property of the forEach method is 1. + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.forEach.length, 1, "The value of `Set.prototype.forEach.length` is `1`"); + +verifyNotEnumerable(Set.prototype.forEach, "length"); +verifyNotWritable(Set.prototype.forEach, "length"); +verifyConfigurable(Set.prototype.forEach, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/name.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/name.js new file mode 100644 index 0000000000..390b016c64 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/name.js @@ -0,0 +1,19 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.forEach.name, "forEach", "The value of `Set.prototype.forEach.name` is `'forEach'`"); + +verifyNotEnumerable(Set.prototype.forEach, "name"); +verifyNotWritable(Set.prototype.forEach, "name"); +verifyConfigurable(Set.prototype.forEach, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/not-a-constructor.js new file mode 100644 index 0000000000..96509bf80a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Set.prototype.forEach does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, Set, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Set.prototype.forEach), + false, + 'isConstructor(Set.prototype.forEach) must return false' +); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.forEach(() => {}); +}, '`let s = new Set([]); new s.forEach(() => {})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/returns-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/returns-undefined.js new file mode 100644 index 0000000000..27cac6eb45 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/returns-undefined.js @@ -0,0 +1,21 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 8. Return undefined. + +---*/ + +var s = new Set([1]); + +assert.sameValue( + s.forEach(function() {}), + undefined, + "`s.forEach(function() {})` returns `undefined`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/shell.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-arg-explicit-cannot-override-lexical-this-arrow.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-arg-explicit-cannot-override-lexical-this-arrow.js new file mode 100644 index 0000000000..7c20508936 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-arg-explicit-cannot-override-lexical-this-arrow.js @@ -0,0 +1,28 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + + An arrow function will ignore an explicit thisArg + +features: [arrow-function] +---*/ + +var s = new Set([1]); +var usurper = {}; +var counter = 0; + +s.forEach(_ => { + assert.notSameValue(this, usurper, "`this` is not `usurper`"); + counter++; +}, usurper); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-arg-explicit.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-arg-explicit.js new file mode 100644 index 0000000000..dcae47e946 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-arg-explicit.js @@ -0,0 +1,24 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... +---*/ + +var s = new Set([1]); +var thisArg = {}; +var counter = 0; + +s.forEach(function() { + assert.sameValue(this, thisArg, "`this` is `thisArg`"); + counter++; +}, thisArg); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-non-strict.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-non-strict.js new file mode 100644 index 0000000000..b7d3a08faf --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-non-strict.js @@ -0,0 +1,26 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + +flags: [noStrict] +---*/ + +var s = new Set([1]); +var counter = 0; +var globalObject = this; + +s.forEach(function() { + assert.sameValue(this, globalObject, "`this` is the global object in non-strict mode code"); + counter++; +}); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..d06d23cec1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-boolean.js @@ -0,0 +1,22 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(false, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(false, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-null.js new file mode 100644 index 0000000000..9fb0dd4177 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-null.js @@ -0,0 +1,22 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(null, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(null, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-number.js new file mode 100644 index 0000000000..2ee877c8dc --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-number.js @@ -0,0 +1,22 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(0, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(0, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-string.js new file mode 100644 index 0000000000..0e12d3fdc5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-string.js @@ -0,0 +1,22 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call("", function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call("", function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..acf72f3e03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-symbol.js @@ -0,0 +1,23 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(Symbol(), function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(Symbol(), function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..cc97196396 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-undefined.js @@ -0,0 +1,22 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(undefined, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(undefined, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-strict-strict.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-strict-strict.js new file mode 100644 index 0000000000..8360f34120 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-strict-strict.js @@ -0,0 +1,26 @@ +'use strict'; +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + +flags: [onlyStrict] +---*/ + +var s = new Set([1]); +var counter = 0; + +s.forEach(function() { + assert.sameValue(this, undefined, "`this` is `undefined` in strict mode code"); + counter++; +}); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/throws-when-callback-throws.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/throws-when-callback-throws.js new file mode 100644 index 0000000000..423b0d2fe5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/throws-when-callback-throws.js @@ -0,0 +1,28 @@ +// 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-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... +---*/ + +var s = new Set([1]); +var counter = 0; + +assert.throws(Error, function() { + s.forEach(function() { + counter++; + throw new Error(); + }); +}); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/browser.js b/js/src/tests/test262/built-ins/Set/prototype/has/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..3ae1b82da5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,23 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call([], 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call([], 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..1730d3589f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,23 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(new Map(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(new Map(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..ec257eb554 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,23 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call({}, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call({}, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-set-prototype.js b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 0000000000..aa82cb1ade --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-set-prototype.js @@ -0,0 +1,23 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(Set.prototype, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(Set.prototype, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..e2137cc903 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,23 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(new WeakSet(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(new WeakSet(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/has.js b/js/src/tests/test262/built-ins/Set/prototype/has/has.js new file mode 100644 index 0000000000..c8f3c054ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/has.js @@ -0,0 +1,23 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.has, + "function", + "`typeof Set.prototype.has` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "has"); +verifyWritable(Set.prototype, "has"); +verifyConfigurable(Set.prototype, "has"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/length.js b/js/src/tests/test262/built-ins/Set/prototype/has/length.js new file mode 100644 index 0000000000..93326a3565 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/length.js @@ -0,0 +1,19 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.has.length, 1, "The value of `Set.prototype.has.length` is `1`"); + +verifyNotEnumerable(Set.prototype.has, "length"); +verifyNotWritable(Set.prototype.has, "length"); +verifyConfigurable(Set.prototype.has, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/name.js b/js/src/tests/test262/built-ins/Set/prototype/has/name.js new file mode 100644 index 0000000000..c95b4ff0b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/name.js @@ -0,0 +1,19 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.has.name, "has", "The value of `Set.prototype.has.name` is `'has'`"); + +verifyNotEnumerable(Set.prototype.has, "name"); +verifyNotWritable(Set.prototype.has, "name"); +verifyConfigurable(Set.prototype.has, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/has/not-a-constructor.js new file mode 100644 index 0000000000..8f41ff0c1f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Set.prototype.has does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, Set, arrow-function] +---*/ + +assert.sameValue(isConstructor(Set.prototype.has), false, 'isConstructor(Set.prototype.has) must return false'); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.has(); +}, '`let s = new Set([]); new s.has()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-undefined-added-deleted-not-present-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-undefined-added-deleted-not-present-undefined.js new file mode 100644 index 0000000000..4391df70be --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-undefined-added-deleted-not-present-undefined.js @@ -0,0 +1,23 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +s.add(undefined); +assert.sameValue(s.has(undefined), true, "`s.has(undefined)` returns `true`"); + +var result = s.delete(undefined); + +assert.sameValue(s.has(undefined), false, "`s.has(undefined)` returns `false`"); +assert.sameValue(result, true, "The result of `s.delete(undefined)` is `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-boolean.js new file mode 100644 index 0000000000..366a694050 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-boolean.js @@ -0,0 +1,17 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +assert.sameValue(s.has(false), false, "`s.has(false)` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-nan.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-nan.js new file mode 100644 index 0000000000..7ce69a5c8b --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-nan.js @@ -0,0 +1,17 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +assert.sameValue(s.has(NaN), false, "`s.has(NaN)` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-null.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-null.js new file mode 100644 index 0000000000..ddfada5bf3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-null.js @@ -0,0 +1,17 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +assert.sameValue(s.has(null), false, "`s.has(null)` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-number.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-number.js new file mode 100644 index 0000000000..9075d36884 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-number.js @@ -0,0 +1,17 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +assert.sameValue(s.has(0), false, "`s.has(0)` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-string.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-string.js new file mode 100644 index 0000000000..f244b2ee87 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-string.js @@ -0,0 +1,17 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +assert.sameValue(s.has(""), false, "`s.has('')` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-symbol.js new file mode 100644 index 0000000000..8f974f799c --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-symbol.js @@ -0,0 +1,18 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +features: [Symbol] +---*/ + +var s = new Set(); + +assert.sameValue(s.has(Symbol()), false, "`s.has(Symbol())` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-undefined.js new file mode 100644 index 0000000000..6863c7a53f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-undefined.js @@ -0,0 +1,17 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +assert.sameValue(s.has(undefined), false, "`s.has(undefined)` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-boolean.js new file mode 100644 index 0000000000..4809af3dc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-boolean.js @@ -0,0 +1,21 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new Set(); + +s.add(false) + +assert.sameValue(s.has(false), true, "`s.has(false)` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-nan.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-nan.js new file mode 100644 index 0000000000..dcc51d54e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-nan.js @@ -0,0 +1,21 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new Set(); + +s.add(NaN) + +assert.sameValue(s.has(NaN), true, "`s.has(NaN)` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-null.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-null.js new file mode 100644 index 0000000000..7c90fcd66f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-null.js @@ -0,0 +1,21 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new Set(); + +s.add(null) + +assert.sameValue(s.has(null), true, "`s.has(null)` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-number.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-number.js new file mode 100644 index 0000000000..1831aaa35f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-number.js @@ -0,0 +1,21 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new Set(); + +s.add(0) + +assert.sameValue(s.has(0), true, "`s.has(0)` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-string.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-string.js new file mode 100644 index 0000000000..938bcae841 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-string.js @@ -0,0 +1,21 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new Set(); + +s.add("") + +assert.sameValue(s.has(""), true, "`s.has('')` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-symbol.js new file mode 100644 index 0000000000..f8c5b80400 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-symbol.js @@ -0,0 +1,23 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +features: [Symbol] +---*/ + +var s = new Set(); +var a = Symbol(); + +s.add(a) + +assert.sameValue(s.has(a), true, "`s.has(a)` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-undefined.js new file mode 100644 index 0000000000..0f14f5c490 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-undefined.js @@ -0,0 +1,21 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new Set(); + +s.add(undefined) + +assert.sameValue(s.has(undefined), true, "`s.has(undefined)` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/shell.js b/js/src/tests/test262/built-ins/Set/prototype/has/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..c954fa9572 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-boolean.js @@ -0,0 +1,22 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(false, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(false, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-null.js new file mode 100644 index 0000000000..150cb8fb83 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-null.js @@ -0,0 +1,22 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(null, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(null, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-number.js new file mode 100644 index 0000000000..067c2918bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-number.js @@ -0,0 +1,22 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(0, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(0, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-string.js new file mode 100644 index 0000000000..e8f4b2ec5b --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-string.js @@ -0,0 +1,22 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call("", 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call("", 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..8254cab357 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-symbol.js @@ -0,0 +1,23 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(Symbol(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(Symbol(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..bee6d27e3e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-undefined.js @@ -0,0 +1,22 @@ +// 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-set.prototype.has +description: > + Set.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(undefined, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(undefined, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/keys/browser.js b/js/src/tests/test262/built-ins/Set/prototype/keys/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/keys/keys.js b/js/src/tests/test262/built-ins/Set/prototype/keys/keys.js new file mode 100644 index 0000000000..0f4325be91 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/keys/keys.js @@ -0,0 +1,17 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set.prototype.keys +description: > + The initial value of the keys property is the same function object as the + initial value of the values property. +---*/ + +assert.sameValue( + Set.prototype.keys, + Set.prototype.values, + "The value of `Set.prototype.keys` is `Set.prototype.values`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/keys/shell.js b/js/src/tests/test262/built-ins/Set/prototype/keys/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/shell.js b/js/src/tests/test262/built-ins/Set/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/browser.js b/js/src/tests/test262/built-ins/Set/prototype/size/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/length.js b/js/src/tests/test262/built-ins/Set/prototype/size/length.js new file mode 100644 index 0000000000..4b0b0675dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/size/length.js @@ -0,0 +1,22 @@ +// 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-get-set.prototype.size +description: > + get Set.prototype.size + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(Set.prototype, "size"); + + +assert.sameValue(descriptor.get.length, 0, "The value of `Set.prototype.size.length` is `0`"); + +verifyNotEnumerable(descriptor.get, "length"); +verifyNotWritable(descriptor.get, "length"); +verifyConfigurable(descriptor.get, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/name.js b/js/src/tests/test262/built-ins/Set/prototype/size/name.js new file mode 100644 index 0000000000..79723d8f0e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/size/name.js @@ -0,0 +1,25 @@ +// 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-get-set.prototype.size +description: > + get Set.prototype.size + + 17 ECMAScript Standard Built-in Objects + + Functions that are specified as get or set accessor functions of built-in + properties have "get " or "set " prepended to the property name string. + +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(Set.prototype, "size"); + + +assert.sameValue(descriptor.get.name, "get size", "The value of `descriptor.get.name` is `'get size'`"); + +verifyNotEnumerable(descriptor.get, "name"); +verifyNotWritable(descriptor.get, "name"); +verifyConfigurable(descriptor.get, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-before-after-add-delete.js b/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-before-after-add-delete.js new file mode 100644 index 0000000000..6a6c083bae --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-before-after-add-delete.js @@ -0,0 +1,27 @@ +// 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-get-set.prototype.size +description: > + get Set.prototype.size + + 5. Let count be 0. + 6. For each e that is an element of entries + a. If e is not empty, set count to count+1. + + Before and after add(), delete() +---*/ + +var s = new Set(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); + +s.add(0); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(0)`"); + +s.delete(0); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(0)`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-by-insertion.js b/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-by-insertion.js new file mode 100644 index 0000000000..b1ea12fc5f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-by-insertion.js @@ -0,0 +1,27 @@ +// 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-get-set.prototype.size +description: > + get Set.prototype.size + + 5. Let count be 0. + 6. For each e that is an element of entries + a. If e is not empty, set count to count+1. + +features: [Symbol] +---*/ + +var s = new Set(); + +s.add(0); +s.add(undefined); +s.add(false); +s.add(NaN); +s.add(null); +s.add(""); +s.add(Symbol()); + +assert.sameValue(s.size, 7, "The value of `s.size` is `7`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-by-iterable.js b/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-by-iterable.js new file mode 100644 index 0000000000..9ef5423a70 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-by-iterable.js @@ -0,0 +1,19 @@ +// 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-get-set.prototype.size +description: > + get Set.prototype.size + + 5. Let count be 0. + 6. For each e that is an element of entries + a. If e is not empty, set count to count+1. + +features: [Symbol] +---*/ + +var s = new Set([0, undefined, false, NaN, null, "", Symbol()]); + +assert.sameValue(s.size, 7, "The value of `s.size` is `7`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/shell.js b/js/src/tests/test262/built-ins/Set/prototype/size/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/size.js b/js/src/tests/test262/built-ins/Set/prototype/size/size.js new file mode 100644 index 0000000000..18b0566e2c --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/size/size.js @@ -0,0 +1,29 @@ +// 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-get-set.prototype.size +description: > + get Set.prototype.size + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(Set.prototype, "size"); + +assert.sameValue( + typeof descriptor.get, + "function", + "`typeof descriptor.get` is `'function'`" +); +assert.sameValue( + typeof descriptor.set, + "undefined", + "`typeof descriptor.set` is `\"undefined\"`" +); + +verifyNotEnumerable(Set.prototype, "size"); +verifyConfigurable(Set.prototype, "size"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/browser.js b/js/src/tests/test262/built-ins/Set/prototype/values/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..8c09871a1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,29 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call([]); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..ba9452f718 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,28 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(new Map()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(new Map()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..8c96537bd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,28 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call({}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-set-prototype.js b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 0000000000..6d9fcceecb --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-set-prototype.js @@ -0,0 +1,28 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(Set.prototype); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(Set.prototype); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..24a79a9138 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,29 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(new WeakSet()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(new WeakSet()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/length.js b/js/src/tests/test262/built-ins/Set/prototype/values/length.js new file mode 100644 index 0000000000..8e49d1bc51 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/length.js @@ -0,0 +1,19 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.values.length, 0, "The value of `Set.prototype.values.length` is `0`"); + +verifyNotEnumerable(Set.prototype.values, "length"); +verifyNotWritable(Set.prototype.values, "length"); +verifyConfigurable(Set.prototype.values, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/name.js b/js/src/tests/test262/built-ins/Set/prototype/values/name.js new file mode 100644 index 0000000000..a2458e9505 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/name.js @@ -0,0 +1,19 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.values.name, "values", "The value of `Set.prototype.values.name` is `'values'`"); + +verifyNotEnumerable(Set.prototype.values, "name"); +verifyNotWritable(Set.prototype.values, "name"); +verifyConfigurable(Set.prototype.values, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/values/not-a-constructor.js new file mode 100644 index 0000000000..f21399ca9f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Set.prototype.values does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, Set, arrow-function] +---*/ + +assert.sameValue(isConstructor(Set.prototype.values), false, 'isConstructor(Set.prototype.values) must return false'); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.values(); +}, '`let s = new Set([]); new s.values()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/returns-iterator-empty.js b/js/src/tests/test262/built-ins/Set/prototype/values/returns-iterator-empty.js new file mode 100644 index 0000000000..92c4dff059 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/returns-iterator-empty.js @@ -0,0 +1,16 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set.prototype.values +description: > + Returns an iterator that's already done if Set is empty. +---*/ + +var set = new Set(); +var iterator = set.values(); +var result = iterator.next(); +assert.sameValue(result.value, undefined, "The value of `result.value` is `undefined`"); +assert.sameValue(result.done, true, "The value of `result.done` is `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/returns-iterator.js b/js/src/tests/test262/built-ins/Set/prototype/values/returns-iterator.js new file mode 100644 index 0000000000..319cbbddbe --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/returns-iterator.js @@ -0,0 +1,43 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set.prototype.values +description: > + The method should return a valid iterator with the context as the + IteratedObject. +---*/ + +var set = new Set(); +set.add(1); +set.add(2); +set.add(3); + +var iterator = set.values(); +var result; + +result = iterator.next(); +assert.sameValue(result.value, 1, 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 2, 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 3, 'Third result `value`'); +assert.sameValue(result.done, false, 'Third result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); + +result = iterator.next(); +assert.sameValue( + result.value, undefined, 'Exhausted result `value` (repeated request)' +); +assert.sameValue( + result.done, true, 'Exhausted result `done` flag (repeated request)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/shell.js b/js/src/tests/test262/built-ins/Set/prototype/values/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..83828a339d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-boolean.js @@ -0,0 +1,28 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(false); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(false); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-null.js new file mode 100644 index 0000000000..253f10a31d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-null.js @@ -0,0 +1,27 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(null); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-number.js new file mode 100644 index 0000000000..1c8319a523 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-number.js @@ -0,0 +1,27 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(0); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-string.js new file mode 100644 index 0000000000..e6e81fdba2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-string.js @@ -0,0 +1,27 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(""); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(""); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..bd88d0fabf --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-symbol.js @@ -0,0 +1,28 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(Symbol()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..14c2ec0a0e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-undefined.js @@ -0,0 +1,27 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(undefined); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/values-iteration-mutable.js b/js/src/tests/test262/built-ins/Set/prototype/values/values-iteration-mutable.js new file mode 100644 index 0000000000..c0ba8093c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/values-iteration-mutable.js @@ -0,0 +1,48 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set.prototype.values +description: > + When an item is added to the set after the iterator is created but before + the iterator is "done" (as defined by 23.2.5.2.1), the new item should be + accessible via iteration. When an item is added to the set after the + iterator is "done", the new item should not be accessible via iteration. +---*/ + +var set = new Set(); +set.add(1); +set.add(2); + +var iterator = set.values(); +var result; + +result = iterator.next(); +assert.sameValue(result.value, 1, 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +set.add(3); + +result = iterator.next(); +assert.sameValue(result.value, 2, 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 3, 'Third result `value`'); +assert.sameValue(result.done, false, 'Third result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); + +set.add(4); + +result = iterator.next(); +assert.sameValue( + result.value, undefined, 'Exhausted result `value` (repeated request)' +); +assert.sameValue( + result.done, true, 'Exhausted result `done` flag (repeated request)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/values.js b/js/src/tests/test262/built-ins/Set/prototype/values/values.js new file mode 100644 index 0000000000..4a02e37d00 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/values.js @@ -0,0 +1,23 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.values, + "function", + "`typeof Set.prototype.values` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "values"); +verifyWritable(Set.prototype, "values"); +verifyConfigurable(Set.prototype, "values"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-does-not-throw-when-add-is-not-callable.js b/js/src/tests/test262/built-ins/Set/set-does-not-throw-when-add-is-not-callable.js new file mode 100644 index 0000000000..b76957c90e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-does-not-throw-when-add-is-not-callable.js @@ -0,0 +1,35 @@ +// 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-set-constructor +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + +Set.prototype.add = null; + +var s = new Set(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-get-add-method-failure.js b/js/src/tests/test262/built-ins/Set/set-get-add-method-failure.js new file mode 100644 index 0000000000..c201c60f6c --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-get-add-method-failure.js @@ -0,0 +1,30 @@ +// 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-set-constructor +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 6. If iterable is either undefined or null, let iter be undefined. + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). +---*/ + +function MyError() {} +Object.defineProperty(Set.prototype, 'add', { + get: function() { + throw new MyError(); + } +}); + +new Set(); + +assert.throws(MyError, function() { + new Set([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-iterable-calls-add.js b/js/src/tests/test262/built-ins/Set/set-iterable-calls-add.js new file mode 100644 index 0000000000..5655c98e82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-iterable-calls-add.js @@ -0,0 +1,41 @@ +// 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-set-constructor +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + +var setAdd = Set.prototype.add; +var counter = 0; + +Set.prototype.add = function(value) { + counter++; + setAdd.call(this, value); +}; + +var s = new Set([1, 2]); + +assert.sameValue(counter, 2, "`Set.prototype.add` called twice."); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-iterable-empty-does-not-call-add.js b/js/src/tests/test262/built-ins/Set/set-iterable-empty-does-not-call-add.js new file mode 100644 index 0000000000..2ccd6a1a03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-iterable-empty-does-not-call-add.js @@ -0,0 +1,41 @@ +// 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-set-constructor +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + +var setAdd = Set.prototype.add; +var counter = 0; + +Set.prototype.add = function(value) { + counter++; + setAdd.call(this, value); +}; + +var s = new Set([]); + +assert.sameValue(counter, 0, "`Set.prototype.add` was not called."); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-iterable-throws-when-add-is-not-callable.js b/js/src/tests/test262/built-ins/Set/set-iterable-throws-when-add-is-not-callable.js new file mode 100644 index 0000000000..da2d3da374 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-iterable-throws-when-add-is-not-callable.js @@ -0,0 +1,36 @@ +// 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-set-constructor +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + + +Set.prototype.add = null; + +assert.throws(TypeError, function() { + new Set([1, 2]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-iterable.js b/js/src/tests/test262/built-ins/Set/set-iterable.js new file mode 100644 index 0000000000..7ab3f202f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-iterable.js @@ -0,0 +1,33 @@ +// 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-set-constructor +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + +var s = new Set([1, 2]); + +assert.sameValue(s.size, 2, "The value of `s.size` is `2`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-iterator-close-after-add-failure.js b/js/src/tests/test262/built-ins/Set/set-iterator-close-after-add-failure.js new file mode 100644 index 0000000000..8b78343ba6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-iterator-close-after-add-failure.js @@ -0,0 +1,50 @@ +// 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-set-constructor +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +features: [Symbol.iterator] +---*/ + +var count = 0; +var iterable = {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + return { + value: null, + done: false + }; + }, + return: function() { + count += 1; + } + }; +}; +Set.prototype.add = function() { + throw new Error(); +} + +assert.throws(Error, function() { + new Set(iterable); +}); + +assert.sameValue( + count, 1, "The iterator is closed when `Set.prototype.add` throws an error." +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-iterator-next-failure.js b/js/src/tests/test262/built-ins/Set/set-iterator-next-failure.js new file mode 100644 index 0000000000..a4bc2cc4c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-iterator-next-failure.js @@ -0,0 +1,32 @@ +// 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-set-constructor +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). +features: [Symbol.iterator] +---*/ + +var iterable = {}; + +function MyError() {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + throw new MyError(); + } + }; +}; + +assert.throws(MyError, function() { + new Set(iterable); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-iterator-value-failure.js b/js/src/tests/test262/built-ins/Set/set-iterator-value-failure.js new file mode 100644 index 0000000000..ef62c38644 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-iterator-value-failure.js @@ -0,0 +1,39 @@ +// 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-set-constructor +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 9. Repeat + ... + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). +features: [Symbol.iterator] +---*/ + +var count = 0; +var iterable = {}; + +function MyError() {} +iterable[Symbol.iterator] = function() { + return { + next: function() { + return { + get value() { + throw new MyError(); + }, + done: false + }; + } + }; +}; + +assert.throws(MyError, function() { + new Set(iterable); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-newtarget.js b/js/src/tests/test262/built-ins/Set/set-newtarget.js new file mode 100644 index 0000000000..2a32deaffd --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-newtarget.js @@ -0,0 +1,32 @@ +// 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-set-constructor +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 2. Let set be OrdinaryCreateFromConstructor(NewTarget, "%SetPrototype%", «‍[[SetData]]» ). + ... + +---*/ + +var s1 = new Set(); + +assert.sameValue( + Object.getPrototypeOf(s1), + Set.prototype, + "`Object.getPrototypeOf(s1)` returns `Set.prototype`" +); + +var s2 = new Set([1, 2]); + +assert.sameValue( + Object.getPrototypeOf(s2), + Set.prototype, + "`Object.getPrototypeOf(s2)` returns `Set.prototype`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-no-iterable.js b/js/src/tests/test262/built-ins/Set/set-no-iterable.js new file mode 100644 index 0000000000..5ccdc4f763 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-no-iterable.js @@ -0,0 +1,23 @@ +// 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-set-constructor +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 5. If iterable is not present, let iterable be undefined. + 6. If iterable is either undefined or null, let iter be undefined. + ... + 8. If iter is undefined, return set. + +---*/ + + +assert.sameValue(new Set().size, 0, "The value of `new Set().size` is `0`"); +assert.sameValue(new Set(undefined).size, 0, "The value of `new Set(undefined).size` is `0`"); +assert.sameValue(new Set(null).size, 0, "The value of `new Set(null).size` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-undefined-newtarget.js b/js/src/tests/test262/built-ins/Set/set-undefined-newtarget.js new file mode 100644 index 0000000000..f1f5dbb15e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-undefined-newtarget.js @@ -0,0 +1,23 @@ +// 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-set-constructor +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + 1. If NewTarget is undefined, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set(); +}); + +assert.throws(TypeError, function() { + Set([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set.js b/js/src/tests/test262/built-ins/Set/set.js new file mode 100644 index 0000000000..244eb8b69b --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set.js @@ -0,0 +1,17 @@ +// 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-set-constructor +description: > + Set ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(this, "Set"); +verifyWritable(this, "Set"); +verifyConfigurable(this, "Set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/shell.js b/js/src/tests/test262/built-ins/Set/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/Set/valid-values.js b/js/src/tests/test262/built-ins/Set/valid-values.js new file mode 100644 index 0000000000..fa0458236d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/valid-values.js @@ -0,0 +1,390 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2021 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.add +description: Observing the expected behavior of valid values +info: | + Set.prototype.add ( value ) + + ... + For each element e of entries, do + If e is not empty and SameValueZero(e, value) is true, then + Return S. + If value is -0, set value to +0. + Append value as the last element of entries. + ... + +features: [BigInt, Symbol, TypedArray, WeakRef, exponentiation] +---*/ + + +const negativeZero = -0; +const positiveZero = +0; +const zero = 0; +const one = 1; +const twoRaisedToFiftyThreeMinusOne = 2 ** 53 - 1; +const int32Array = new Int32Array([zero, one]); +const uint32Array = new Uint32Array([zero, one]); +const n = 100000000000000000000000000000000000000000000000000000000000000000000000000000000001n; +const bigInt = BigInt('100000000000000000000000000000000000000000000000000000000000000000000000000000000001'); +const n1 = 1n; +const n53 = 9007199254740991n; +const fiftyThree = BigInt('9007199254740991'); +const bigInt64Array = new BigInt64Array([n1, n53]); +const bigUint64Array = new BigUint64Array([n1, n53]); +const symbol = Symbol(''); +const object = {}; +const array = {}; +const string = ''; +const booleanTrue = true; +const booleanFalse = true; +const functionExprValue = function() {}; +const arrowFunctionValue = () => {}; +const classValue = class {}; +const map = new Map(); +const set = new Set(); +const weakMap = new WeakMap(); +const weakRef = new WeakRef({}); +const weakSet = new WeakSet(); +const nullValue = null; +const undefinedValue = undefined; +let unassigned; + +{ + const s = new Set([negativeZero, negativeZero]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(negativeZero), true); + s.delete(negativeZero); + assert.sameValue(s.size, 0); + s.add(negativeZero); + assert.sameValue(s.has(negativeZero), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([positiveZero, positiveZero]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(positiveZero), true); + s.delete(positiveZero); + assert.sameValue(s.size, 0); + s.add(positiveZero); + assert.sameValue(s.has(positiveZero), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([zero, zero]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(zero), true); + s.delete(zero); + assert.sameValue(s.size, 0); + s.add(zero); + assert.sameValue(s.has(zero), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([one, one]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(one), true); + s.delete(one); + assert.sameValue(s.size, 0); + s.add(one); + assert.sameValue(s.has(one), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([twoRaisedToFiftyThreeMinusOne, twoRaisedToFiftyThreeMinusOne]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(twoRaisedToFiftyThreeMinusOne), true); + s.delete(twoRaisedToFiftyThreeMinusOne); + assert.sameValue(s.size, 0); + s.add(twoRaisedToFiftyThreeMinusOne); assert.sameValue(s.has(twoRaisedToFiftyThreeMinusOne), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([int32Array, int32Array]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(int32Array), true); + s.delete(int32Array); + assert.sameValue(s.size, 0); + s.add(int32Array); + assert.sameValue(s.has(int32Array), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([uint32Array, uint32Array]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(uint32Array), true); + s.delete(uint32Array); + assert.sameValue(s.size, 0); + s.add(uint32Array); + assert.sameValue(s.has(uint32Array), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([n, n]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(n), true); + s.delete(n); + assert.sameValue(s.size, 0); + s.add(n); + assert.sameValue(s.has(n), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([bigInt, bigInt]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(bigInt), true); + s.delete(bigInt); + assert.sameValue(s.size, 0); + s.add(bigInt); + assert.sameValue(s.has(bigInt), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([n1, n1]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(n1), true); + s.delete(n1); + assert.sameValue(s.size, 0); + s.add(n1); + assert.sameValue(s.has(n1), true); +} +{ const s = new Set([n53, n53]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(n53), true); + s.delete(n53); + assert.sameValue(s.size, 0); + s.add(n53); + assert.sameValue(s.has(n53), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([fiftyThree, fiftyThree]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(fiftyThree), true); + s.delete(fiftyThree); + assert.sameValue(s.size, 0); + s.add(fiftyThree); + assert.sameValue(s.has(fiftyThree), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([bigInt64Array, bigInt64Array]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(bigInt64Array), true); + s.delete(bigInt64Array); + assert.sameValue(s.size, 0); + s.add(bigInt64Array); + assert.sameValue(s.has(bigInt64Array), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([bigUint64Array, bigUint64Array]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(bigUint64Array), true); + s.delete(bigUint64Array); + assert.sameValue(s.size, 0); + s.add(bigUint64Array); + assert.sameValue(s.has(bigUint64Array), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([symbol, symbol]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(symbol), true); + s.delete(symbol); + assert.sameValue(s.size, 0); + s.add(symbol); + assert.sameValue(s.has(symbol), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([object, object]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(object), true); + s.delete(object); + assert.sameValue(s.size, 0); + s.add(object); + assert.sameValue(s.has(object), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([array, array]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(array), true); + s.delete(array); + assert.sameValue(s.size, 0); + s.add(array); + assert.sameValue(s.has(array), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([string, string]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(string), true); + s.delete(string); + assert.sameValue(s.size, 0); + s.add(string); + assert.sameValue(s.has(string), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([booleanTrue, booleanTrue]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(booleanTrue), true); + s.delete(booleanTrue); + assert.sameValue(s.size, 0); + s.add(booleanTrue); + assert.sameValue(s.has(booleanTrue), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([booleanFalse, booleanFalse]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(booleanFalse), true); + s.delete(booleanFalse); + assert.sameValue(s.size, 0); + s.add(booleanFalse); + assert.sameValue(s.has(booleanFalse), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([functionExprValue, functionExprValue]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(functionExprValue), true); + s.delete(functionExprValue); + assert.sameValue(s.size, 0); + s.add(functionExprValue); assert.sameValue(s.has(functionExprValue), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([arrowFunctionValue, arrowFunctionValue]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(arrowFunctionValue), true); + s.delete(arrowFunctionValue); + assert.sameValue(s.size, 0); + s.add(arrowFunctionValue); assert.sameValue(s.has(arrowFunctionValue), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([classValue, classValue]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(classValue), true); + s.delete(classValue); + assert.sameValue(s.size, 0); + s.add(classValue); + assert.sameValue(s.has(classValue), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([map, map]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(map), true); + s.delete(map); + assert.sameValue(s.size, 0); + s.add(map); + assert.sameValue(s.has(map), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([set, set]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(set), true); + s.delete(set); + assert.sameValue(s.size, 0); + s.add(set); + assert.sameValue(s.has(set), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([weakMap, weakMap]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(weakMap), true); + s.delete(weakMap); + assert.sameValue(s.size, 0); + s.add(weakMap); + assert.sameValue(s.has(weakMap), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([weakRef, weakRef]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(weakRef), true); + s.delete(weakRef); + assert.sameValue(s.size, 0); + s.add(weakRef); + assert.sameValue(s.has(weakRef), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([weakSet, weakSet]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(weakSet), true); + s.delete(weakSet); + assert.sameValue(s.size, 0); + s.add(weakSet); + assert.sameValue(s.has(weakSet), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([nullValue, nullValue]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(nullValue), true); + s.delete(nullValue); + assert.sameValue(s.size, 0); + s.add(nullValue); + assert.sameValue(s.has(nullValue), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([undefinedValue, undefinedValue]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(undefinedValue), true); + s.delete(undefinedValue); + assert.sameValue(s.size, 0); + s.add(undefinedValue); + assert.sameValue(s.has(undefinedValue), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new Set([unassigned, unassigned]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(unassigned), true); + s.delete(unassigned); + assert.sameValue(s.size, 0); + s.add(unassigned); + assert.sameValue(s.has(unassigned), true); + assert.sameValue(s.size, 1); +}; + + +reportCompare(0, 0); -- cgit v1.2.3