From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- js/src/tests/test262/built-ins/Array/15.4.5-1.js | 14 + .../tests/test262/built-ins/Array/15.4.5.1-5-1.js | 16 + .../tests/test262/built-ins/Array/15.4.5.1-5-2.js | 16 + .../test262/built-ins/Array/S15.4.1_A1.1_T1.js | 25 + .../test262/built-ins/Array/S15.4.1_A1.1_T2.js | 21 + .../test262/built-ins/Array/S15.4.1_A1.1_T3.js | 19 + .../test262/built-ins/Array/S15.4.1_A1.2_T1.js | 18 + .../test262/built-ins/Array/S15.4.1_A1.3_T1.js | 17 + .../test262/built-ins/Array/S15.4.1_A2.1_T1.js | 20 + .../test262/built-ins/Array/S15.4.1_A2.2_T1.js | 37 + .../test262/built-ins/Array/S15.4.1_A3.1_T1.js | 20 + .../test262/built-ins/Array/S15.4.2.1_A1.1_T1.js | 20 + .../test262/built-ins/Array/S15.4.2.1_A1.1_T2.js | 21 + .../test262/built-ins/Array/S15.4.2.1_A1.1_T3.js | 18 + .../test262/built-ins/Array/S15.4.2.1_A1.2_T1.js | 18 + .../test262/built-ins/Array/S15.4.2.1_A1.3_T1.js | 17 + .../test262/built-ins/Array/S15.4.2.1_A2.1_T1.js | 20 + .../test262/built-ins/Array/S15.4.2.1_A2.2_T1.js | 37 + .../test262/built-ins/Array/S15.4.3_A1.1_T1.js | 19 + .../test262/built-ins/Array/S15.4.3_A1.1_T2.js | 20 + .../test262/built-ins/Array/S15.4.3_A1.1_T3.js | 17 + .../test262/built-ins/Array/S15.4.5.1_A1.2_T2.js | 21 + .../test262/built-ins/Array/S15.4.5.1_A2.1_T1.js | 27 + .../test262/built-ins/Array/S15.4.5.1_A2.2_T1.js | 22 + .../test262/built-ins/Array/S15.4.5.1_A2.3_T1.js | 19 + .../test262/built-ins/Array/S15.4.5.2_A1_T1.js | 28 + .../test262/built-ins/Array/S15.4.5.2_A1_T2.js | 22 + .../test262/built-ins/Array/S15.4.5.2_A2_T1.js | 24 + .../test262/built-ins/Array/S15.4.5.2_A3_T1.js | 23 + .../test262/built-ins/Array/S15.4.5.2_A3_T2.js | 32 + .../test262/built-ins/Array/S15.4.5.2_A3_T3.js | 28 + .../test262/built-ins/Array/S15.4_A1.1_T10.js | 25 + .../tests/test262/built-ins/Array/S15.4_A1.1_T4.js | 20 + .../tests/test262/built-ins/Array/S15.4_A1.1_T5.js | 22 + .../tests/test262/built-ins/Array/S15.4_A1.1_T6.js | 21 + .../tests/test262/built-ins/Array/S15.4_A1.1_T7.js | 24 + .../tests/test262/built-ins/Array/S15.4_A1.1_T8.js | 24 + .../tests/test262/built-ins/Array/S15.4_A1.1_T9.js | 121 ++ .../built-ins/Array/Symbol.species/browser.js | 0 .../built-ins/Array/Symbol.species/length.js | 34 + .../built-ins/Array/Symbol.species/return-value.js | 16 + .../built-ins/Array/Symbol.species/shell.js | 0 .../Array/Symbol.species/symbol-species-name.js | 27 + .../Array/Symbol.species/symbol-species.js | 23 + js/src/tests/test262/built-ins/Array/browser.js | 0 .../tests/test262/built-ins/Array/constructor.js | 12 + .../built-ins/Array/from/Array.from-descriptor.js | 14 + .../built-ins/Array/from/Array.from-name.js | 32 + .../built-ins/Array/from/Array.from_arity.js | 23 + .../Array.from_forwards-length-for-array-likes.js | 41 + ...y-like-has-length-but-no-indexes-with-values.js | 41 + .../tests/test262/built-ins/Array/from/browser.js | 0 .../Array/from/calling-from-valid-1-noStrict.js | 68 + .../from/calling-from-valid-1-onlyStrict-strict.js | 69 + .../built-ins/Array/from/calling-from-valid-2.js | 69 + .../built-ins/Array/from/elements-added-after.js | 40 + .../built-ins/Array/from/elements-deleted-after.js | 34 + .../built-ins/Array/from/elements-updated-after.js | 29 + .../test262/built-ins/Array/from/from-array.js | 25 + .../test262/built-ins/Array/from/from-string.js | 19 + .../built-ins/Array/from/get-iter-method-err.js | 24 + .../built-ins/Array/from/items-is-arraybuffer.js | 21 + .../built-ins/Array/from/items-is-null-throws.js | 19 + .../test262/built-ins/Array/from/iter-adv-err.js | 30 + .../built-ins/Array/from/iter-cstm-ctor-err.js | 28 + .../test262/built-ins/Array/from/iter-cstm-ctor.js | 50 + .../built-ins/Array/from/iter-get-iter-err.js | 24 + .../built-ins/Array/from/iter-get-iter-val-err.js | 36 + .../built-ins/Array/from/iter-map-fn-args.js | 73 + .../built-ins/Array/from/iter-map-fn-err.js | 43 + .../built-ins/Array/from/iter-map-fn-return.js | 72 + .../built-ins/Array/from/iter-map-fn-this-arg.js | 59 + .../Array/from/iter-map-fn-this-non-strict.js | 62 + .../Array/from/iter-map-fn-this-strict-strict.js | 60 + .../built-ins/Array/from/iter-set-elem-prop-err.js | 54 + .../Array/from/iter-set-elem-prop-non-writable.js | 45 + .../built-ins/Array/from/iter-set-elem-prop.js | 60 + .../built-ins/Array/from/iter-set-length-err.js | 39 + .../built-ins/Array/from/iter-set-length.js | 48 + .../Array/from/mapfn-is-not-callable-typeerror.js | 36 + .../built-ins/Array/from/mapfn-is-symbol-throws.js | 22 + .../built-ins/Array/from/mapfn-throws-exception.js | 20 + .../built-ins/Array/from/not-a-constructor.js | 31 + .../built-ins/Array/from/proto-from-ctor-realm.js | 37 + js/src/tests/test262/built-ins/Array/from/shell.js | 0 .../built-ins/Array/from/source-array-boundary.js | 30 + .../Array/from/source-object-constructor.js | 17 + .../Array/from/source-object-iterator-1.js | 34 + .../Array/from/source-object-iterator-2.js | 39 + .../from/source-object-length-set-elem-prop-err.js | 54 + ...rce-object-length-set-elem-prop-non-writable.js | 48 + .../built-ins/Array/from/source-object-length.js | 27 + .../built-ins/Array/from/source-object-missing.js | 24 + .../built-ins/Array/from/source-object-without.js | 20 + .../test262/built-ins/Array/from/this-null.js | 14 + .../async-iterable-async-mapped-awaits-once.js | 31 + .../async-iterable-input-does-not-await-input.js | 39 + .../async-iterable-input-iteration-err.js | 21 + .../Array/fromAsync/async-iterable-input.js | 24 + .../fromAsync/asyncitems-array-add-to-empty.js | 45 + .../fromAsync/asyncitems-array-add-to-singleton.js | 44 + .../Array/fromAsync/asyncitems-array-add.js | 44 + .../Array/fromAsync/asyncitems-array-mutate.js | 45 + .../Array/fromAsync/asyncitems-array-remove.js | 44 + .../Array/fromAsync/asyncitems-arraybuffer.js | 18 + .../Array/fromAsync/asyncitems-arraylike-holes.js | 25 + .../asyncitems-arraylike-length-accessor-throws.js | 26 + .../fromAsync/asyncitems-arraylike-promise.js | 32 + .../fromAsync/asyncitems-arraylike-too-long.js | 32 + .../fromAsync/asyncitems-asynciterator-exists.js | 33 + .../asyncitems-asynciterator-not-callable.js | 20 + .../fromAsync/asyncitems-asynciterator-null.js | 31 + .../fromAsync/asyncitems-asynciterator-sync.js | 33 + .../fromAsync/asyncitems-asynciterator-throws.js | 17 + .../built-ins/Array/fromAsync/asyncitems-bigint.js | 21 + .../Array/fromAsync/asyncitems-boolean.js | 21 + .../Array/fromAsync/asyncitems-function.js | 22 + .../Array/fromAsync/asyncitems-iterator-exists.js | 34 + .../fromAsync/asyncitems-iterator-not-callable.js | 20 + .../Array/fromAsync/asyncitems-iterator-null.js | 31 + .../Array/fromAsync/asyncitems-iterator-promise.js | 34 + .../Array/fromAsync/asyncitems-iterator-throws.js | 17 + .../Array/fromAsync/asyncitems-null-undefined.js | 19 + .../built-ins/Array/fromAsync/asyncitems-number.js | 21 + .../fromAsync/asyncitems-object-not-arraylike.js | 24 + .../Array/fromAsync/asyncitems-operations.js | 31 + .../built-ins/Array/fromAsync/asyncitems-string.js | 17 + .../built-ins/Array/fromAsync/asyncitems-symbol.js | 21 + .../asyncitems-uses-intrinsic-iterator-symbols.js | 41 + .../test262/built-ins/Array/fromAsync/browser.js | 0 .../test262/built-ins/Array/fromAsync/builtin.js | 38 + .../test262/built-ins/Array/fromAsync/length.js | 28 + .../Array/fromAsync/mapfn-async-arraylike.js | 36 + .../Array/fromAsync/mapfn-async-iterable-async.js | 36 + .../Array/fromAsync/mapfn-async-iterable-sync.js | 36 + .../mapfn-async-throws-close-async-iterator.js | 41 + .../mapfn-async-throws-close-sync-iterator.js | 41 + .../Array/fromAsync/mapfn-async-throws.js | 24 + .../Array/fromAsync/mapfn-not-callable.js | 26 + .../mapfn-result-awaited-once-per-iteration.js | 48 + .../Array/fromAsync/mapfn-sync-arraylike.js | 36 + .../Array/fromAsync/mapfn-sync-iterable-async.js | 34 + .../Array/fromAsync/mapfn-sync-iterable-sync.js | 34 + .../mapfn-sync-throws-close-async-iterator.js | 40 + .../mapfn-sync-throws-close-sync-iterator.js | 40 + .../built-ins/Array/fromAsync/mapfn-sync-throws.js | 23 + .../test262/built-ins/Array/fromAsync/name.js | 28 + ...-iterable-input-does-not-use-array-prototype.js | 47 + .../non-iterable-input-element-access-err.js | 22 + ...ble-async-mapped-awaits-callback-result-once.js | 33 + ...nput-with-thenable-async-mapped-callback-err.js | 28 + ...iterable-input-with-thenable-element-rejects.js | 27 + ...input-with-thenable-sync-mapped-callback-err.js | 22 + .../fromAsync/non-iterable-input-with-thenable.js | 25 + .../Array/fromAsync/non-iterable-input.js | 25 + .../non-iterable-sync-mapped-callback-err.js | 28 + .../non-iterable-with-non-promise-thenable.js | 27 + ...rable-with-thenable-async-mapped-awaits-once.js | 30 + .../non-iterable-with-thenable-awaits-once.js | 28 + ...erable-with-thenable-sync-mapped-awaits-once.js | 29 + .../non-iterable-with-thenable-then-method-err.js | 25 + .../built-ins/Array/fromAsync/not-a-constructor.js | 19 + .../test262/built-ins/Array/fromAsync/prop-desc.js | 23 + .../returned-promise-resolves-to-array.js | 23 + .../built-ins/Array/fromAsync/returns-promise.js | 36 + .../test262/built-ins/Array/fromAsync/shell.js | 2271 ++++++++++++++++++++ ...ync-iterable-input-with-non-promise-thenable.js | 24 + .../fromAsync/sync-iterable-input-with-thenable.js | 18 + .../Array/fromAsync/sync-iterable-input.js | 18 + .../Array/fromAsync/sync-iterable-iteration-err.js | 20 + ...rable-with-thenable-async-mapped-awaits-once.js | 26 + ...able-with-thenable-async-mapped-callback-err.js | 19 + .../sync-iterable-with-thenable-awaits-once.js | 26 + .../sync-iterable-with-thenable-element-rejects.js | 22 + ...erable-with-thenable-sync-mapped-awaits-once.js | 26 + ...rable-with-thenable-sync-mapped-callback-err.js | 19 + .../sync-iterable-with-thenable-then-method-err.js | 24 + .../Array/fromAsync/this-constructor-operations.js | 74 + .../this-constructor-with-bad-length-setter.js | 34 + .../this-constructor-with-readonly-elements.js | 51 + .../this-constructor-with-readonly-length.js | 39 + ...ith-unsettable-element-closes-async-iterator.js | 44 + ...with-unsettable-element-closes-sync-iterator.js | 44 + .../this-constructor-with-unsettable-element.js | 29 + .../built-ins/Array/fromAsync/this-constructor.js | 53 + .../Array/fromAsync/this-non-constructor.js | 49 + .../built-ins/Array/fromAsync/thisarg-object.js | 22 + .../Array/fromAsync/thisarg-omitted-sloppy.js | 34 + .../fromAsync/thisarg-omitted-strict-strict.js | 30 + .../Array/fromAsync/thisarg-primitive-sloppy.js | 76 + .../fromAsync/thisarg-primitive-strict-strict.js | 51 + .../test262/built-ins/Array/is-a-constructor.js | 26 + .../built-ins/Array/isArray/15.4.3.2-0-1.js | 14 + .../built-ins/Array/isArray/15.4.3.2-0-2.js | 12 + .../built-ins/Array/isArray/15.4.3.2-0-3.js | 12 + .../built-ins/Array/isArray/15.4.3.2-0-4.js | 16 + .../built-ins/Array/isArray/15.4.3.2-0-5.js | 14 + .../built-ins/Array/isArray/15.4.3.2-0-6.js | 12 + .../built-ins/Array/isArray/15.4.3.2-0-7.js | 12 + .../built-ins/Array/isArray/15.4.3.2-1-1.js | 12 + .../built-ins/Array/isArray/15.4.3.2-1-10.js | 12 + .../built-ins/Array/isArray/15.4.3.2-1-11.js | 12 + .../built-ins/Array/isArray/15.4.3.2-1-12.js | 12 + .../built-ins/Array/isArray/15.4.3.2-1-13.js | 18 + .../built-ins/Array/isArray/15.4.3.2-1-15.js | 12 + .../built-ins/Array/isArray/15.4.3.2-1-2.js | 12 + .../built-ins/Array/isArray/15.4.3.2-1-3.js | 12 + .../built-ins/Array/isArray/15.4.3.2-1-4.js | 12 + .../built-ins/Array/isArray/15.4.3.2-1-5.js | 12 + .../built-ins/Array/isArray/15.4.3.2-1-6.js | 12 + .../built-ins/Array/isArray/15.4.3.2-1-7.js | 12 + .../built-ins/Array/isArray/15.4.3.2-1-8.js | 12 + .../built-ins/Array/isArray/15.4.3.2-1-9.js | 12 + .../built-ins/Array/isArray/15.4.3.2-2-1.js | 18 + .../built-ins/Array/isArray/15.4.3.2-2-2.js | 20 + .../built-ins/Array/isArray/15.4.3.2-2-3.js | 18 + .../test262/built-ins/Array/isArray/browser.js | 0 .../test262/built-ins/Array/isArray/descriptor.js | 14 + .../tests/test262/built-ins/Array/isArray/name.js | 29 + .../built-ins/Array/isArray/not-a-constructor.js | 31 + .../built-ins/Array/isArray/proxy-revoked.js | 30 + .../tests/test262/built-ins/Array/isArray/proxy.js | 32 + .../tests/test262/built-ins/Array/isArray/shell.js | 0 js/src/tests/test262/built-ins/Array/length.js | 26 + .../built-ins/Array/length/15.4.5.1-3.d-1.js | 17 + .../built-ins/Array/length/15.4.5.1-3.d-2.js | 17 + .../built-ins/Array/length/15.4.5.1-3.d-3.js | 15 + .../built-ins/Array/length/S15.4.2.2_A1.1_T1.js | 20 + .../built-ins/Array/length/S15.4.2.2_A1.1_T2.js | 18 + .../built-ins/Array/length/S15.4.2.2_A1.1_T3.js | 20 + .../built-ins/Array/length/S15.4.2.2_A1.2_T1.js | 14 + .../built-ins/Array/length/S15.4.2.2_A2.1_T1.js | 22 + .../built-ins/Array/length/S15.4.2.2_A2.2_T1.js | 46 + .../built-ins/Array/length/S15.4.2.2_A2.2_T2.js | 46 + .../built-ins/Array/length/S15.4.2.2_A2.2_T3.js | 46 + .../built-ins/Array/length/S15.4.2.2_A2.3_T1.js | 24 + .../built-ins/Array/length/S15.4.2.2_A2.3_T2.js | 25 + .../built-ins/Array/length/S15.4.2.2_A2.3_T3.js | 25 + .../built-ins/Array/length/S15.4.2.2_A2.3_T4.js | 32 + .../built-ins/Array/length/S15.4.2.2_A2.3_T5.js | 32 + .../built-ins/Array/length/S15.4.4_A1.3_T1.js | 13 + .../built-ins/Array/length/S15.4.5.1_A1.1_T1.js | 47 + .../built-ins/Array/length/S15.4.5.1_A1.1_T2.js | 59 + .../built-ins/Array/length/S15.4.5.1_A1.2_T1.js | 23 + .../built-ins/Array/length/S15.4.5.1_A1.2_T3.js | 23 + .../built-ins/Array/length/S15.4.5.1_A1.3_T1.js | 35 + .../built-ins/Array/length/S15.4.5.1_A1.3_T2.js | 114 + .../built-ins/Array/length/S15.4.5.2_A3_T4.js | 24 + .../test262/built-ins/Array/length/browser.js | 0 .../define-own-prop-length-coercion-order-set.js | 48 + .../define-own-prop-length-coercion-order.js | 63 + .../Array/length/define-own-prop-length-error.js | 26 + .../define-own-prop-length-no-value-order.js | 64 + .../define-own-prop-length-overflow-order.js | 31 + .../define-own-prop-length-overflow-realm.js | 23 + .../tests/test262/built-ins/Array/length/shell.js | 0 js/src/tests/test262/built-ins/Array/name.js | 30 + js/src/tests/test262/built-ins/Array/of/browser.js | 0 .../construct-this-with-the-number-of-arguments.js | 41 + .../Array/of/creates-a-new-array-from-arguments.js | 47 + .../Array/of/does-not-use-prototype-properties.js | 32 + .../Array/of/does-not-use-set-for-indices.js | 38 + js/src/tests/test262/built-ins/Array/of/length.js | 23 + js/src/tests/test262/built-ins/Array/of/name.js | 24 + .../built-ins/Array/of/not-a-constructor.js | 31 + js/src/tests/test262/built-ins/Array/of/of.js | 19 + .../built-ins/Array/of/proto-from-ctor-realm.js | 35 + .../built-ins/Array/of/return-a-custom-instance.js | 39 + .../Array/of/return-a-new-array-object.js | 42 + .../Array/of/return-abrupt-from-contructor.js | 29 + ...return-abrupt-from-data-property-using-proxy.js | 40 + .../Array/of/return-abrupt-from-data-property.js | 48 + .../Array/of/return-abrupt-from-setting-length.js | 28 + .../test262/built-ins/Array/of/sets-length.js | 38 + js/src/tests/test262/built-ins/Array/of/shell.js | 0 js/src/tests/test262/built-ins/Array/prop-desc.js | 27 + .../Array/property-cast-boolean-primitive.js | 22 + .../built-ins/Array/property-cast-nan-infinity.js | 28 + .../built-ins/Array/property-cast-number.js | 40 + .../built-ins/Array/proto-from-ctor-realm-one.js | 56 + .../built-ins/Array/proto-from-ctor-realm-two.js | 56 + .../built-ins/Array/proto-from-ctor-realm-zero.js | 54 + js/src/tests/test262/built-ins/Array/proto.js | 21 + .../built-ins/Array/prototype/Symbol.iterator.js | 22 + .../Array/prototype/Symbol.iterator/browser.js | 0 .../prototype/Symbol.iterator/not-a-constructor.js | 35 + .../Array/prototype/Symbol.iterator/shell.js | 0 .../Symbol.unscopables/array-find-from-last.js | 33 + .../Array/prototype/Symbol.unscopables/browser.js | 0 .../Symbol.unscopables/change-array-by-copy.js | 31 + .../prototype/Symbol.unscopables/prop-desc.js | 18 + .../Array/prototype/Symbol.unscopables/shell.js | 0 .../Array/prototype/Symbol.unscopables/value.js | 82 + .../built-ins/Array/prototype/at/browser.js | 0 .../Array/prototype/at/index-argument-tointeger.js | 33 + ...index-non-numeric-argument-tointeger-invalid.js | 26 + .../at/index-non-numeric-argument-tointeger.js | 32 + .../test262/built-ins/Array/prototype/at/length.js | 30 + .../test262/built-ins/Array/prototype/at/name.js | 32 + .../built-ins/Array/prototype/at/prop-desc.js | 32 + .../Array/prototype/at/return-abrupt-from-this.js | 28 + .../prototype/at/returns-item-relative-index.js | 36 + .../built-ins/Array/prototype/at/returns-item.js | 37 + ...returns-undefined-for-holes-in-sparse-arrays.js | 45 + .../at/returns-undefined-for-out-of-range-index.js | 26 + .../test262/built-ins/Array/prototype/at/shell.js | 0 .../test262/built-ins/Array/prototype/browser.js | 0 .../prototype/concat/15.4.4.4-5-b-iii-3-b-1.js | 28 + .../Array/prototype/concat/15.4.4.4-5-c-i-1.js | 30 + ...pe.concat_array-like-length-to-string-throws.js | 26 + ...ype.concat_array-like-length-value-of-throws.js | 26 + ....prototype.concat_array-like-negative-length.js | 24 + ...oncat_array-like-primitive-non-number-length.js | 32 + ...ay.prototype.concat_array-like-string-length.js | 35 + ...prototype.concat_array-like-to-length-throws.js | 31 + .../concat/Array.prototype.concat_array-like.js | 36 + ...rray.prototype.concat_holey-sloppy-arguments.js | 21 + .../Array.prototype.concat_large-typed-array.js | 52 + .../concat/Array.prototype.concat_length-throws.js | 27 + .../concat/Array.prototype.concat_no-prototype.js | 16 + .../concat/Array.prototype.concat_non-array.js | 31 + ...ray.prototype.concat_sloppy-arguments-throws.js | 24 + ...prototype.concat_sloppy-arguments-with-dupes.js | 28 + .../Array.prototype.concat_sloppy-arguments.js | 27 + .../Array.prototype.concat_small-typed-array.js | 56 + ....prototype.concat_spreadable-boolean-wrapper.js | 45 + .../Array.prototype.concat_spreadable-function.js | 38 + ...ay.prototype.concat_spreadable-getter-throws.js | 26 + ...y.prototype.concat_spreadable-number-wrapper.js | 43 + .../Array.prototype.concat_spreadable-reg-exp.js | 41 + ...ay.prototype.concat_spreadable-sparse-object.js | 25 + ...y.prototype.concat_spreadable-string-wrapper.js | 34 + .../Array.prototype.concat_strict-arguments.js | 28 + .../Array/prototype/concat/S15.4.4.4_A1_T1.js | 28 + .../Array/prototype/concat/S15.4.4.4_A1_T2.js | 30 + .../Array/prototype/concat/S15.4.4.4_A1_T3.js | 24 + .../Array/prototype/concat/S15.4.4.4_A1_T4.js | 24 + .../Array/prototype/concat/S15.4.4.4_A2_T1.js | 30 + .../Array/prototype/concat/S15.4.4.4_A2_T2.js | 22 + .../Array/prototype/concat/S15.4.4.4_A3_T1.js | 34 + .../Array/prototype/concat/S15.4.4.4_A3_T2.js | 37 + .../Array/prototype/concat/S15.4.4.4_A3_T3.js | 37 + .../concat/arg-length-exceeding-integer-limit.js | 42 + .../concat/arg-length-near-integer-limit.js | 39 + .../built-ins/Array/prototype/concat/browser.js | 0 .../Array/prototype/concat/call-with-boolean.js | 20 + .../prototype/concat/create-ctor-non-object.js | 44 + .../Array/prototype/concat/create-ctor-poisoned.js | 28 + .../Array/prototype/concat/create-non-array.js | 40 + .../concat/create-proto-from-ctor-realm-array.js | 48 + .../create-proto-from-ctor-realm-non-array.js | 49 + .../Array/prototype/concat/create-proxy.js | 45 + .../Array/prototype/concat/create-revoked-proxy.js | 40 + .../prototype/concat/create-species-abrupt.js | 34 + .../prototype/concat/create-species-non-ctor.js | 40 + .../create-species-non-extensible-spreadable.js | 45 + .../concat/create-species-non-extensible.js | 43 + .../Array/prototype/concat/create-species-null.js | 38 + .../prototype/concat/create-species-poisoned.js | 33 + .../Array/prototype/concat/create-species-undef.js | 40 + ...es-with-non-configurable-property-spreadable.js | 47 + ...reate-species-with-non-configurable-property.js | 45 + ...pecies-with-non-writable-property-spreadable.js | 49 + .../create-species-with-non-writable-property.js | 49 + .../Array/prototype/concat/create-species.js | 48 + .../concat/is-concat-spreadable-get-err.js | 40 + .../concat/is-concat-spreadable-get-order.js | 75 + .../is-concat-spreadable-is-array-proxy-revoked.js | 52 + .../concat/is-concat-spreadable-proxy-revoked.js | 45 + .../prototype/concat/is-concat-spreadable-proxy.js | 53 + .../concat/is-concat-spreadable-val-falsey.js | 57 + .../concat/is-concat-spreadable-val-truthy.js | 55 + .../concat/is-concat-spreadable-val-undefined.js | 43 + .../built-ins/Array/prototype/concat/length.js | 34 + .../built-ins/Array/prototype/concat/name.js | 32 + .../Array/prototype/concat/not-a-constructor.js | 35 + .../built-ins/Array/prototype/concat/prop-desc.js | 23 + .../built-ins/Array/prototype/concat/shell.js | 0 .../built-ins/Array/prototype/constructor.js | 27 + .../Array/prototype/copyWithin/browser.js | 0 .../prototype/copyWithin/call-with-boolean.js | 20 + .../prototype/copyWithin/coerced-values-end.js | 47 + .../coerced-values-start-change-start.js | 57 + .../coerced-values-start-change-target.js | 46 + .../prototype/copyWithin/coerced-values-start.js | 58 + .../prototype/copyWithin/coerced-values-target.js | 63 + .../Array/prototype/copyWithin/fill-holes.js | 20 + .../copyWithin/length-near-integer-limit.js | 45 + .../built-ins/Array/prototype/copyWithin/length.js | 22 + .../built-ins/Array/prototype/copyWithin/name.js | 24 + .../Array/prototype/copyWithin/negative-end.js | 60 + .../copyWithin/negative-out-of-bounds-end.js | 70 + .../copyWithin/negative-out-of-bounds-start.js | 59 + .../copyWithin/negative-out-of-bounds-target.js | 37 + .../Array/prototype/copyWithin/negative-start.js | 47 + .../Array/prototype/copyWithin/negative-target.js | 32 + .../copyWithin/non-negative-out-of-bounds-end.js | 56 + .../non-negative-out-of-bounds-target-and-start.js | 107 + .../copyWithin/non-negative-target-and-start.js | 54 + .../non-negative-target-start-and-end.js | 72 + .../prototype/copyWithin/not-a-constructor.js | 35 + .../Array/prototype/copyWithin/prop-desc.js | 23 + .../return-abrupt-from-delete-proxy-target.js | 40 + .../copyWithin/return-abrupt-from-delete-target.js | 35 + .../copyWithin/return-abrupt-from-end-as-symbol.js | 23 + .../prototype/copyWithin/return-abrupt-from-end.js | 26 + .../return-abrupt-from-get-start-value.js | 41 + .../copyWithin/return-abrupt-from-has-start.js | 40 + .../return-abrupt-from-set-target-value.js | 42 + .../return-abrupt-from-start-as-symbol.js | 22 + .../copyWithin/return-abrupt-from-start.js | 25 + .../return-abrupt-from-target-as-symbol.js | 22 + .../copyWithin/return-abrupt-from-target.js | 25 + .../return-abrupt-from-this-length-as-symbol.js | 26 + .../copyWithin/return-abrupt-from-this-length.js | 38 + .../copyWithin/return-abrupt-from-this.js | 22 + .../Array/prototype/copyWithin/return-this.js | 24 + .../built-ins/Array/prototype/copyWithin/shell.js | 0 .../Array/prototype/copyWithin/undefined-end.js | 27 + .../built-ins/Array/prototype/entries/browser.js | 0 .../Array/prototype/entries/iteration-mutable.js | 36 + .../built-ins/Array/prototype/entries/iteration.js | 41 + .../built-ins/Array/prototype/entries/length.js | 24 + .../built-ins/Array/prototype/entries/name.js | 24 + .../Array/prototype/entries/not-a-constructor.js | 35 + .../built-ins/Array/prototype/entries/prop-desc.js | 24 + .../prototype/entries/return-abrupt-from-this.js | 22 + .../entries/returns-iterator-from-object.js | 27 + .../Array/prototype/entries/returns-iterator.js | 32 + .../built-ins/Array/prototype/entries/shell.js | 0 .../Array/prototype/every/15.4.4.16-0-1.js | 13 + .../Array/prototype/every/15.4.4.16-1-1.js | 14 + .../Array/prototype/every/15.4.4.16-1-10.js | 18 + .../Array/prototype/every/15.4.4.16-1-11.js | 19 + .../Array/prototype/every/15.4.4.16-1-12.js | 19 + .../Array/prototype/every/15.4.4.16-1-13.js | 18 + .../Array/prototype/every/15.4.4.16-1-14.js | 19 + .../Array/prototype/every/15.4.4.16-1-15.js | 19 + .../Array/prototype/every/15.4.4.16-1-2.js | 14 + .../Array/prototype/every/15.4.4.16-1-3.js | 22 + .../Array/prototype/every/15.4.4.16-1-4.js | 24 + .../Array/prototype/every/15.4.4.16-1-5.js | 22 + .../Array/prototype/every/15.4.4.16-1-6.js | 24 + .../Array/prototype/every/15.4.4.16-1-7.js | 15 + .../Array/prototype/every/15.4.4.16-1-8.js | 17 + .../Array/prototype/every/15.4.4.16-1-9.js | 21 + .../Array/prototype/every/15.4.4.16-2-1.js | 29 + .../Array/prototype/every/15.4.4.16-2-10.js | 39 + .../Array/prototype/every/15.4.4.16-2-11.js | 30 + .../Array/prototype/every/15.4.4.16-2-12.js | 37 + .../Array/prototype/every/15.4.4.16-2-13.js | 34 + .../Array/prototype/every/15.4.4.16-2-14.js | 26 + .../Array/prototype/every/15.4.4.16-2-17.js | 27 + .../Array/prototype/every/15.4.4.16-2-18.js | 26 + .../Array/prototype/every/15.4.4.16-2-19.js | 29 + .../Array/prototype/every/15.4.4.16-2-2.js | 22 + .../Array/prototype/every/15.4.4.16-2-3.js | 35 + .../Array/prototype/every/15.4.4.16-2-4.js | 28 + .../Array/prototype/every/15.4.4.16-2-5.js | 44 + .../Array/prototype/every/15.4.4.16-2-6.js | 34 + .../Array/prototype/every/15.4.4.16-2-7.js | 35 + .../Array/prototype/every/15.4.4.16-2-8.js | 42 + .../Array/prototype/every/15.4.4.16-2-9.js | 47 + .../Array/prototype/every/15.4.4.16-3-1.js | 24 + .../Array/prototype/every/15.4.4.16-3-10.js | 26 + .../Array/prototype/every/15.4.4.16-3-11.js | 29 + .../Array/prototype/every/15.4.4.16-3-12.js | 29 + .../Array/prototype/every/15.4.4.16-3-13.js | 29 + .../Array/prototype/every/15.4.4.16-3-14.js | 34 + .../Array/prototype/every/15.4.4.16-3-15.js | 29 + .../Array/prototype/every/15.4.4.16-3-16.js | 29 + .../Array/prototype/every/15.4.4.16-3-17.js | 29 + .../Array/prototype/every/15.4.4.16-3-18.js | 27 + .../Array/prototype/every/15.4.4.16-3-19.js | 43 + .../Array/prototype/every/15.4.4.16-3-2.js | 28 + .../Array/prototype/every/15.4.4.16-3-20.js | 37 + .../Array/prototype/every/15.4.4.16-3-21.js | 44 + .../Array/prototype/every/15.4.4.16-3-22.js | 43 + .../Array/prototype/every/15.4.4.16-3-23.js | 51 + .../Array/prototype/every/15.4.4.16-3-24.js | 29 + .../Array/prototype/every/15.4.4.16-3-25.js | 27 + .../Array/prototype/every/15.4.4.16-3-29.js | 28 + .../Array/prototype/every/15.4.4.16-3-3.js | 24 + .../Array/prototype/every/15.4.4.16-3-4.js | 24 + .../Array/prototype/every/15.4.4.16-3-5.js | 24 + .../Array/prototype/every/15.4.4.16-3-6.js | 29 + .../Array/prototype/every/15.4.4.16-3-7.js | 29 + .../Array/prototype/every/15.4.4.16-3-8.js | 27 + .../Array/prototype/every/15.4.4.16-3-9.js | 27 + .../Array/prototype/every/15.4.4.16-4-1.js | 15 + .../Array/prototype/every/15.4.4.16-4-10.js | 28 + .../Array/prototype/every/15.4.4.16-4-11.js | 32 + .../Array/prototype/every/15.4.4.16-4-12.js | 16 + .../Array/prototype/every/15.4.4.16-4-15.js | 39 + .../Array/prototype/every/15.4.4.16-4-3.js | 15 + .../Array/prototype/every/15.4.4.16-4-4.js | 15 + .../Array/prototype/every/15.4.4.16-4-5.js | 15 + .../Array/prototype/every/15.4.4.16-4-6.js | 15 + .../Array/prototype/every/15.4.4.16-4-7.js | 17 + .../Array/prototype/every/15.4.4.16-4-8.js | 31 + .../Array/prototype/every/15.4.4.16-4-9.js | 35 + .../Array/prototype/every/15.4.4.16-5-1-s.js | 23 + .../Array/prototype/every/15.4.4.16-5-1.js | 22 + .../Array/prototype/every/15.4.4.16-5-10.js | 23 + .../Array/prototype/every/15.4.4.16-5-11.js | 23 + .../Array/prototype/every/15.4.4.16-5-12.js | 23 + .../Array/prototype/every/15.4.4.16-5-13.js | 21 + .../Array/prototype/every/15.4.4.16-5-14.js | 20 + .../Array/prototype/every/15.4.4.16-5-15.js | 21 + .../Array/prototype/every/15.4.4.16-5-16.js | 21 + .../Array/prototype/every/15.4.4.16-5-17.js | 20 + .../Array/prototype/every/15.4.4.16-5-18.js | 21 + .../Array/prototype/every/15.4.4.16-5-19.js | 25 + .../Array/prototype/every/15.4.4.16-5-2.js | 23 + .../Array/prototype/every/15.4.4.16-5-21.js | 21 + .../Array/prototype/every/15.4.4.16-5-22.js | 20 + .../Array/prototype/every/15.4.4.16-5-23.js | 20 + .../Array/prototype/every/15.4.4.16-5-24.js | 20 + .../Array/prototype/every/15.4.4.16-5-3.js | 23 + .../Array/prototype/every/15.4.4.16-5-4.js | 25 + .../Array/prototype/every/15.4.4.16-5-5.js | 23 + .../Array/prototype/every/15.4.4.16-5-6.js | 22 + .../Array/prototype/every/15.4.4.16-5-7.js | 19 + .../Array/prototype/every/15.4.4.16-5-9.js | 20 + .../Array/prototype/every/15.4.4.16-7-1.js | 27 + .../Array/prototype/every/15.4.4.16-7-2.js | 25 + .../Array/prototype/every/15.4.4.16-7-3.js | 25 + .../Array/prototype/every/15.4.4.16-7-4.js | 25 + .../Array/prototype/every/15.4.4.16-7-5.js | 27 + .../Array/prototype/every/15.4.4.16-7-6.js | 28 + .../Array/prototype/every/15.4.4.16-7-7.js | 26 + .../Array/prototype/every/15.4.4.16-7-8.js | 25 + .../Array/prototype/every/15.4.4.16-7-9.js | 35 + .../Array/prototype/every/15.4.4.16-7-b-1.js | 25 + .../Array/prototype/every/15.4.4.16-7-b-10.js | 35 + .../Array/prototype/every/15.4.4.16-7-b-11.js | 32 + .../Array/prototype/every/15.4.4.16-7-b-12.js | 38 + .../Array/prototype/every/15.4.4.16-7-b-13.js | 32 + .../Array/prototype/every/15.4.4.16-7-b-14.js | 30 + .../Array/prototype/every/15.4.4.16-7-b-15.js | 37 + .../Array/prototype/every/15.4.4.16-7-b-16.js | 39 + .../Array/prototype/every/15.4.4.16-7-b-2.js | 29 + .../Array/prototype/every/15.4.4.16-7-b-3.js | 33 + .../Array/prototype/every/15.4.4.16-7-b-4.js | 38 + .../Array/prototype/every/15.4.4.16-7-b-5.js | 36 + .../Array/prototype/every/15.4.4.16-7-b-6.js | 37 + .../Array/prototype/every/15.4.4.16-7-b-7.js | 35 + .../Array/prototype/every/15.4.4.16-7-b-8.js | 39 + .../Array/prototype/every/15.4.4.16-7-b-9.js | 37 + .../Array/prototype/every/15.4.4.16-7-c-i-1.js | 28 + .../Array/prototype/every/15.4.4.16-7-c-i-10.js | 30 + .../Array/prototype/every/15.4.4.16-7-c-i-11.js | 40 + .../Array/prototype/every/15.4.4.16-7-c-i-12.js | 32 + .../Array/prototype/every/15.4.4.16-7-c-i-13.js | 45 + .../Array/prototype/every/15.4.4.16-7-c-i-14.js | 37 + .../Array/prototype/every/15.4.4.16-7-c-i-15.js | 36 + .../Array/prototype/every/15.4.4.16-7-c-i-16.js | 28 + .../Array/prototype/every/15.4.4.16-7-c-i-17.js | 29 + .../Array/prototype/every/15.4.4.16-7-c-i-18.js | 28 + .../Array/prototype/every/15.4.4.16-7-c-i-19.js | 32 + .../Array/prototype/every/15.4.4.16-7-c-i-2.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-i-20.js | 31 + .../Array/prototype/every/15.4.4.16-7-c-i-21.js | 33 + .../Array/prototype/every/15.4.4.16-7-c-i-22.js | 26 + .../Array/prototype/every/15.4.4.16-7-c-i-25.js | 26 + .../Array/prototype/every/15.4.4.16-7-c-i-26.js | 32 + .../Array/prototype/every/15.4.4.16-7-c-i-27.js | 32 + .../Array/prototype/every/15.4.4.16-7-c-i-28.js | 39 + .../Array/prototype/every/15.4.4.16-7-c-i-29.js | 41 + .../Array/prototype/every/15.4.4.16-7-c-i-3.js | 33 + .../Array/prototype/every/15.4.4.16-7-c-i-30.js | 37 + .../Array/prototype/every/15.4.4.16-7-c-i-31.js | 35 + .../Array/prototype/every/15.4.4.16-7-c-i-4.js | 24 + .../Array/prototype/every/15.4.4.16-7-c-i-5.js | 42 + .../Array/prototype/every/15.4.4.16-7-c-i-6.js | 28 + .../Array/prototype/every/15.4.4.16-7-c-i-7.js | 33 + .../Array/prototype/every/15.4.4.16-7-c-i-8.js | 23 + .../Array/prototype/every/15.4.4.16-7-c-i-9.js | 34 + .../Array/prototype/every/15.4.4.16-7-c-ii-1.js | 20 + .../Array/prototype/every/15.4.4.16-7-c-ii-10.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-ii-11.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-ii-12.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-ii-13.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-ii-16.js | 26 + .../Array/prototype/every/15.4.4.16-7-c-ii-17.js | 26 + .../Array/prototype/every/15.4.4.16-7-c-ii-18.js | 26 + .../Array/prototype/every/15.4.4.16-7-c-ii-19.js | 26 + .../Array/prototype/every/15.4.4.16-7-c-ii-2.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-ii-20.js | 29 + .../Array/prototype/every/15.4.4.16-7-c-ii-21.js | 34 + .../Array/prototype/every/15.4.4.16-7-c-ii-22.js | 34 + .../Array/prototype/every/15.4.4.16-7-c-ii-23.js | 26 + .../Array/prototype/every/15.4.4.16-7-c-ii-3.js | 28 + .../Array/prototype/every/15.4.4.16-7-c-ii-4.js | 28 + .../Array/prototype/every/15.4.4.16-7-c-ii-5.js | 33 + .../Array/prototype/every/15.4.4.16-7-c-ii-6.js | 27 + .../Array/prototype/every/15.4.4.16-7-c-ii-7.js | 34 + .../Array/prototype/every/15.4.4.16-7-c-ii-8.js | 28 + .../Array/prototype/every/15.4.4.16-7-c-ii-9.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-1.js | 25 + .../Array/prototype/every/15.4.4.16-7-c-iii-10.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-11.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-12.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-13.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-14.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-15.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-16.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-17.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-18.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-19.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-2.js | 25 + .../Array/prototype/every/15.4.4.16-7-c-iii-20.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-21.js | 19 + .../Array/prototype/every/15.4.4.16-7-c-iii-22.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-23.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-24.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-25.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-27.js | 22 + .../Array/prototype/every/15.4.4.16-7-c-iii-28.js | 46 + .../Array/prototype/every/15.4.4.16-7-c-iii-29.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-3.js | 25 + .../Array/prototype/every/15.4.4.16-7-c-iii-4.js | 27 + .../Array/prototype/every/15.4.4.16-7-c-iii-5.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-6.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-7.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-8.js | 21 + .../Array/prototype/every/15.4.4.16-7-c-iii-9.js | 21 + .../Array/prototype/every/15.4.4.16-8-1.js | 14 + .../Array/prototype/every/15.4.4.16-8-10.js | 27 + .../Array/prototype/every/15.4.4.16-8-11.js | 25 + .../Array/prototype/every/15.4.4.16-8-12.js | 24 + .../Array/prototype/every/15.4.4.16-8-13.js | 25 + .../Array/prototype/every/15.4.4.16-8-2.js | 23 + .../Array/prototype/every/15.4.4.16-8-3.js | 23 + .../Array/prototype/every/15.4.4.16-8-4.js | 23 + .../Array/prototype/every/15.4.4.16-8-5.js | 23 + .../Array/prototype/every/15.4.4.16-8-6.js | 29 + .../Array/prototype/every/15.4.4.16-8-7.js | 34 + .../Array/prototype/every/15.4.4.16-8-8.js | 38 + .../built-ins/Array/prototype/every/browser.js | 0 .../Array/prototype/every/call-with-boolean.js | 20 + .../every/callbackfn-resize-arraybuffer.js | 74 + .../built-ins/Array/prototype/every/length.js | 23 + .../built-ins/Array/prototype/every/name.js | 28 + .../Array/prototype/every/not-a-constructor.js | 35 + .../built-ins/Array/prototype/every/prop-desc.js | 23 + .../built-ins/Array/prototype/every/shell.js | 161 ++ .../built-ins/Array/prototype/exotic-array.js | 26 + .../built-ins/Array/prototype/fill/browser.js | 0 .../Array/prototype/fill/call-with-boolean.js | 20 + .../Array/prototype/fill/coerced-indexes.js | 77 + .../fill/fill-values-custom-start-and-end.js | 40 + .../prototype/fill/fill-values-relative-end.js | 32 + .../prototype/fill/fill-values-relative-start.js | 29 + .../built-ins/Array/prototype/fill/fill-values.js | 35 + .../prototype/fill/length-near-integer-limit.js | 33 + .../built-ins/Array/prototype/fill/length.js | 20 + .../test262/built-ins/Array/prototype/fill/name.js | 24 + .../Array/prototype/fill/not-a-constructor.js | 31 + .../built-ins/Array/prototype/fill/prop-desc.js | 21 + .../fill/return-abrupt-from-end-as-symbol.js | 24 + .../Array/prototype/fill/return-abrupt-from-end.js | 27 + .../return-abrupt-from-setting-property-value.js | 36 + .../fill/return-abrupt-from-start-as-symbol.js | 23 + .../prototype/fill/return-abrupt-from-start.js | 26 + .../return-abrupt-from-this-length-as-symbol.js | 26 + .../fill/return-abrupt-from-this-length.js | 39 + .../prototype/fill/return-abrupt-from-this.js | 22 + .../built-ins/Array/prototype/fill/return-this.js | 22 + .../built-ins/Array/prototype/fill/shell.js | 0 .../Array/prototype/filter/15.4.4.20-1-1.js | 14 + .../Array/prototype/filter/15.4.4.20-1-10.js | 19 + .../Array/prototype/filter/15.4.4.20-1-11.js | 21 + .../Array/prototype/filter/15.4.4.20-1-12.js | 21 + .../Array/prototype/filter/15.4.4.20-1-13.js | 19 + .../Array/prototype/filter/15.4.4.20-1-14.js | 21 + .../Array/prototype/filter/15.4.4.20-1-15.js | 22 + .../Array/prototype/filter/15.4.4.20-1-2.js | 14 + .../Array/prototype/filter/15.4.4.20-1-3.js | 20 + .../Array/prototype/filter/15.4.4.20-1-4.js | 23 + .../Array/prototype/filter/15.4.4.20-1-5.js | 20 + .../Array/prototype/filter/15.4.4.20-1-6.js | 23 + .../Array/prototype/filter/15.4.4.20-1-7.js | 17 + .../Array/prototype/filter/15.4.4.20-1-8.js | 18 + .../Array/prototype/filter/15.4.4.20-1-9.js | 24 + .../Array/prototype/filter/15.4.4.20-10-1.js | 24 + .../Array/prototype/filter/15.4.4.20-10-2.js | 26 + .../Array/prototype/filter/15.4.4.20-10-3.js | 24 + .../Array/prototype/filter/15.4.4.20-10-4.js | 23 + .../Array/prototype/filter/15.4.4.20-2-1.js | 26 + .../Array/prototype/filter/15.4.4.20-2-10.js | 36 + .../Array/prototype/filter/15.4.4.20-2-11.js | 32 + .../Array/prototype/filter/15.4.4.20-2-12.js | 39 + .../Array/prototype/filter/15.4.4.20-2-13.js | 36 + .../Array/prototype/filter/15.4.4.20-2-14.js | 28 + .../Array/prototype/filter/15.4.4.20-2-17.js | 22 + .../Array/prototype/filter/15.4.4.20-2-18.js | 21 + .../Array/prototype/filter/15.4.4.20-2-19.js | 26 + .../Array/prototype/filter/15.4.4.20-2-2.js | 17 + .../Array/prototype/filter/15.4.4.20-2-3.js | 32 + .../Array/prototype/filter/15.4.4.20-2-4.js | 23 + .../Array/prototype/filter/15.4.4.20-2-5.js | 40 + .../Array/prototype/filter/15.4.4.20-2-6.js | 31 + .../Array/prototype/filter/15.4.4.20-2-7.js | 32 + .../Array/prototype/filter/15.4.4.20-2-8.js | 39 + .../Array/prototype/filter/15.4.4.20-2-9.js | 45 + .../Array/prototype/filter/15.4.4.20-3-1.js | 26 + .../Array/prototype/filter/15.4.4.20-3-10.js | 28 + .../Array/prototype/filter/15.4.4.20-3-11.js | 26 + .../Array/prototype/filter/15.4.4.20-3-12.js | 26 + .../Array/prototype/filter/15.4.4.20-3-13.js | 26 + .../Array/prototype/filter/15.4.4.20-3-14.js | 26 + .../Array/prototype/filter/15.4.4.20-3-15.js | 26 + .../Array/prototype/filter/15.4.4.20-3-16.js | 26 + .../Array/prototype/filter/15.4.4.20-3-17.js | 26 + .../Array/prototype/filter/15.4.4.20-3-18.js | 28 + .../Array/prototype/filter/15.4.4.20-3-19.js | 30 + .../Array/prototype/filter/15.4.4.20-3-2.js | 25 + .../Array/prototype/filter/15.4.4.20-3-20.js | 30 + .../Array/prototype/filter/15.4.4.20-3-21.js | 41 + .../Array/prototype/filter/15.4.4.20-3-22.js | 43 + .../Array/prototype/filter/15.4.4.20-3-23.js | 48 + .../Array/prototype/filter/15.4.4.20-3-24.js | 26 + .../Array/prototype/filter/15.4.4.20-3-25.js | 26 + .../Array/prototype/filter/15.4.4.20-3-3.js | 25 + .../Array/prototype/filter/15.4.4.20-3-4.js | 27 + .../Array/prototype/filter/15.4.4.20-3-5.js | 27 + .../Array/prototype/filter/15.4.4.20-3-6.js | 26 + .../Array/prototype/filter/15.4.4.20-3-7.js | 25 + .../Array/prototype/filter/15.4.4.20-3-9.js | 28 + .../Array/prototype/filter/15.4.4.20-4-1.js | 14 + .../Array/prototype/filter/15.4.4.20-4-10.js | 27 + .../Array/prototype/filter/15.4.4.20-4-11.js | 31 + .../Array/prototype/filter/15.4.4.20-4-12.js | 21 + .../Array/prototype/filter/15.4.4.20-4-15.js | 36 + .../Array/prototype/filter/15.4.4.20-4-2.js | 16 + .../Array/prototype/filter/15.4.4.20-4-3.js | 14 + .../Array/prototype/filter/15.4.4.20-4-4.js | 14 + .../Array/prototype/filter/15.4.4.20-4-5.js | 14 + .../Array/prototype/filter/15.4.4.20-4-6.js | 14 + .../Array/prototype/filter/15.4.4.20-4-7.js | 16 + .../Array/prototype/filter/15.4.4.20-4-8.js | 30 + .../Array/prototype/filter/15.4.4.20-4-9.js | 34 + .../Array/prototype/filter/15.4.4.20-5-1-s.js | 22 + .../Array/prototype/filter/15.4.4.20-5-1.js | 23 + .../Array/prototype/filter/15.4.4.20-5-10.js | 23 + .../Array/prototype/filter/15.4.4.20-5-11.js | 22 + .../Array/prototype/filter/15.4.4.20-5-12.js | 22 + .../Array/prototype/filter/15.4.4.20-5-13.js | 22 + .../Array/prototype/filter/15.4.4.20-5-14.js | 21 + .../Array/prototype/filter/15.4.4.20-5-15.js | 23 + .../Array/prototype/filter/15.4.4.20-5-16.js | 23 + .../Array/prototype/filter/15.4.4.20-5-17.js | 21 + .../Array/prototype/filter/15.4.4.20-5-18.js | 22 + .../Array/prototype/filter/15.4.4.20-5-19.js | 28 + .../Array/prototype/filter/15.4.4.20-5-2.js | 23 + .../Array/prototype/filter/15.4.4.20-5-21.js | 23 + .../Array/prototype/filter/15.4.4.20-5-22.js | 21 + .../Array/prototype/filter/15.4.4.20-5-23.js | 21 + .../Array/prototype/filter/15.4.4.20-5-24.js | 21 + .../Array/prototype/filter/15.4.4.20-5-27.js | 15 + .../Array/prototype/filter/15.4.4.20-5-28.js | 13 + .../Array/prototype/filter/15.4.4.20-5-29.js | 13 + .../Array/prototype/filter/15.4.4.20-5-3.js | 23 + .../Array/prototype/filter/15.4.4.20-5-30.js | 24 + .../Array/prototype/filter/15.4.4.20-5-4.js | 28 + .../Array/prototype/filter/15.4.4.20-5-5.js | 26 + .../Array/prototype/filter/15.4.4.20-5-6.js | 25 + .../Array/prototype/filter/15.4.4.20-5-7.js | 22 + .../Array/prototype/filter/15.4.4.20-5-9.js | 23 + .../Array/prototype/filter/15.4.4.20-6-1.js | 18 + .../Array/prototype/filter/15.4.4.20-6-2.js | 25 + .../Array/prototype/filter/15.4.4.20-6-3.js | 25 + .../Array/prototype/filter/15.4.4.20-6-4.js | 25 + .../Array/prototype/filter/15.4.4.20-6-5.js | 25 + .../Array/prototype/filter/15.4.4.20-6-6.js | 31 + .../Array/prototype/filter/15.4.4.20-6-7.js | 38 + .../Array/prototype/filter/15.4.4.20-6-8.js | 40 + .../Array/prototype/filter/15.4.4.20-9-1.js | 23 + .../Array/prototype/filter/15.4.4.20-9-2.js | 29 + .../Array/prototype/filter/15.4.4.20-9-3.js | 30 + .../Array/prototype/filter/15.4.4.20-9-4.js | 23 + .../Array/prototype/filter/15.4.4.20-9-5.js | 25 + .../Array/prototype/filter/15.4.4.20-9-6.js | 32 + .../Array/prototype/filter/15.4.4.20-9-7.js | 28 + .../Array/prototype/filter/15.4.4.20-9-8.js | 29 + .../Array/prototype/filter/15.4.4.20-9-9.js | 38 + .../Array/prototype/filter/15.4.4.20-9-b-1.js | 27 + .../Array/prototype/filter/15.4.4.20-9-b-10.js | 34 + .../Array/prototype/filter/15.4.4.20-9-b-11.js | 31 + .../Array/prototype/filter/15.4.4.20-9-b-12.js | 37 + .../Array/prototype/filter/15.4.4.20-9-b-13.js | 31 + .../Array/prototype/filter/15.4.4.20-9-b-14.js | 31 + .../Array/prototype/filter/15.4.4.20-9-b-15.js | 37 + .../Array/prototype/filter/15.4.4.20-9-b-16.js | 39 + .../Array/prototype/filter/15.4.4.20-9-b-2.js | 31 + .../Array/prototype/filter/15.4.4.20-9-b-3.js | 33 + .../Array/prototype/filter/15.4.4.20-9-b-4.js | 38 + .../Array/prototype/filter/15.4.4.20-9-b-5.js | 36 + .../Array/prototype/filter/15.4.4.20-9-b-6.js | 37 + .../Array/prototype/filter/15.4.4.20-9-b-7.js | 35 + .../Array/prototype/filter/15.4.4.20-9-b-8.js | 42 + .../Array/prototype/filter/15.4.4.20-9-b-9.js | 37 + .../Array/prototype/filter/15.4.4.20-9-c-i-1.js | 28 + .../Array/prototype/filter/15.4.4.20-9-c-i-10.js | 29 + .../Array/prototype/filter/15.4.4.20-9-c-i-11.js | 39 + .../Array/prototype/filter/15.4.4.20-9-c-i-12.js | 31 + .../Array/prototype/filter/15.4.4.20-9-c-i-13.js | 43 + .../Array/prototype/filter/15.4.4.20-9-c-i-14.js | 36 + .../Array/prototype/filter/15.4.4.20-9-c-i-15.js | 34 + .../Array/prototype/filter/15.4.4.20-9-c-i-16.js | 26 + .../Array/prototype/filter/15.4.4.20-9-c-i-17.js | 28 + .../Array/prototype/filter/15.4.4.20-9-c-i-18.js | 27 + .../Array/prototype/filter/15.4.4.20-9-c-i-19.js | 30 + .../Array/prototype/filter/15.4.4.20-9-c-i-2.js | 22 + .../Array/prototype/filter/15.4.4.20-9-c-i-20.js | 29 + .../Array/prototype/filter/15.4.4.20-9-c-i-21.js | 31 + .../Array/prototype/filter/15.4.4.20-9-c-i-22.js | 24 + .../Array/prototype/filter/15.4.4.20-9-c-i-25.js | 25 + .../Array/prototype/filter/15.4.4.20-9-c-i-26.js | 31 + .../Array/prototype/filter/15.4.4.20-9-c-i-27.js | 34 + .../Array/prototype/filter/15.4.4.20-9-c-i-28.js | 41 + .../Array/prototype/filter/15.4.4.20-9-c-i-29.js | 43 + .../Array/prototype/filter/15.4.4.20-9-c-i-3.js | 33 + .../Array/prototype/filter/15.4.4.20-9-c-i-30.js | 37 + .../Array/prototype/filter/15.4.4.20-9-c-i-31.js | 35 + .../Array/prototype/filter/15.4.4.20-9-c-i-4.js | 21 + .../Array/prototype/filter/15.4.4.20-9-c-i-5.js | 41 + .../Array/prototype/filter/15.4.4.20-9-c-i-6.js | 26 + .../Array/prototype/filter/15.4.4.20-9-c-i-7.js | 32 + .../Array/prototype/filter/15.4.4.20-9-c-i-8.js | 21 + .../Array/prototype/filter/15.4.4.20-9-c-i-9.js | 32 + .../Array/prototype/filter/15.4.4.20-9-c-ii-1.js | 27 + .../Array/prototype/filter/15.4.4.20-9-c-ii-10.js | 19 + .../Array/prototype/filter/15.4.4.20-9-c-ii-11.js | 19 + .../Array/prototype/filter/15.4.4.20-9-c-ii-12.js | 19 + .../Array/prototype/filter/15.4.4.20-9-c-ii-13.js | 19 + .../Array/prototype/filter/15.4.4.20-9-c-ii-16.js | 24 + .../Array/prototype/filter/15.4.4.20-9-c-ii-17.js | 24 + .../Array/prototype/filter/15.4.4.20-9-c-ii-18.js | 24 + .../Array/prototype/filter/15.4.4.20-9-c-ii-19.js | 27 + .../Array/prototype/filter/15.4.4.20-9-c-ii-2.js | 25 + .../Array/prototype/filter/15.4.4.20-9-c-ii-20.js | 28 + .../Array/prototype/filter/15.4.4.20-9-c-ii-21.js | 34 + .../Array/prototype/filter/15.4.4.20-9-c-ii-22.js | 34 + .../Array/prototype/filter/15.4.4.20-9-c-ii-23.js | 25 + .../Array/prototype/filter/15.4.4.20-9-c-ii-4.js | 28 + .../Array/prototype/filter/15.4.4.20-9-c-ii-5.js | 34 + .../Array/prototype/filter/15.4.4.20-9-c-ii-6.js | 29 + .../Array/prototype/filter/15.4.4.20-9-c-ii-7.js | 32 + .../Array/prototype/filter/15.4.4.20-9-c-ii-8.js | 29 + .../Array/prototype/filter/15.4.4.20-9-c-ii-9.js | 19 + .../prototype/filter/15.4.4.20-9-c-iii-1-1.js | 25 + .../prototype/filter/15.4.4.20-9-c-iii-1-2.js | 27 + .../prototype/filter/15.4.4.20-9-c-iii-1-3.js | 33 + .../prototype/filter/15.4.4.20-9-c-iii-1-4.js | 28 + .../prototype/filter/15.4.4.20-9-c-iii-1-5.js | 29 + .../prototype/filter/15.4.4.20-9-c-iii-1-6.js | 35 + .../Array/prototype/filter/15.4.4.20-9-c-iii-1.js | 29 + .../Array/prototype/filter/15.4.4.20-9-c-iii-10.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-11.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-12.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-13.js | 23 + .../Array/prototype/filter/15.4.4.20-9-c-iii-14.js | 23 + .../Array/prototype/filter/15.4.4.20-9-c-iii-15.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-16.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-17.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-18.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-19.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-2.js | 26 + .../Array/prototype/filter/15.4.4.20-9-c-iii-20.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-21.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-22.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-23.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-24.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-25.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-26.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-28.js | 22 + .../Array/prototype/filter/15.4.4.20-9-c-iii-29.js | 30 + .../Array/prototype/filter/15.4.4.20-9-c-iii-3.js | 26 + .../Array/prototype/filter/15.4.4.20-9-c-iii-30.js | 20 + .../Array/prototype/filter/15.4.4.20-9-c-iii-4.js | 28 + .../Array/prototype/filter/15.4.4.20-9-c-iii-5.js | 25 + .../Array/prototype/filter/15.4.4.20-9-c-iii-6.js | 23 + .../Array/prototype/filter/15.4.4.20-9-c-iii-7.js | 23 + .../Array/prototype/filter/15.4.4.20-9-c-iii-8.js | 23 + .../Array/prototype/filter/15.4.4.20-9-c-iii-9.js | 20 + .../built-ins/Array/prototype/filter/browser.js | 0 .../Array/prototype/filter/call-with-boolean.js | 21 + .../filter/callbackfn-resize-arraybuffer.js | 74 + .../prototype/filter/create-ctor-non-object.js | 53 + .../Array/prototype/filter/create-ctor-poisoned.js | 34 + .../Array/prototype/filter/create-non-array.js | 36 + .../filter/create-proto-from-ctor-realm-array.js | 45 + .../create-proto-from-ctor-realm-non-array.js | 46 + .../Array/prototype/filter/create-proxy.js | 41 + .../Array/prototype/filter/create-revoked-proxy.js | 46 + .../prototype/filter/create-species-abrupt.js | 40 + .../prototype/filter/create-species-non-ctor.js | 46 + .../Array/prototype/filter/create-species-null.js | 35 + .../prototype/filter/create-species-poisoned.js | 39 + .../Array/prototype/filter/create-species-undef.js | 36 + .../Array/prototype/filter/create-species.js | 45 + .../built-ins/Array/prototype/filter/length.js | 32 + .../built-ins/Array/prototype/filter/name.js | 28 + .../Array/prototype/filter/not-a-constructor.js | 35 + .../built-ins/Array/prototype/filter/prop-desc.js | 23 + .../built-ins/Array/prototype/filter/shell.js | 161 ++ .../filter/target-array-non-extensible.js | 44 + .../target-array-with-non-configurable-property.js | 46 + .../target-array-with-non-writable-property.js | 39 + .../prototype/find/array-altered-during-loop.js | 49 + .../built-ins/Array/prototype/find/browser.js | 0 .../Array/prototype/find/call-with-boolean.js | 20 + .../find/callbackfn-resize-arraybuffer.js | 76 + .../built-ins/Array/prototype/find/length.js | 20 + .../test262/built-ins/Array/prototype/find/name.js | 24 + .../Array/prototype/find/not-a-constructor.js | 31 + .../prototype/find/predicate-call-parameters.js | 48 + .../find/predicate-call-this-non-strict.js | 34 + .../find/predicate-call-this-strict-strict.js | 35 + .../predicate-called-for-each-array-property.js | 28 + .../find/predicate-is-not-callable-throws.js | 51 + .../find/predicate-not-called-on-empty-array.js | 31 + .../built-ins/Array/prototype/find/prop-desc.js | 21 + .../find/return-abrupt-from-predicate-call.js | 27 + .../prototype/find/return-abrupt-from-property.js | 33 + .../return-abrupt-from-this-length-as-symbol.js | 26 + .../find/return-abrupt-from-this-length.js | 40 + .../prototype/find/return-abrupt-from-this.js | 23 + .../return-found-value-predicate-result-is-true.js | 65 + ...n-undefined-if-predicate-returns-false-value.js | 55 + .../built-ins/Array/prototype/find/shell.js | 161 ++ .../findIndex/array-altered-during-loop.js | 49 + .../built-ins/Array/prototype/findIndex/browser.js | 0 .../Array/prototype/findIndex/call-with-boolean.js | 20 + .../findIndex/callbackfn-resize-arraybuffer.js | 76 + .../built-ins/Array/prototype/findIndex/length.js | 20 + .../built-ins/Array/prototype/findIndex/name.js | 24 + .../Array/prototype/findIndex/not-a-constructor.js | 35 + .../findIndex/predicate-call-parameters.js | 47 + .../findIndex/predicate-call-this-non-strict.js | 34 + .../findIndex/predicate-call-this-strict-strict.js | 35 + .../predicate-called-for-each-array-property.js | 28 + .../findIndex/predicate-is-not-callable-throws.js | 51 + .../predicate-not-called-on-empty-array.js | 37 + .../Array/prototype/findIndex/prop-desc.js | 21 + .../findIndex/return-abrupt-from-predicate-call.js | 27 + .../findIndex/return-abrupt-from-property.js | 33 + .../return-abrupt-from-this-length-as-symbol.js | 27 + .../findIndex/return-abrupt-from-this-length.js | 40 + .../prototype/findIndex/return-abrupt-from-this.js | 23 + .../return-index-predicate-result-is-true.js | 65 + ...egative-one-if-predicate-returns-false-value.js | 55 + .../built-ins/Array/prototype/findIndex/shell.js | 161 ++ .../findLast/array-altered-during-loop.js | 49 + .../built-ins/Array/prototype/findLast/browser.js | 0 .../Array/prototype/findLast/call-with-boolean.js | 21 + .../findLast/callbackfn-resize-arraybuffer.js | 76 + .../built-ins/Array/prototype/findLast/length.js | 23 + .../Array/prototype/findLast/maximum-index.js | 38 + .../built-ins/Array/prototype/findLast/name.js | 27 + .../Array/prototype/findLast/not-a-constructor.js | 31 + .../findLast/predicate-call-parameters.js | 48 + .../findLast/predicate-call-this-non-strict.js | 35 + .../findLast/predicate-call-this-strict-strict.js | 36 + .../predicate-called-for-each-array-property.js | 28 + .../findLast/predicate-is-not-callable-throws.js | 52 + .../predicate-not-called-on-empty-array.js | 32 + .../Array/prototype/findLast/prop-desc.js | 24 + .../findLast/return-abrupt-from-predicate-call.js | 28 + .../findLast/return-abrupt-from-property.js | 35 + .../return-abrupt-from-this-length-as-symbol.js | 25 + .../findLast/return-abrupt-from-this-length.js | 39 + .../prototype/findLast/return-abrupt-from-this.js | 23 + .../return-found-value-predicate-result-is-true.js | 64 + ...n-undefined-if-predicate-returns-false-value.js | 55 + .../built-ins/Array/prototype/findLast/shell.js | 161 ++ .../findLastIndex/array-altered-during-loop.js | 49 + .../Array/prototype/findLastIndex/browser.js | 0 .../prototype/findLastIndex/call-with-boolean.js | 21 + .../findLastIndex/callbackfn-resize-arraybuffer.js | 76 + .../Array/prototype/findLastIndex/length.js | 23 + .../Array/prototype/findLastIndex/maximum-index.js | 38 + .../Array/prototype/findLastIndex/name.js | 27 + .../prototype/findLastIndex/not-a-constructor.js | 35 + .../findLastIndex/predicate-call-parameters.js | 47 + .../predicate-call-this-non-strict.js | 35 + .../predicate-call-this-strict-strict.js | 36 + .../predicate-called-for-each-array-property.js | 28 + .../predicate-is-not-callable-throws.js | 52 + .../predicate-not-called-on-empty-array.js | 37 + .../Array/prototype/findLastIndex/prop-desc.js | 24 + .../return-abrupt-from-predicate-call.js | 28 + .../findLastIndex/return-abrupt-from-property.js | 33 + .../return-abrupt-from-this-length-as-symbol.js | 25 + .../return-abrupt-from-this-length.js | 39 + .../findLastIndex/return-abrupt-from-this.js | 23 + .../return-index-predicate-result-is-true.js | 64 + ...egative-one-if-predicate-returns-false-value.js | 55 + .../Array/prototype/findLastIndex/shell.js | 161 ++ .../Array/prototype/flat/array-like-objects.js | 33 + .../Array/prototype/flat/bound-function-call.js | 19 + .../built-ins/Array/prototype/flat/browser.js | 0 .../Array/prototype/flat/call-with-boolean.js | 13 + .../Array/prototype/flat/empty-array-elements.js | 26 + .../Array/prototype/flat/empty-object-elements.js | 24 + .../built-ins/Array/prototype/flat/length.js | 23 + .../test262/built-ins/Array/prototype/flat/name.js | 24 + .../flat/non-numeric-depth-should-not-throw.js | 45 + .../Array/prototype/flat/non-object-ctor-throws.js | 37 + .../Array/prototype/flat/not-a-constructor.js | 31 + .../prototype/flat/null-undefined-elements.js | 34 + .../prototype/flat/null-undefined-input-throws.js | 24 + .../Array/prototype/flat/positive-infinity.js | 14 + .../built-ins/Array/prototype/flat/prop-desc.js | 24 + .../Array/prototype/flat/proxy-access-count.js | 38 + .../built-ins/Array/prototype/flat/shell.js | 0 .../flat/symbol-object-create-null-depth-throws.js | 20 + .../prototype/flat/target-array-non-extensible.js | 50 + .../target-array-with-non-configurable-property.js | 50 + .../target-array-with-non-writable-property.js | 52 + .../prototype/flatMap/array-like-objects-nested.js | 74 + .../flatMap/array-like-objects-poisoned-length.js | 62 + .../flatMap/array-like-objects-typedarrays.js | 52 + .../Array/prototype/flatMap/array-like-objects.js | 87 + .../prototype/flatMap/bound-function-argument.js | 16 + .../built-ins/Array/prototype/flatMap/browser.js | 0 .../Array/prototype/flatMap/call-with-boolean.js | 21 + .../Array/prototype/flatMap/depth-always-one.js | 25 + .../built-ins/Array/prototype/flatMap/length.js | 23 + .../built-ins/Array/prototype/flatMap/name.js | 23 + .../flatMap/non-callable-argument-throws.js | 52 + .../Array/prototype/flatMap/not-a-constructor.js | 35 + .../built-ins/Array/prototype/flatMap/prop-desc.js | 29 + .../Array/prototype/flatMap/proxy-access-count.js | 44 + .../built-ins/Array/prototype/flatMap/shell.js | 0 .../flatMap/target-array-non-extensible.js | 50 + .../target-array-with-non-configurable-property.js | 54 + .../target-array-with-non-writable-property.js | 56 + .../flatMap/this-value-ctor-non-object.js | 84 + .../this-value-ctor-object-species-bad-throws.js | 139 ++ ...r-object-species-custom-ctor-poisoned-throws.js | 60 + .../this-value-ctor-object-species-custom-ctor.js | 96 + .../flatMap/this-value-ctor-object-species.js | 159 ++ .../flatMap/this-value-null-undefined-throws.js | 27 + .../prototype/flatMap/thisArg-argument-strict.js | 48 + .../Array/prototype/forEach/15.4.4.18-1-1.js | 14 + .../Array/prototype/forEach/15.4.4.18-1-10.js | 21 + .../Array/prototype/forEach/15.4.4.18-1-11.js | 23 + .../Array/prototype/forEach/15.4.4.18-1-12.js | 23 + .../Array/prototype/forEach/15.4.4.18-1-13.js | 21 + .../Array/prototype/forEach/15.4.4.18-1-14.js | 23 + .../Array/prototype/forEach/15.4.4.18-1-15.js | 23 + .../Array/prototype/forEach/15.4.4.18-1-2.js | 14 + .../Array/prototype/forEach/15.4.4.18-1-3.js | 22 + .../Array/prototype/forEach/15.4.4.18-1-4.js | 24 + .../Array/prototype/forEach/15.4.4.18-1-5.js | 22 + .../Array/prototype/forEach/15.4.4.18-1-6.js | 24 + .../Array/prototype/forEach/15.4.4.18-1-7.js | 19 + .../Array/prototype/forEach/15.4.4.18-1-8.js | 20 + .../Array/prototype/forEach/15.4.4.18-1-9.js | 25 + .../Array/prototype/forEach/15.4.4.18-2-1.js | 28 + .../Array/prototype/forEach/15.4.4.18-2-10.js | 38 + .../Array/prototype/forEach/15.4.4.18-2-11.js | 30 + .../Array/prototype/forEach/15.4.4.18-2-12.js | 38 + .../Array/prototype/forEach/15.4.4.18-2-13.js | 34 + .../Array/prototype/forEach/15.4.4.18-2-14.js | 26 + .../Array/prototype/forEach/15.4.4.18-2-17.js | 25 + .../Array/prototype/forEach/15.4.4.18-2-18.js | 23 + .../Array/prototype/forEach/15.4.4.18-2-19.js | 28 + .../Array/prototype/forEach/15.4.4.18-2-2.js | 19 + .../Array/prototype/forEach/15.4.4.18-2-3.js | 34 + .../Array/prototype/forEach/15.4.4.18-2-4.js | 24 + .../Array/prototype/forEach/15.4.4.18-2-5.js | 42 + .../Array/prototype/forEach/15.4.4.18-2-6.js | 33 + .../Array/prototype/forEach/15.4.4.18-2-7.js | 34 + .../Array/prototype/forEach/15.4.4.18-2-8.js | 41 + .../Array/prototype/forEach/15.4.4.18-2-9.js | 47 + .../Array/prototype/forEach/15.4.4.18-3-1.js | 25 + .../Array/prototype/forEach/15.4.4.18-3-10.js | 26 + .../Array/prototype/forEach/15.4.4.18-3-11.js | 28 + .../Array/prototype/forEach/15.4.4.18-3-12.js | 28 + .../Array/prototype/forEach/15.4.4.18-3-13.js | 27 + .../Array/prototype/forEach/15.4.4.18-3-14.js | 25 + .../Array/prototype/forEach/15.4.4.18-3-15.js | 28 + .../Array/prototype/forEach/15.4.4.18-3-16.js | 28 + .../Array/prototype/forEach/15.4.4.18-3-17.js | 28 + .../Array/prototype/forEach/15.4.4.18-3-18.js | 27 + .../Array/prototype/forEach/15.4.4.18-3-19.js | 32 + .../Array/prototype/forEach/15.4.4.18-3-2.js | 28 + .../Array/prototype/forEach/15.4.4.18-3-20.js | 32 + .../Array/prototype/forEach/15.4.4.18-3-21.js | 42 + .../Array/prototype/forEach/15.4.4.18-3-22.js | 41 + .../Array/prototype/forEach/15.4.4.18-3-23.js | 50 + .../Array/prototype/forEach/15.4.4.18-3-24.js | 28 + .../Array/prototype/forEach/15.4.4.18-3-25.js | 28 + .../Array/prototype/forEach/15.4.4.18-3-3.js | 28 + .../Array/prototype/forEach/15.4.4.18-3-4.js | 27 + .../Array/prototype/forEach/15.4.4.18-3-5.js | 27 + .../Array/prototype/forEach/15.4.4.18-3-6.js | 28 + .../Array/prototype/forEach/15.4.4.18-3-7.js | 28 + .../Array/prototype/forEach/15.4.4.18-3-9.js | 27 + .../Array/prototype/forEach/15.4.4.18-4-1.js | 15 + .../Array/prototype/forEach/15.4.4.18-4-10.js | 28 + .../Array/prototype/forEach/15.4.4.18-4-11.js | 32 + .../Array/prototype/forEach/15.4.4.18-4-12.js | 20 + .../Array/prototype/forEach/15.4.4.18-4-15.js | 39 + .../Array/prototype/forEach/15.4.4.18-4-2.js | 17 + .../Array/prototype/forEach/15.4.4.18-4-3.js | 15 + .../Array/prototype/forEach/15.4.4.18-4-4.js | 15 + .../Array/prototype/forEach/15.4.4.18-4-5.js | 15 + .../Array/prototype/forEach/15.4.4.18-4-6.js | 15 + .../Array/prototype/forEach/15.4.4.18-4-7.js | 16 + .../Array/prototype/forEach/15.4.4.18-4-8.js | 30 + .../Array/prototype/forEach/15.4.4.18-4-9.js | 34 + .../Array/prototype/forEach/15.4.4.18-5-1-s.js | 22 + .../Array/prototype/forEach/15.4.4.18-5-1.js | 24 + .../Array/prototype/forEach/15.4.4.18-5-10.js | 20 + .../Array/prototype/forEach/15.4.4.18-5-11.js | 20 + .../Array/prototype/forEach/15.4.4.18-5-12.js | 20 + .../Array/prototype/forEach/15.4.4.18-5-13.js | 20 + .../Array/prototype/forEach/15.4.4.18-5-14.js | 19 + .../Array/prototype/forEach/15.4.4.18-5-15.js | 20 + .../Array/prototype/forEach/15.4.4.18-5-16.js | 20 + .../Array/prototype/forEach/15.4.4.18-5-17.js | 19 + .../Array/prototype/forEach/15.4.4.18-5-18.js | 20 + .../Array/prototype/forEach/15.4.4.18-5-19.js | 26 + .../Array/prototype/forEach/15.4.4.18-5-2.js | 24 + .../Array/prototype/forEach/15.4.4.18-5-21.js | 20 + .../Array/prototype/forEach/15.4.4.18-5-22.js | 19 + .../Array/prototype/forEach/15.4.4.18-5-23.js | 19 + .../Array/prototype/forEach/15.4.4.18-5-24.js | 19 + .../Array/prototype/forEach/15.4.4.18-5-25.js | 25 + .../Array/prototype/forEach/15.4.4.18-5-3.js | 24 + .../Array/prototype/forEach/15.4.4.18-5-4.js | 27 + .../Array/prototype/forEach/15.4.4.18-5-5.js | 26 + .../Array/prototype/forEach/15.4.4.18-5-6.js | 25 + .../Array/prototype/forEach/15.4.4.18-5-7.js | 19 + .../Array/prototype/forEach/15.4.4.18-5-9.js | 20 + .../Array/prototype/forEach/15.4.4.18-7-1.js | 25 + .../Array/prototype/forEach/15.4.4.18-7-2.js | 25 + .../Array/prototype/forEach/15.4.4.18-7-3.js | 24 + .../Array/prototype/forEach/15.4.4.18-7-4.js | 26 + .../Array/prototype/forEach/15.4.4.18-7-5.js | 27 + .../Array/prototype/forEach/15.4.4.18-7-7.js | 25 + .../Array/prototype/forEach/15.4.4.18-7-8.js | 25 + .../Array/prototype/forEach/15.4.4.18-7-9.js | 35 + .../Array/prototype/forEach/15.4.4.18-7-b-1.js | 24 + .../Array/prototype/forEach/15.4.4.18-7-b-10.js | 40 + .../Array/prototype/forEach/15.4.4.18-7-b-11.js | 37 + .../Array/prototype/forEach/15.4.4.18-7-b-12.js | 39 + .../Array/prototype/forEach/15.4.4.18-7-b-13.js | 33 + .../Array/prototype/forEach/15.4.4.18-7-b-14.js | 36 + .../Array/prototype/forEach/15.4.4.18-7-b-15.js | 39 + .../Array/prototype/forEach/15.4.4.18-7-b-16.js | 41 + .../Array/prototype/forEach/15.4.4.18-7-b-2.js | 33 + .../Array/prototype/forEach/15.4.4.18-7-b-3.js | 38 + .../Array/prototype/forEach/15.4.4.18-7-b-4.js | 40 + .../Array/prototype/forEach/15.4.4.18-7-b-5.js | 38 + .../Array/prototype/forEach/15.4.4.18-7-b-6.js | 40 + .../Array/prototype/forEach/15.4.4.18-7-b-7.js | 38 + .../Array/prototype/forEach/15.4.4.18-7-b-8.js | 45 + .../Array/prototype/forEach/15.4.4.18-7-b-9.js | 43 + .../Array/prototype/forEach/15.4.4.18-7-c-i-1.js | 29 + .../Array/prototype/forEach/15.4.4.18-7-c-i-10.js | 32 + .../Array/prototype/forEach/15.4.4.18-7-c-i-11.js | 41 + .../Array/prototype/forEach/15.4.4.18-7-c-i-12.js | 34 + .../Array/prototype/forEach/15.4.4.18-7-c-i-13.js | 47 + .../Array/prototype/forEach/15.4.4.18-7-c-i-14.js | 39 + .../Array/prototype/forEach/15.4.4.18-7-c-i-15.js | 38 + .../Array/prototype/forEach/15.4.4.18-7-c-i-16.js | 30 + .../Array/prototype/forEach/15.4.4.18-7-c-i-17.js | 31 + .../Array/prototype/forEach/15.4.4.18-7-c-i-18.js | 30 + .../Array/prototype/forEach/15.4.4.18-7-c-i-19.js | 40 + .../Array/prototype/forEach/15.4.4.18-7-c-i-2.js | 23 + .../Array/prototype/forEach/15.4.4.18-7-c-i-20.js | 38 + .../Array/prototype/forEach/15.4.4.18-7-c-i-21.js | 35 + .../Array/prototype/forEach/15.4.4.18-7-c-i-22.js | 28 + .../Array/prototype/forEach/15.4.4.18-7-c-i-25.js | 28 + .../Array/prototype/forEach/15.4.4.18-7-c-i-26.js | 37 + .../Array/prototype/forEach/15.4.4.18-7-c-i-27.js | 39 + .../Array/prototype/forEach/15.4.4.18-7-c-i-28.js | 44 + .../Array/prototype/forEach/15.4.4.18-7-c-i-29.js | 46 + .../Array/prototype/forEach/15.4.4.18-7-c-i-3.js | 35 + .../Array/prototype/forEach/15.4.4.18-7-c-i-30.js | 44 + .../Array/prototype/forEach/15.4.4.18-7-c-i-31.js | 42 + .../Array/prototype/forEach/15.4.4.18-7-c-i-4.js | 25 + .../Array/prototype/forEach/15.4.4.18-7-c-i-5.js | 43 + .../Array/prototype/forEach/15.4.4.18-7-c-i-6.js | 30 + .../Array/prototype/forEach/15.4.4.18-7-c-i-7.js | 34 + .../Array/prototype/forEach/15.4.4.18-7-c-i-8.js | 25 + .../Array/prototype/forEach/15.4.4.18-7-c-i-9.js | 35 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-1.js | 26 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-10.js | 21 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-11.js | 21 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-12.js | 21 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-13.js | 19 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-16.js | 26 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-17.js | 26 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-18.js | 26 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-19.js | 31 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-2.js | 25 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-20.js | 30 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-21.js | 36 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-22.js | 36 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-23.js | 25 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-4.js | 30 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-5.js | 32 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-6.js | 29 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-7.js | 33 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-8.js | 32 + .../Array/prototype/forEach/15.4.4.18-7-c-ii-9.js | 21 + .../Array/prototype/forEach/15.4.4.18-8-1.js | 20 + .../Array/prototype/forEach/15.4.4.18-8-10.js | 24 + .../Array/prototype/forEach/15.4.4.18-8-11.js | 24 + .../Array/prototype/forEach/15.4.4.18-8-12.js | 23 + .../Array/prototype/forEach/15.4.4.18-8-13.js | 22 + .../Array/prototype/forEach/15.4.4.18-8-2.js | 26 + .../Array/prototype/forEach/15.4.4.18-8-3.js | 26 + .../Array/prototype/forEach/15.4.4.18-8-4.js | 26 + .../Array/prototype/forEach/15.4.4.18-8-5.js | 26 + .../Array/prototype/forEach/15.4.4.18-8-6.js | 32 + .../Array/prototype/forEach/15.4.4.18-8-7.js | 38 + .../Array/prototype/forEach/15.4.4.18-8-8.js | 40 + .../Array/prototype/forEach/15.4.4.18-8-9.js | 41 + .../Array/prototype/forEach/S15.4.4.18_A1.js | 14 + .../Array/prototype/forEach/S15.4.4.18_A2.js | 17 + .../built-ins/Array/prototype/forEach/browser.js | 0 .../Array/prototype/forEach/call-with-boolean.js | 20 + .../forEach/callbackfn-resize-arraybuffer.js | 72 + .../built-ins/Array/prototype/forEach/length.js | 32 + .../built-ins/Array/prototype/forEach/name.js | 28 + .../Array/prototype/forEach/not-a-constructor.js | 35 + .../built-ins/Array/prototype/forEach/prop-desc.js | 23 + .../built-ins/Array/prototype/forEach/shell.js | 161 ++ .../built-ins/Array/prototype/includes/browser.js | 0 .../Array/prototype/includes/call-with-boolean.js | 17 + ...mIndex-equal-or-greater-length-returns-false.js | 26 + .../Array/prototype/includes/fromIndex-infinity.js | 37 + .../prototype/includes/fromIndex-minus-zero.js | 24 + .../built-ins/Array/prototype/includes/get-prop.js | 48 + .../Array/prototype/includes/length-boundaries.js | 85 + .../includes/length-zero-returns-false.js | 30 + .../built-ins/Array/prototype/includes/length.js | 32 + .../built-ins/Array/prototype/includes/name.js | 29 + .../built-ins/Array/prototype/includes/no-arg.js | 22 + .../Array/prototype/includes/not-a-constructor.js | 35 + .../Array/prototype/includes/prop-desc.js | 19 + .../prototype/includes/return-abrupt-get-length.js | 28 + .../prototype/includes/return-abrupt-get-prop.js | 41 + .../return-abrupt-tointeger-fromindex-symbol.js | 25 + .../includes/return-abrupt-tointeger-fromindex.js | 29 + .../return-abrupt-tonumber-length-symbol.js | 24 + .../includes/return-abrupt-tonumber-length.js | 40 + .../Array/prototype/includes/samevaluezero.js | 30 + .../includes/search-found-returns-true.js | 43 + .../includes/search-not-found-returns-false.js | 45 + .../built-ins/Array/prototype/includes/shell.js | 0 .../built-ins/Array/prototype/includes/sparse.js | 54 + .../Array/prototype/includes/this-is-not-object.js | 25 + .../prototype/includes/tointeger-fromindex.js | 55 + .../Array/prototype/includes/tolength-length.js | 90 + .../Array/prototype/includes/using-fromindex.js | 52 + .../prototype/includes/values-are-not-cached.js | 46 + .../Array/prototype/indexOf/15.4.4.14-1-1.js | 14 + .../Array/prototype/indexOf/15.4.4.14-1-10.js | 14 + .../Array/prototype/indexOf/15.4.4.14-1-11.js | 15 + .../Array/prototype/indexOf/15.4.4.14-1-12.js | 15 + .../Array/prototype/indexOf/15.4.4.14-1-13.js | 16 + .../Array/prototype/indexOf/15.4.4.14-1-14.js | 15 + .../Array/prototype/indexOf/15.4.4.14-1-15.js | 16 + .../Array/prototype/indexOf/15.4.4.14-1-2.js | 14 + .../Array/prototype/indexOf/15.4.4.14-1-3.js | 16 + .../Array/prototype/indexOf/15.4.4.14-1-4.js | 15 + .../Array/prototype/indexOf/15.4.4.14-1-5.js | 16 + .../Array/prototype/indexOf/15.4.4.14-1-6.js | 15 + .../Array/prototype/indexOf/15.4.4.14-1-7.js | 11 + .../Array/prototype/indexOf/15.4.4.14-1-8.js | 13 + .../Array/prototype/indexOf/15.4.4.14-1-9.js | 16 + .../Array/prototype/indexOf/15.4.4.14-10-1.js | 31 + .../Array/prototype/indexOf/15.4.4.14-10-2.js | 29 + .../Array/prototype/indexOf/15.4.4.14-2-1.js | 23 + .../Array/prototype/indexOf/15.4.4.14-2-10.js | 28 + .../Array/prototype/indexOf/15.4.4.14-2-11.js | 21 + .../Array/prototype/indexOf/15.4.4.14-2-12.js | 29 + .../Array/prototype/indexOf/15.4.4.14-2-13.js | 25 + .../Array/prototype/indexOf/15.4.4.14-2-14.js | 16 + .../Array/prototype/indexOf/15.4.4.14-2-17.js | 19 + .../Array/prototype/indexOf/15.4.4.14-2-18.js | 18 + .../Array/prototype/indexOf/15.4.4.14-2-19.js | 20 + .../Array/prototype/indexOf/15.4.4.14-2-2.js | 17 + .../Array/prototype/indexOf/15.4.4.14-2-3.js | 24 + .../Array/prototype/indexOf/15.4.4.14-2-4.js | 19 + .../Array/prototype/indexOf/15.4.4.14-2-5.js | 32 + .../Array/prototype/indexOf/15.4.4.14-2-6.js | 24 + .../Array/prototype/indexOf/15.4.4.14-2-7.js | 31 + .../Array/prototype/indexOf/15.4.4.14-2-8.js | 30 + .../Array/prototype/indexOf/15.4.4.14-2-9.js | 34 + .../Array/prototype/indexOf/15.4.4.14-3-1.js | 17 + .../Array/prototype/indexOf/15.4.4.14-3-10.js | 18 + .../Array/prototype/indexOf/15.4.4.14-3-11.js | 20 + .../Array/prototype/indexOf/15.4.4.14-3-12.js | 20 + .../Array/prototype/indexOf/15.4.4.14-3-13.js | 20 + .../Array/prototype/indexOf/15.4.4.14-3-14.js | 31 + .../Array/prototype/indexOf/15.4.4.14-3-15.js | 20 + .../Array/prototype/indexOf/15.4.4.14-3-16.js | 20 + .../Array/prototype/indexOf/15.4.4.14-3-17.js | 20 + .../Array/prototype/indexOf/15.4.4.14-3-18.js | 19 + .../Array/prototype/indexOf/15.4.4.14-3-19.js | 31 + .../Array/prototype/indexOf/15.4.4.14-3-2.js | 20 + .../Array/prototype/indexOf/15.4.4.14-3-20.js | 25 + .../Array/prototype/indexOf/15.4.4.14-3-21.js | 34 + .../Array/prototype/indexOf/15.4.4.14-3-22.js | 36 + .../Array/prototype/indexOf/15.4.4.14-3-23.js | 40 + .../Array/prototype/indexOf/15.4.4.14-3-24.js | 20 + .../Array/prototype/indexOf/15.4.4.14-3-25.js | 20 + .../Array/prototype/indexOf/15.4.4.14-3-28.js | 21 + .../Array/prototype/indexOf/15.4.4.14-3-29.js | 21 + .../Array/prototype/indexOf/15.4.4.14-3-3.js | 18 + .../Array/prototype/indexOf/15.4.4.14-3-4.js | 18 + .../Array/prototype/indexOf/15.4.4.14-3-5.js | 18 + .../Array/prototype/indexOf/15.4.4.14-3-6.js | 20 + .../Array/prototype/indexOf/15.4.4.14-3-7.js | 20 + .../Array/prototype/indexOf/15.4.4.14-3-8.js | 18 + .../Array/prototype/indexOf/15.4.4.14-3-9.js | 18 + .../Array/prototype/indexOf/15.4.4.14-4-1.js | 13 + .../Array/prototype/indexOf/15.4.4.14-4-10.js | 18 + .../Array/prototype/indexOf/15.4.4.14-4-11.js | 18 + .../Array/prototype/indexOf/15.4.4.14-4-2.js | 18 + .../Array/prototype/indexOf/15.4.4.14-4-3.js | 18 + .../Array/prototype/indexOf/15.4.4.14-4-4.js | 18 + .../Array/prototype/indexOf/15.4.4.14-4-5.js | 18 + .../Array/prototype/indexOf/15.4.4.14-4-6.js | 22 + .../Array/prototype/indexOf/15.4.4.14-4-7.js | 27 + .../Array/prototype/indexOf/15.4.4.14-4-8.js | 31 + .../Array/prototype/indexOf/15.4.4.14-4-9.js | 18 + .../Array/prototype/indexOf/15.4.4.14-5-1.js | 14 + .../Array/prototype/indexOf/15.4.4.14-5-10.js | 16 + .../Array/prototype/indexOf/15.4.4.14-5-11.js | 16 + .../Array/prototype/indexOf/15.4.4.14-5-12.js | 16 + .../Array/prototype/indexOf/15.4.4.14-5-13.js | 13 + .../Array/prototype/indexOf/15.4.4.14-5-14.js | 14 + .../Array/prototype/indexOf/15.4.4.14-5-15.js | 14 + .../Array/prototype/indexOf/15.4.4.14-5-16.js | 16 + .../Array/prototype/indexOf/15.4.4.14-5-17.js | 13 + .../Array/prototype/indexOf/15.4.4.14-5-18.js | 16 + .../Array/prototype/indexOf/15.4.4.14-5-19.js | 16 + .../Array/prototype/indexOf/15.4.4.14-5-2.js | 15 + .../Array/prototype/indexOf/15.4.4.14-5-20.js | 16 + .../Array/prototype/indexOf/15.4.4.14-5-21.js | 24 + .../Array/prototype/indexOf/15.4.4.14-5-22.js | 20 + .../Array/prototype/indexOf/15.4.4.14-5-23.js | 31 + .../Array/prototype/indexOf/15.4.4.14-5-24.js | 33 + .../Array/prototype/indexOf/15.4.4.14-5-25.js | 35 + .../Array/prototype/indexOf/15.4.4.14-5-26.js | 39 + .../Array/prototype/indexOf/15.4.4.14-5-27.js | 43 + .../Array/prototype/indexOf/15.4.4.14-5-28.js | 23 + .../Array/prototype/indexOf/15.4.4.14-5-29.js | 32 + .../Array/prototype/indexOf/15.4.4.14-5-3.js | 14 + .../Array/prototype/indexOf/15.4.4.14-5-30.js | 36 + .../Array/prototype/indexOf/15.4.4.14-5-31.js | 16 + .../Array/prototype/indexOf/15.4.4.14-5-32.js | 16 + .../Array/prototype/indexOf/15.4.4.14-5-33.js | 17 + .../Array/prototype/indexOf/15.4.4.14-5-4.js | 14 + .../Array/prototype/indexOf/15.4.4.14-5-5.js | 14 + .../Array/prototype/indexOf/15.4.4.14-5-6.js | 16 + .../Array/prototype/indexOf/15.4.4.14-5-7.js | 13 + .../Array/prototype/indexOf/15.4.4.14-5-8.js | 13 + .../Array/prototype/indexOf/15.4.4.14-5-9.js | 13 + .../Array/prototype/indexOf/15.4.4.14-6-1.js | 17 + .../Array/prototype/indexOf/15.4.4.14-7-1.js | 13 + .../Array/prototype/indexOf/15.4.4.14-7-2.js | 13 + .../Array/prototype/indexOf/15.4.4.14-7-3.js | 13 + .../Array/prototype/indexOf/15.4.4.14-7-4.js | 11 + .../Array/prototype/indexOf/15.4.4.14-7-5.js | 11 + .../Array/prototype/indexOf/15.4.4.14-8-1.js | 17 + .../Array/prototype/indexOf/15.4.4.14-8-2.js | 13 + .../Array/prototype/indexOf/15.4.4.14-8-3.js | 13 + .../Array/prototype/indexOf/15.4.4.14-8-4.js | 13 + .../Array/prototype/indexOf/15.4.4.14-9-1.js | 20 + .../Array/prototype/indexOf/15.4.4.14-9-10.js | 21 + .../Array/prototype/indexOf/15.4.4.14-9-11.js | 23 + .../Array/prototype/indexOf/15.4.4.14-9-2.js | 23 + .../Array/prototype/indexOf/15.4.4.14-9-3.js | 19 + .../Array/prototype/indexOf/15.4.4.14-9-4.js | 20 + .../Array/prototype/indexOf/15.4.4.14-9-5.js | 28 + .../Array/prototype/indexOf/15.4.4.14-9-6.js | 19 + .../Array/prototype/indexOf/15.4.4.14-9-7.js | 15 + .../Array/prototype/indexOf/15.4.4.14-9-8.js | 15 + .../Array/prototype/indexOf/15.4.4.14-9-9.js | 22 + .../Array/prototype/indexOf/15.4.4.14-9-a-1.js | 23 + .../Array/prototype/indexOf/15.4.4.14-9-a-10.js | 28 + .../Array/prototype/indexOf/15.4.4.14-9-a-11.js | 32 + .../Array/prototype/indexOf/15.4.4.14-9-a-12.js | 30 + .../Array/prototype/indexOf/15.4.4.14-9-a-13.js | 28 + .../Array/prototype/indexOf/15.4.4.14-9-a-14.js | 25 + .../Array/prototype/indexOf/15.4.4.14-9-a-15.js | 31 + .../Array/prototype/indexOf/15.4.4.14-9-a-16.js | 25 + .../Array/prototype/indexOf/15.4.4.14-9-a-17.js | 23 + .../Array/prototype/indexOf/15.4.4.14-9-a-18.js | 30 + .../Array/prototype/indexOf/15.4.4.14-9-a-19.js | 32 + .../Array/prototype/indexOf/15.4.4.14-9-a-2.js | 26 + .../Array/prototype/indexOf/15.4.4.14-9-a-3.js | 24 + .../Array/prototype/indexOf/15.4.4.14-9-a-4.js | 25 + .../Array/prototype/indexOf/15.4.4.14-9-a-5.js | 25 + .../Array/prototype/indexOf/15.4.4.14-9-a-6.js | 24 + .../Array/prototype/indexOf/15.4.4.14-9-a-7.js | 30 + .../Array/prototype/indexOf/15.4.4.14-9-a-8.js | 28 + .../Array/prototype/indexOf/15.4.4.14-9-a-9.js | 30 + .../Array/prototype/indexOf/15.4.4.14-9-b-1.js | 11 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-1.js | 22 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-10.js | 39 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-11.js | 23 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-12.js | 26 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-13.js | 29 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-14.js | 32 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-15.js | 36 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-16.js | 42 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-17.js | 19 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-18.js | 21 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-19.js | 28 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-2.js | 15 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-20.js | 33 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-21.js | 18 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-22.js | 20 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-25.js | 19 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-26.js | 20 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-27.js | 20 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-28.js | 35 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-29.js | 37 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-3.js | 15 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-30.js | 33 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-31.js | 35 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-4.js | 20 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-5.js | 20 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-6.js | 25 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-7.js | 19 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-8.js | 25 + .../Array/prototype/indexOf/15.4.4.14-9-b-i-9.js | 37 + .../Array/prototype/indexOf/15.4.4.14-9-b-ii-1.js | 20 + .../Array/prototype/indexOf/15.4.4.14-9-b-ii-10.js | 13 + .../Array/prototype/indexOf/15.4.4.14-9-b-ii-11.js | 17 + .../Array/prototype/indexOf/15.4.4.14-9-b-ii-2.js | 14 + .../Array/prototype/indexOf/15.4.4.14-9-b-ii-3.js | 13 + .../Array/prototype/indexOf/15.4.4.14-9-b-ii-4.js | 11 + .../Array/prototype/indexOf/15.4.4.14-9-b-ii-5.js | 11 + .../Array/prototype/indexOf/15.4.4.14-9-b-ii-6.js | 13 + .../Array/prototype/indexOf/15.4.4.14-9-b-ii-7.js | 13 + .../Array/prototype/indexOf/15.4.4.14-9-b-ii-8.js | 13 + .../Array/prototype/indexOf/15.4.4.14-9-b-ii-9.js | 13 + .../Array/prototype/indexOf/15.4.4.14-9-b-iii-1.js | 13 + .../Array/prototype/indexOf/15.4.4.14-9-b-iii-2.js | 35 + .../built-ins/Array/prototype/indexOf/browser.js | 0 .../Array/prototype/indexOf/call-with-boolean.js | 12 + ...ls-only-has-on-prototype-after-length-zeroed.js | 45 + .../prototype/indexOf/fromindex-zero-conversion.js | 18 + .../prototype/indexOf/length-near-integer-limit.js | 37 + .../indexOf/length-zero-returns-minus-one.js | 24 + .../built-ins/Array/prototype/indexOf/length.js | 30 + .../built-ins/Array/prototype/indexOf/name.js | 28 + .../Array/prototype/indexOf/not-a-constructor.js | 35 + .../built-ins/Array/prototype/indexOf/prop-desc.js | 23 + .../built-ins/Array/prototype/indexOf/shell.js | 33 + .../Array/prototype/join/S15.4.4.5_A1.1_T1.js | 22 + .../Array/prototype/join/S15.4.4.5_A1.2_T1.js | 28 + .../Array/prototype/join/S15.4.4.5_A1.2_T2.js | 28 + .../Array/prototype/join/S15.4.4.5_A1.3_T1.js | 27 + .../Array/prototype/join/S15.4.4.5_A2_T1.js | 44 + .../Array/prototype/join/S15.4.4.5_A2_T2.js | 63 + .../Array/prototype/join/S15.4.4.5_A2_T3.js | 51 + .../Array/prototype/join/S15.4.4.5_A2_T4.js | 95 + .../Array/prototype/join/S15.4.4.5_A3.1_T1.js | 46 + .../Array/prototype/join/S15.4.4.5_A3.1_T2.js | 146 ++ .../Array/prototype/join/S15.4.4.5_A3.2_T1.js | 52 + .../Array/prototype/join/S15.4.4.5_A3.2_T2.js | 113 + .../Array/prototype/join/S15.4.4.5_A4_T3.js | 25 + .../Array/prototype/join/S15.4.4.5_A5_T1.js | 29 + .../Array/prototype/join/S15.4.4.5_A6.6.js | 14 + .../built-ins/Array/prototype/join/browser.js | 0 .../Array/prototype/join/call-with-boolean.js | 12 + .../built-ins/Array/prototype/join/length.js | 30 + .../test262/built-ins/Array/prototype/join/name.js | 28 + .../Array/prototype/join/not-a-constructor.js | 31 + .../built-ins/Array/prototype/join/prop-desc.js | 23 + .../built-ins/Array/prototype/join/shell.js | 0 .../built-ins/Array/prototype/keys/browser.js | 0 .../Array/prototype/keys/iteration-mutable.js | 41 + .../built-ins/Array/prototype/keys/iteration.js | 35 + .../built-ins/Array/prototype/keys/length.js | 24 + .../test262/built-ins/Array/prototype/keys/name.js | 24 + .../Array/prototype/keys/not-a-constructor.js | 31 + .../built-ins/Array/prototype/keys/prop-desc.js | 24 + .../prototype/keys/return-abrupt-from-this.js | 22 + .../prototype/keys/returns-iterator-from-object.js | 27 + .../Array/prototype/keys/returns-iterator.js | 32 + .../built-ins/Array/prototype/keys/shell.js | 0 .../Array/prototype/lastIndexOf/15.4.4.15-1-1.js | 14 + .../Array/prototype/lastIndexOf/15.4.4.15-1-10.js | 14 + .../Array/prototype/lastIndexOf/15.4.4.15-1-11.js | 15 + .../Array/prototype/lastIndexOf/15.4.4.15-1-12.js | 15 + .../Array/prototype/lastIndexOf/15.4.4.15-1-13.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-1-14.js | 15 + .../Array/prototype/lastIndexOf/15.4.4.15-1-15.js | 15 + .../Array/prototype/lastIndexOf/15.4.4.15-1-2.js | 14 + .../Array/prototype/lastIndexOf/15.4.4.15-1-3.js | 14 + .../Array/prototype/lastIndexOf/15.4.4.15-1-4.js | 15 + .../Array/prototype/lastIndexOf/15.4.4.15-1-5.js | 14 + .../Array/prototype/lastIndexOf/15.4.4.15-1-6.js | 15 + .../Array/prototype/lastIndexOf/15.4.4.15-1-7.js | 11 + .../Array/prototype/lastIndexOf/15.4.4.15-1-8.js | 13 + .../Array/prototype/lastIndexOf/15.4.4.15-1-9.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-2-1.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-2-10.js | 29 + .../Array/prototype/lastIndexOf/15.4.4.15-2-11.js | 21 + .../Array/prototype/lastIndexOf/15.4.4.15-2-12.js | 29 + .../Array/prototype/lastIndexOf/15.4.4.15-2-13.js | 25 + .../Array/prototype/lastIndexOf/15.4.4.15-2-14.js | 18 + .../Array/prototype/lastIndexOf/15.4.4.15-2-17.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-2-18.js | 18 + .../Array/prototype/lastIndexOf/15.4.4.15-2-19.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-2-2.js | 18 + .../Array/prototype/lastIndexOf/15.4.4.15-2-3.js | 24 + .../Array/prototype/lastIndexOf/15.4.4.15-2-4.js | 19 + .../Array/prototype/lastIndexOf/15.4.4.15-2-5.js | 32 + .../Array/prototype/lastIndexOf/15.4.4.15-2-6.js | 25 + .../Array/prototype/lastIndexOf/15.4.4.15-2-7.js | 26 + .../Array/prototype/lastIndexOf/15.4.4.15-2-8.js | 30 + .../Array/prototype/lastIndexOf/15.4.4.15-2-9.js | 35 + .../Array/prototype/lastIndexOf/15.4.4.15-3-1.js | 17 + .../Array/prototype/lastIndexOf/15.4.4.15-3-10.js | 18 + .../Array/prototype/lastIndexOf/15.4.4.15-3-11.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-3-12.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-3-13.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-3-14.js | 19 + .../Array/prototype/lastIndexOf/15.4.4.15-3-15.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-3-16.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-3-17.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-3-18.js | 19 + .../Array/prototype/lastIndexOf/15.4.4.15-3-19.js | 32 + .../Array/prototype/lastIndexOf/15.4.4.15-3-2.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-3-20.js | 26 + .../Array/prototype/lastIndexOf/15.4.4.15-3-21.js | 35 + .../Array/prototype/lastIndexOf/15.4.4.15-3-22.js | 37 + .../Array/prototype/lastIndexOf/15.4.4.15-3-23.js | 40 + .../Array/prototype/lastIndexOf/15.4.4.15-3-24.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-3-25.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-3-28.js | 21 + .../Array/prototype/lastIndexOf/15.4.4.15-3-3.js | 18 + .../Array/prototype/lastIndexOf/15.4.4.15-3-4.js | 18 + .../Array/prototype/lastIndexOf/15.4.4.15-3-5.js | 18 + .../Array/prototype/lastIndexOf/15.4.4.15-3-6.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-3-7.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-3-9.js | 18 + .../Array/prototype/lastIndexOf/15.4.4.15-4-1.js | 15 + .../Array/prototype/lastIndexOf/15.4.4.15-4-10.js | 18 + .../Array/prototype/lastIndexOf/15.4.4.15-4-11.js | 18 + .../Array/prototype/lastIndexOf/15.4.4.15-4-2.js | 18 + .../Array/prototype/lastIndexOf/15.4.4.15-4-3.js | 18 + .../Array/prototype/lastIndexOf/15.4.4.15-4-4.js | 24 + .../Array/prototype/lastIndexOf/15.4.4.15-4-5.js | 18 + .../Array/prototype/lastIndexOf/15.4.4.15-4-6.js | 22 + .../Array/prototype/lastIndexOf/15.4.4.15-4-7.js | 39 + .../Array/prototype/lastIndexOf/15.4.4.15-4-8.js | 31 + .../Array/prototype/lastIndexOf/15.4.4.15-4-9.js | 18 + .../Array/prototype/lastIndexOf/15.4.4.15-5-1.js | 14 + .../Array/prototype/lastIndexOf/15.4.4.15-5-10.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-5-11.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-5-12.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-5-13.js | 13 + .../Array/prototype/lastIndexOf/15.4.4.15-5-14.js | 17 + .../Array/prototype/lastIndexOf/15.4.4.15-5-15.js | 14 + .../Array/prototype/lastIndexOf/15.4.4.15-5-16.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-5-17.js | 13 + .../Array/prototype/lastIndexOf/15.4.4.15-5-18.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-5-19.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-5-2.js | 15 + .../Array/prototype/lastIndexOf/15.4.4.15-5-20.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-5-21.js | 26 + .../Array/prototype/lastIndexOf/15.4.4.15-5-22.js | 22 + .../Array/prototype/lastIndexOf/15.4.4.15-5-23.js | 31 + .../Array/prototype/lastIndexOf/15.4.4.15-5-24.js | 34 + .../Array/prototype/lastIndexOf/15.4.4.15-5-25.js | 35 + .../Array/prototype/lastIndexOf/15.4.4.15-5-26.js | 38 + .../Array/prototype/lastIndexOf/15.4.4.15-5-27.js | 43 + .../Array/prototype/lastIndexOf/15.4.4.15-5-28.js | 23 + .../Array/prototype/lastIndexOf/15.4.4.15-5-29.js | 32 + .../Array/prototype/lastIndexOf/15.4.4.15-5-3.js | 14 + .../Array/prototype/lastIndexOf/15.4.4.15-5-30.js | 36 + .../Array/prototype/lastIndexOf/15.4.4.15-5-31.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-5-32.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-5-33.js | 17 + .../Array/prototype/lastIndexOf/15.4.4.15-5-4.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-5-5.js | 15 + .../Array/prototype/lastIndexOf/15.4.4.15-5-6.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-5-7.js | 14 + .../Array/prototype/lastIndexOf/15.4.4.15-5-8.js | 14 + .../Array/prototype/lastIndexOf/15.4.4.15-5-9.js | 14 + .../Array/prototype/lastIndexOf/15.4.4.15-6-1.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-6-2.js | 13 + .../Array/prototype/lastIndexOf/15.4.4.15-6-3.js | 13 + .../Array/prototype/lastIndexOf/15.4.4.15-6-4.js | 13 + .../Array/prototype/lastIndexOf/15.4.4.15-6-5.js | 11 + .../Array/prototype/lastIndexOf/15.4.4.15-6-6.js | 13 + .../Array/prototype/lastIndexOf/15.4.4.15-7-1.js | 16 + .../Array/prototype/lastIndexOf/15.4.4.15-7-2.js | 13 + .../Array/prototype/lastIndexOf/15.4.4.15-7-3.js | 13 + .../Array/prototype/lastIndexOf/15.4.4.15-7-4.js | 13 + .../Array/prototype/lastIndexOf/15.4.4.15-8-1.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-8-10.js | 21 + .../Array/prototype/lastIndexOf/15.4.4.15-8-11.js | 23 + .../Array/prototype/lastIndexOf/15.4.4.15-8-2.js | 23 + .../Array/prototype/lastIndexOf/15.4.4.15-8-3.js | 19 + .../Array/prototype/lastIndexOf/15.4.4.15-8-4.js | 20 + .../Array/prototype/lastIndexOf/15.4.4.15-8-5.js | 28 + .../Array/prototype/lastIndexOf/15.4.4.15-8-6.js | 19 + .../Array/prototype/lastIndexOf/15.4.4.15-8-7.js | 17 + .../Array/prototype/lastIndexOf/15.4.4.15-8-8.js | 15 + .../Array/prototype/lastIndexOf/15.4.4.15-8-9.js | 27 + .../Array/prototype/lastIndexOf/15.4.4.15-8-a-1.js | 23 + .../prototype/lastIndexOf/15.4.4.15-8-a-10.js | 28 + .../prototype/lastIndexOf/15.4.4.15-8-a-11.js | 32 + .../prototype/lastIndexOf/15.4.4.15-8-a-12.js | 30 + .../prototype/lastIndexOf/15.4.4.15-8-a-13.js | 29 + .../prototype/lastIndexOf/15.4.4.15-8-a-14.js | 25 + .../prototype/lastIndexOf/15.4.4.15-8-a-15.js | 31 + .../prototype/lastIndexOf/15.4.4.15-8-a-16.js | 26 + .../prototype/lastIndexOf/15.4.4.15-8-a-17.js | 23 + .../prototype/lastIndexOf/15.4.4.15-8-a-18.js | 30 + .../prototype/lastIndexOf/15.4.4.15-8-a-19.js | 31 + .../Array/prototype/lastIndexOf/15.4.4.15-8-a-2.js | 26 + .../Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js | 24 + .../Array/prototype/lastIndexOf/15.4.4.15-8-a-4.js | 25 + .../Array/prototype/lastIndexOf/15.4.4.15-8-a-5.js | 25 + .../Array/prototype/lastIndexOf/15.4.4.15-8-a-6.js | 24 + .../Array/prototype/lastIndexOf/15.4.4.15-8-a-7.js | 30 + .../Array/prototype/lastIndexOf/15.4.4.15-8-a-8.js | 28 + .../Array/prototype/lastIndexOf/15.4.4.15-8-a-9.js | 31 + .../Array/prototype/lastIndexOf/15.4.4.15-8-b-1.js | 11 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-1.js | 22 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-10.js | 39 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-11.js | 24 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-12.js | 26 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-13.js | 30 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-14.js | 32 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-15.js | 36 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-16.js | 42 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-17.js | 19 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-18.js | 21 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-19.js | 30 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-2.js | 15 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-20.js | 28 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-21.js | 18 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-22.js | 20 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-25.js | 19 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-26.js | 20 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-27.js | 22 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-28.js | 35 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-29.js | 37 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-3.js | 15 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-30.js | 33 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-31.js | 35 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-4.js | 20 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-5.js | 20 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-6.js | 25 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-7.js | 19 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-8.js | 25 + .../prototype/lastIndexOf/15.4.4.15-8-b-i-9.js | 37 + .../prototype/lastIndexOf/15.4.4.15-8-b-ii-1.js | 20 + .../prototype/lastIndexOf/15.4.4.15-8-b-ii-10.js | 13 + .../prototype/lastIndexOf/15.4.4.15-8-b-ii-11.js | 17 + .../prototype/lastIndexOf/15.4.4.15-8-b-ii-2.js | 14 + .../prototype/lastIndexOf/15.4.4.15-8-b-ii-3.js | 13 + .../prototype/lastIndexOf/15.4.4.15-8-b-ii-4.js | 11 + .../prototype/lastIndexOf/15.4.4.15-8-b-ii-5.js | 11 + .../prototype/lastIndexOf/15.4.4.15-8-b-ii-6.js | 13 + .../prototype/lastIndexOf/15.4.4.15-8-b-ii-7.js | 13 + .../prototype/lastIndexOf/15.4.4.15-8-b-ii-8.js | 13 + .../prototype/lastIndexOf/15.4.4.15-8-b-ii-9.js | 14 + .../prototype/lastIndexOf/15.4.4.15-8-b-iii-1.js | 13 + .../prototype/lastIndexOf/15.4.4.15-8-b-iii-2.js | 35 + .../Array/prototype/lastIndexOf/15.4.4.15-9-1.js | 29 + .../Array/prototype/lastIndexOf/15.4.4.15-9-2.js | 28 + .../Array/prototype/lastIndexOf/browser.js | 0 .../prototype/lastIndexOf/call-with-boolean.js | 16 + ...ls-only-has-on-prototype-after-length-zeroed.js | 45 + .../lastIndexOf/fromindex-zero-conversion.js | 18 + .../lastIndexOf/length-near-integer-limit.js | 37 + .../lastIndexOf/length-zero-returns-minus-one.js | 24 + .../Array/prototype/lastIndexOf/length.js | 30 + .../built-ins/Array/prototype/lastIndexOf/name.js | 28 + .../prototype/lastIndexOf/not-a-constructor.js | 35 + .../Array/prototype/lastIndexOf/prop-desc.js | 23 + .../built-ins/Array/prototype/lastIndexOf/shell.js | 33 + .../test262/built-ins/Array/prototype/length.js | 26 + .../built-ins/Array/prototype/map/15.4.4.19-1-1.js | 14 + .../Array/prototype/map/15.4.4.19-1-10.js | 19 + .../Array/prototype/map/15.4.4.19-1-11.js | 21 + .../Array/prototype/map/15.4.4.19-1-12.js | 21 + .../Array/prototype/map/15.4.4.19-1-13.js | 19 + .../Array/prototype/map/15.4.4.19-1-14.js | 21 + .../Array/prototype/map/15.4.4.19-1-15.js | 21 + .../built-ins/Array/prototype/map/15.4.4.19-1-2.js | 14 + .../built-ins/Array/prototype/map/15.4.4.19-1-3.js | 20 + .../built-ins/Array/prototype/map/15.4.4.19-1-4.js | 23 + .../built-ins/Array/prototype/map/15.4.4.19-1-5.js | 20 + .../built-ins/Array/prototype/map/15.4.4.19-1-6.js | 23 + .../built-ins/Array/prototype/map/15.4.4.19-1-7.js | 19 + .../built-ins/Array/prototype/map/15.4.4.19-1-8.js | 20 + .../built-ins/Array/prototype/map/15.4.4.19-1-9.js | 24 + .../built-ins/Array/prototype/map/15.4.4.19-2-1.js | 26 + .../Array/prototype/map/15.4.4.19-2-10.js | 36 + .../Array/prototype/map/15.4.4.19-2-11.js | 28 + .../Array/prototype/map/15.4.4.19-2-12.js | 36 + .../Array/prototype/map/15.4.4.19-2-13.js | 32 + .../Array/prototype/map/15.4.4.19-2-14.js | 24 + .../Array/prototype/map/15.4.4.19-2-17.js | 23 + .../Array/prototype/map/15.4.4.19-2-18.js | 22 + .../Array/prototype/map/15.4.4.19-2-19.js | 26 + .../built-ins/Array/prototype/map/15.4.4.19-2-2.js | 19 + .../built-ins/Array/prototype/map/15.4.4.19-2-3.js | 32 + .../built-ins/Array/prototype/map/15.4.4.19-2-4.js | 22 + .../built-ins/Array/prototype/map/15.4.4.19-2-5.js | 40 + .../built-ins/Array/prototype/map/15.4.4.19-2-6.js | 31 + .../built-ins/Array/prototype/map/15.4.4.19-2-7.js | 32 + .../built-ins/Array/prototype/map/15.4.4.19-2-8.js | 39 + .../built-ins/Array/prototype/map/15.4.4.19-2-9.js | 45 + .../built-ins/Array/prototype/map/15.4.4.19-3-1.js | 21 + .../Array/prototype/map/15.4.4.19-3-10.js | 22 + .../Array/prototype/map/15.4.4.19-3-11.js | 26 + .../Array/prototype/map/15.4.4.19-3-12.js | 26 + .../Array/prototype/map/15.4.4.19-3-13.js | 26 + .../Array/prototype/map/15.4.4.19-3-14.js | 21 + .../Array/prototype/map/15.4.4.19-3-15.js | 26 + .../Array/prototype/map/15.4.4.19-3-16.js | 24 + .../Array/prototype/map/15.4.4.19-3-17.js | 26 + .../Array/prototype/map/15.4.4.19-3-18.js | 23 + .../Array/prototype/map/15.4.4.19-3-19.js | 30 + .../built-ins/Array/prototype/map/15.4.4.19-3-2.js | 24 + .../Array/prototype/map/15.4.4.19-3-20.js | 30 + .../Array/prototype/map/15.4.4.19-3-21.js | 40 + .../Array/prototype/map/15.4.4.19-3-22.js | 33 + .../Array/prototype/map/15.4.4.19-3-23.js | 47 + .../Array/prototype/map/15.4.4.19-3-24.js | 25 + .../Array/prototype/map/15.4.4.19-3-25.js | 23 + .../Array/prototype/map/15.4.4.19-3-28.js | 21 + .../Array/prototype/map/15.4.4.19-3-29.js | 24 + .../built-ins/Array/prototype/map/15.4.4.19-3-3.js | 22 + .../built-ins/Array/prototype/map/15.4.4.19-3-4.js | 22 + .../built-ins/Array/prototype/map/15.4.4.19-3-5.js | 22 + .../built-ins/Array/prototype/map/15.4.4.19-3-6.js | 26 + .../built-ins/Array/prototype/map/15.4.4.19-3-7.js | 26 + .../built-ins/Array/prototype/map/15.4.4.19-3-8.js | 23 + .../built-ins/Array/prototype/map/15.4.4.19-3-9.js | 24 + .../built-ins/Array/prototype/map/15.4.4.19-4-1.js | 14 + .../Array/prototype/map/15.4.4.19-4-10.js | 27 + .../Array/prototype/map/15.4.4.19-4-11.js | 31 + .../Array/prototype/map/15.4.4.19-4-12.js | 19 + .../Array/prototype/map/15.4.4.19-4-15.js | 37 + .../built-ins/Array/prototype/map/15.4.4.19-4-2.js | 16 + .../built-ins/Array/prototype/map/15.4.4.19-4-3.js | 14 + .../built-ins/Array/prototype/map/15.4.4.19-4-4.js | 14 + .../built-ins/Array/prototype/map/15.4.4.19-4-5.js | 14 + .../built-ins/Array/prototype/map/15.4.4.19-4-6.js | 14 + .../built-ins/Array/prototype/map/15.4.4.19-4-7.js | 16 + .../built-ins/Array/prototype/map/15.4.4.19-4-8.js | 30 + .../built-ins/Array/prototype/map/15.4.4.19-4-9.js | 34 + .../Array/prototype/map/15.4.4.19-5-1-s.js | 22 + .../built-ins/Array/prototype/map/15.4.4.19-5-1.js | 25 + .../Array/prototype/map/15.4.4.19-5-10.js | 19 + .../Array/prototype/map/15.4.4.19-5-11.js | 19 + .../Array/prototype/map/15.4.4.19-5-12.js | 19 + .../Array/prototype/map/15.4.4.19-5-13.js | 19 + .../Array/prototype/map/15.4.4.19-5-14.js | 17 + .../Array/prototype/map/15.4.4.19-5-15.js | 19 + .../Array/prototype/map/15.4.4.19-5-16.js | 19 + .../Array/prototype/map/15.4.4.19-5-17.js | 17 + .../Array/prototype/map/15.4.4.19-5-18.js | 19 + .../Array/prototype/map/15.4.4.19-5-19.js | 23 + .../built-ins/Array/prototype/map/15.4.4.19-5-2.js | 23 + .../Array/prototype/map/15.4.4.19-5-21.js | 19 + .../Array/prototype/map/15.4.4.19-5-22.js | 17 + .../Array/prototype/map/15.4.4.19-5-23.js | 17 + .../Array/prototype/map/15.4.4.19-5-24.js | 17 + .../built-ins/Array/prototype/map/15.4.4.19-5-3.js | 23 + .../built-ins/Array/prototype/map/15.4.4.19-5-4.js | 27 + .../built-ins/Array/prototype/map/15.4.4.19-5-5.js | 25 + .../built-ins/Array/prototype/map/15.4.4.19-5-6.js | 24 + .../built-ins/Array/prototype/map/15.4.4.19-5-7.js | 17 + .../built-ins/Array/prototype/map/15.4.4.19-5-9.js | 19 + .../built-ins/Array/prototype/map/15.4.4.19-6-1.js | 15 + .../built-ins/Array/prototype/map/15.4.4.19-6-2.js | 13 + .../built-ins/Array/prototype/map/15.4.4.19-8-1.js | 23 + .../built-ins/Array/prototype/map/15.4.4.19-8-2.js | 26 + .../built-ins/Array/prototype/map/15.4.4.19-8-3.js | 27 + .../built-ins/Array/prototype/map/15.4.4.19-8-4.js | 27 + .../built-ins/Array/prototype/map/15.4.4.19-8-5.js | 28 + .../built-ins/Array/prototype/map/15.4.4.19-8-6.js | 29 + .../built-ins/Array/prototype/map/15.4.4.19-8-7.js | 25 + .../built-ins/Array/prototype/map/15.4.4.19-8-8.js | 29 + .../built-ins/Array/prototype/map/15.4.4.19-8-9.js | 34 + .../Array/prototype/map/15.4.4.19-8-b-1.js | 26 + .../Array/prototype/map/15.4.4.19-8-b-10.js | 33 + .../Array/prototype/map/15.4.4.19-8-b-11.js | 30 + .../Array/prototype/map/15.4.4.19-8-b-12.js | 39 + .../Array/prototype/map/15.4.4.19-8-b-13.js | 33 + .../Array/prototype/map/15.4.4.19-8-b-14.js | 29 + .../Array/prototype/map/15.4.4.19-8-b-15.js | 40 + .../Array/prototype/map/15.4.4.19-8-b-16.js | 42 + .../Array/prototype/map/15.4.4.19-8-b-2.js | 31 + .../Array/prototype/map/15.4.4.19-8-b-3.js | 33 + .../Array/prototype/map/15.4.4.19-8-b-4.js | 41 + .../Array/prototype/map/15.4.4.19-8-b-5.js | 39 + .../Array/prototype/map/15.4.4.19-8-b-6.js | 40 + .../Array/prototype/map/15.4.4.19-8-b-7.js | 38 + .../Array/prototype/map/15.4.4.19-8-b-8.js | 42 + .../Array/prototype/map/15.4.4.19-8-b-9.js | 40 + .../Array/prototype/map/15.4.4.19-8-c-i-1.js | 29 + .../Array/prototype/map/15.4.4.19-8-c-i-10.js | 33 + .../Array/prototype/map/15.4.4.19-8-c-i-11.js | 42 + .../Array/prototype/map/15.4.4.19-8-c-i-12.js | 35 + .../Array/prototype/map/15.4.4.19-8-c-i-13.js | 48 + .../Array/prototype/map/15.4.4.19-8-c-i-14.js | 40 + .../Array/prototype/map/15.4.4.19-8-c-i-15.js | 40 + .../Array/prototype/map/15.4.4.19-8-c-i-16.js | 31 + .../Array/prototype/map/15.4.4.19-8-c-i-17.js | 31 + .../Array/prototype/map/15.4.4.19-8-c-i-18.js | 29 + .../Array/prototype/map/15.4.4.19-8-c-i-19.js | 37 + .../Array/prototype/map/15.4.4.19-8-c-i-2.js | 26 + .../Array/prototype/map/15.4.4.19-8-c-i-20.js | 43 + .../Array/prototype/map/15.4.4.19-8-c-i-21.js | 35 + .../Array/prototype/map/15.4.4.19-8-c-i-22.js | 27 + .../Array/prototype/map/15.4.4.19-8-c-i-25.js | 28 + .../Array/prototype/map/15.4.4.19-8-c-i-26.js | 31 + .../Array/prototype/map/15.4.4.19-8-c-i-27.js | 35 + .../Array/prototype/map/15.4.4.19-8-c-i-28.js | 48 + .../Array/prototype/map/15.4.4.19-8-c-i-29.js | 50 + .../Array/prototype/map/15.4.4.19-8-c-i-3.js | 35 + .../Array/prototype/map/15.4.4.19-8-c-i-30.js | 44 + .../Array/prototype/map/15.4.4.19-8-c-i-31.js | 42 + .../Array/prototype/map/15.4.4.19-8-c-i-4.js | 26 + .../Array/prototype/map/15.4.4.19-8-c-i-5.js | 44 + .../Array/prototype/map/15.4.4.19-8-c-i-6.js | 31 + .../Array/prototype/map/15.4.4.19-8-c-i-7.js | 34 + .../Array/prototype/map/15.4.4.19-8-c-i-8.js | 24 + .../Array/prototype/map/15.4.4.19-8-c-i-9.js | 35 + .../Array/prototype/map/15.4.4.19-8-c-ii-1.js | 27 + .../Array/prototype/map/15.4.4.19-8-c-ii-10.js | 17 + .../Array/prototype/map/15.4.4.19-8-c-ii-11.js | 17 + .../Array/prototype/map/15.4.4.19-8-c-ii-12.js | 17 + .../Array/prototype/map/15.4.4.19-8-c-ii-13.js | 19 + .../Array/prototype/map/15.4.4.19-8-c-ii-16.js | 24 + .../Array/prototype/map/15.4.4.19-8-c-ii-17.js | 24 + .../Array/prototype/map/15.4.4.19-8-c-ii-18.js | 24 + .../Array/prototype/map/15.4.4.19-8-c-ii-19.js | 32 + .../Array/prototype/map/15.4.4.19-8-c-ii-2.js | 25 + .../Array/prototype/map/15.4.4.19-8-c-ii-20.js | 29 + .../Array/prototype/map/15.4.4.19-8-c-ii-21.js | 34 + .../Array/prototype/map/15.4.4.19-8-c-ii-22.js | 34 + .../Array/prototype/map/15.4.4.19-8-c-ii-23.js | 24 + .../Array/prototype/map/15.4.4.19-8-c-ii-4.js | 28 + .../Array/prototype/map/15.4.4.19-8-c-ii-5.js | 36 + .../Array/prototype/map/15.4.4.19-8-c-ii-6.js | 26 + .../Array/prototype/map/15.4.4.19-8-c-ii-7.js | 33 + .../Array/prototype/map/15.4.4.19-8-c-ii-8.js | 28 + .../Array/prototype/map/15.4.4.19-8-c-ii-9.js | 17 + .../Array/prototype/map/15.4.4.19-8-c-iii-1.js | 29 + .../Array/prototype/map/15.4.4.19-8-c-iii-2.js | 25 + .../Array/prototype/map/15.4.4.19-8-c-iii-3.js | 27 + .../Array/prototype/map/15.4.4.19-8-c-iii-4.js | 33 + .../Array/prototype/map/15.4.4.19-8-c-iii-5.js | 28 + .../built-ins/Array/prototype/map/15.4.4.19-9-1.js | 24 + .../Array/prototype/map/15.4.4.19-9-10.js | 31 + .../Array/prototype/map/15.4.4.19-9-11.js | 36 + .../Array/prototype/map/15.4.4.19-9-12.js | 37 + .../Array/prototype/map/15.4.4.19-9-13.js | 28 + .../built-ins/Array/prototype/map/15.4.4.19-9-2.js | 24 + .../built-ins/Array/prototype/map/15.4.4.19-9-3.js | 22 + .../built-ins/Array/prototype/map/15.4.4.19-9-4.js | 23 + .../built-ins/Array/prototype/map/15.4.4.19-9-5.js | 25 + .../built-ins/Array/prototype/map/15.4.4.19-9-6.js | 24 + .../built-ins/Array/prototype/map/15.4.4.19-9-7.js | 27 + .../built-ins/Array/prototype/map/15.4.4.19-9-8.js | 27 + .../built-ins/Array/prototype/map/15.4.4.19-9-9.js | 27 + .../built-ins/Array/prototype/map/browser.js | 0 .../Array/prototype/map/call-with-boolean.js | 21 + .../prototype/map/callbackfn-resize-arraybuffer.js | 78 + .../Array/prototype/map/create-ctor-non-object.js | 53 + .../Array/prototype/map/create-ctor-poisoned.js | 34 + .../prototype/map/create-non-array-invalid-len.js | 41 + .../Array/prototype/map/create-non-array.js | 35 + .../map/create-proto-from-ctor-realm-array.js | 45 + .../map/create-proto-from-ctor-realm-non-array.js | 46 + .../built-ins/Array/prototype/map/create-proxy.js | 41 + .../Array/prototype/map/create-revoked-proxy.js | 46 + .../Array/prototype/map/create-species-abrupt.js | 40 + .../Array/prototype/map/create-species-non-ctor.js | 46 + .../Array/prototype/map/create-species-null.js | 35 + .../Array/prototype/map/create-species-poisoned.js | 39 + .../map/create-species-undef-invalid-len.js | 61 + .../Array/prototype/map/create-species-undef.js | 36 + .../Array/prototype/map/create-species.js | 45 + .../built-ins/Array/prototype/map/length.js | 30 + .../test262/built-ins/Array/prototype/map/name.js | 28 + .../Array/prototype/map/not-a-constructor.js | 31 + .../built-ins/Array/prototype/map/prop-desc.js | 23 + .../test262/built-ins/Array/prototype/map/shell.js | 161 ++ .../prototype/map/target-array-non-extensible.js | 41 + .../target-array-with-non-configurable-property.js | 43 + .../map/target-array-with-non-writable-property.js | 38 + .../Array/prototype/methods-called-as-functions.js | 205 ++ .../Array/prototype/pop/S15.4.4.6_A1.1_T1.js | 33 + .../Array/prototype/pop/S15.4.4.6_A1.2_T1.js | 60 + .../Array/prototype/pop/S15.4.4.6_A2_T1.js | 49 + .../Array/prototype/pop/S15.4.4.6_A2_T2.js | 81 + .../Array/prototype/pop/S15.4.4.6_A2_T3.js | 37 + .../Array/prototype/pop/S15.4.4.6_A2_T4.js | 126 ++ .../Array/prototype/pop/S15.4.4.6_A3_T1.js | 33 + .../Array/prototype/pop/S15.4.4.6_A3_T2.js | 33 + .../Array/prototype/pop/S15.4.4.6_A3_T3.js | 28 + .../Array/prototype/pop/S15.4.4.6_A4_T1.js | 50 + .../Array/prototype/pop/S15.4.4.6_A4_T2.js | 51 + .../built-ins/Array/prototype/pop/browser.js | 0 .../Array/prototype/pop/call-with-boolean.js | 12 + .../Array/prototype/pop/clamps-to-integer-limit.js | 38 + .../prototype/pop/length-near-integer-limit.js | 46 + .../built-ins/Array/prototype/pop/length.js | 30 + .../test262/built-ins/Array/prototype/pop/name.js | 28 + .../Array/prototype/pop/not-a-constructor.js | 31 + .../built-ins/Array/prototype/pop/prop-desc.js | 23 + .../prototype/pop/set-length-array-is-frozen.js | 49 + .../pop/set-length-array-length-is-non-writable.js | 49 + .../pop/set-length-zero-array-is-frozen.js | 34 + ...set-length-zero-array-length-is-non-writable.js | 34 + .../test262/built-ins/Array/prototype/pop/shell.js | 0 .../prototype/pop/throws-with-string-receiver.js | 31 + .../test262/built-ins/Array/prototype/prop-desc.js | 22 + .../test262/built-ins/Array/prototype/proto.js | 17 + .../Array/prototype/push/S15.4.4.7_A1_T1.js | 45 + .../Array/prototype/push/S15.4.4.7_A1_T2.js | 52 + .../Array/prototype/push/S15.4.4.7_A2_T1.js | 61 + .../Array/prototype/push/S15.4.4.7_A2_T2.js | 101 + .../Array/prototype/push/S15.4.4.7_A2_T3.js | 120 ++ .../built-ins/Array/prototype/push/S15.4.4.7_A3.js | 30 + .../Array/prototype/push/S15.4.4.7_A4_T1.js | 60 + .../Array/prototype/push/S15.4.4.7_A4_T2.js | 35 + .../Array/prototype/push/S15.4.4.7_A4_T3.js | 47 + .../Array/prototype/push/S15.4.4.7_A5_T1.js | 42 + .../built-ins/Array/prototype/push/browser.js | 0 .../Array/prototype/push/call-with-boolean.js | 12 + .../prototype/push/clamps-to-integer-limit.js | 38 + .../push/length-near-integer-limit-set-failure.js | 49 + .../prototype/push/length-near-integer-limit.js | 42 + .../built-ins/Array/prototype/push/length.js | 34 + .../test262/built-ins/Array/prototype/push/name.js | 28 + .../Array/prototype/push/not-a-constructor.js | 31 + .../built-ins/Array/prototype/push/prop-desc.js | 23 + .../prototype/push/set-length-array-is-frozen.js | 47 + .../set-length-array-length-is-non-writable.js | 47 + .../push/set-length-zero-array-is-frozen.js | 38 + ...set-length-zero-array-length-is-non-writable.js | 38 + .../built-ins/Array/prototype/push/shell.js | 0 .../push/throws-if-integer-limit-exceeded.js | 41 + .../prototype/push/throws-with-string-receiver.js | 38 + .../Array/prototype/reduce/15.4.4.21-1-1.js | 14 + .../Array/prototype/reduce/15.4.4.21-1-10.js | 18 + .../Array/prototype/reduce/15.4.4.21-1-11.js | 19 + .../Array/prototype/reduce/15.4.4.21-1-12.js | 19 + .../Array/prototype/reduce/15.4.4.21-1-13.js | 18 + .../Array/prototype/reduce/15.4.4.21-1-14.js | 19 + .../Array/prototype/reduce/15.4.4.21-1-15.js | 19 + .../Array/prototype/reduce/15.4.4.21-1-2.js | 14 + .../Array/prototype/reduce/15.4.4.21-1-3.js | 18 + .../Array/prototype/reduce/15.4.4.21-1-4.js | 20 + .../Array/prototype/reduce/15.4.4.21-1-5.js | 18 + .../Array/prototype/reduce/15.4.4.21-1-6.js | 20 + .../Array/prototype/reduce/15.4.4.21-1-7.js | 15 + .../Array/prototype/reduce/15.4.4.21-1-8.js | 17 + .../Array/prototype/reduce/15.4.4.21-1-9.js | 21 + .../Array/prototype/reduce/15.4.4.21-10-1.js | 24 + .../Array/prototype/reduce/15.4.4.21-10-2.js | 19 + .../Array/prototype/reduce/15.4.4.21-10-3.js | 18 + .../Array/prototype/reduce/15.4.4.21-10-4.js | 20 + .../Array/prototype/reduce/15.4.4.21-10-5.js | 19 + .../Array/prototype/reduce/15.4.4.21-10-6.js | 22 + .../Array/prototype/reduce/15.4.4.21-10-7.js | 22 + .../Array/prototype/reduce/15.4.4.21-10-8.js | 23 + .../Array/prototype/reduce/15.4.4.21-2-1.js | 24 + .../Array/prototype/reduce/15.4.4.21-2-10.js | 34 + .../Array/prototype/reduce/15.4.4.21-2-11.js | 29 + .../Array/prototype/reduce/15.4.4.21-2-12.js | 37 + .../Array/prototype/reduce/15.4.4.21-2-13.js | 33 + .../Array/prototype/reduce/15.4.4.21-2-14.js | 25 + .../Array/prototype/reduce/15.4.4.21-2-17.js | 22 + .../Array/prototype/reduce/15.4.4.21-2-18.js | 19 + .../Array/prototype/reduce/15.4.4.21-2-19.js | 24 + .../Array/prototype/reduce/15.4.4.21-2-2.js | 15 + .../Array/prototype/reduce/15.4.4.21-2-3.js | 30 + .../Array/prototype/reduce/15.4.4.21-2-4.js | 22 + .../Array/prototype/reduce/15.4.4.21-2-5.js | 38 + .../Array/prototype/reduce/15.4.4.21-2-6.js | 29 + .../Array/prototype/reduce/15.4.4.21-2-7.js | 30 + .../Array/prototype/reduce/15.4.4.21-2-8.js | 37 + .../Array/prototype/reduce/15.4.4.21-2-9.js | 43 + .../Array/prototype/reduce/15.4.4.21-3-1.js | 25 + .../Array/prototype/reduce/15.4.4.21-3-10.js | 26 + .../Array/prototype/reduce/15.4.4.21-3-11.js | 23 + .../Array/prototype/reduce/15.4.4.21-3-12.js | 23 + .../Array/prototype/reduce/15.4.4.21-3-13.js | 23 + .../Array/prototype/reduce/15.4.4.21-3-14.js | 24 + .../Array/prototype/reduce/15.4.4.21-3-15.js | 23 + .../Array/prototype/reduce/15.4.4.21-3-16.js | 23 + .../Array/prototype/reduce/15.4.4.21-3-17.js | 23 + .../Array/prototype/reduce/15.4.4.21-3-18.js | 26 + .../Array/prototype/reduce/15.4.4.21-3-19.js | 27 + .../Array/prototype/reduce/15.4.4.21-3-2.js | 23 + .../Array/prototype/reduce/15.4.4.21-3-20.js | 27 + .../Array/prototype/reduce/15.4.4.21-3-21.js | 38 + .../Array/prototype/reduce/15.4.4.21-3-22.js | 43 + .../Array/prototype/reduce/15.4.4.21-3-23.js | 45 + .../Array/prototype/reduce/15.4.4.21-3-24.js | 23 + .../Array/prototype/reduce/15.4.4.21-3-25.js | 23 + .../Array/prototype/reduce/15.4.4.21-3-3.js | 25 + .../Array/prototype/reduce/15.4.4.21-3-4.js | 26 + .../Array/prototype/reduce/15.4.4.21-3-5.js | 26 + .../Array/prototype/reduce/15.4.4.21-3-6.js | 23 + .../Array/prototype/reduce/15.4.4.21-3-7.js | 23 + .../Array/prototype/reduce/15.4.4.21-3-9.js | 25 + .../Array/prototype/reduce/15.4.4.21-4-1.js | 14 + .../Array/prototype/reduce/15.4.4.21-4-10.js | 27 + .../Array/prototype/reduce/15.4.4.21-4-11.js | 31 + .../Array/prototype/reduce/15.4.4.21-4-12.js | 19 + .../Array/prototype/reduce/15.4.4.21-4-15.js | 38 + .../Array/prototype/reduce/15.4.4.21-4-2.js | 16 + .../Array/prototype/reduce/15.4.4.21-4-3.js | 14 + .../Array/prototype/reduce/15.4.4.21-4-4.js | 14 + .../Array/prototype/reduce/15.4.4.21-4-5.js | 14 + .../Array/prototype/reduce/15.4.4.21-4-6.js | 14 + .../Array/prototype/reduce/15.4.4.21-4-7.js | 16 + .../Array/prototype/reduce/15.4.4.21-4-8.js | 30 + .../Array/prototype/reduce/15.4.4.21-4-9.js | 34 + .../Array/prototype/reduce/15.4.4.21-5-1.js | 16 + .../Array/prototype/reduce/15.4.4.21-5-10.js | 34 + .../Array/prototype/reduce/15.4.4.21-5-11.js | 38 + .../Array/prototype/reduce/15.4.4.21-5-12.js | 31 + .../Array/prototype/reduce/15.4.4.21-5-13.js | 35 + .../Array/prototype/reduce/15.4.4.21-5-2.js | 23 + .../Array/prototype/reduce/15.4.4.21-5-3.js | 23 + .../Array/prototype/reduce/15.4.4.21-5-4.js | 23 + .../Array/prototype/reduce/15.4.4.21-5-5.js | 23 + .../Array/prototype/reduce/15.4.4.21-5-6.js | 29 + .../Array/prototype/reduce/15.4.4.21-5-7.js | 35 + .../Array/prototype/reduce/15.4.4.21-5-8.js | 37 + .../Array/prototype/reduce/15.4.4.21-5-9.js | 20 + .../Array/prototype/reduce/15.4.4.21-7-1.js | 14 + .../Array/prototype/reduce/15.4.4.21-7-10.js | 13 + .../Array/prototype/reduce/15.4.4.21-7-11.js | 13 + .../Array/prototype/reduce/15.4.4.21-7-2.js | 21 + .../Array/prototype/reduce/15.4.4.21-7-3.js | 21 + .../Array/prototype/reduce/15.4.4.21-7-4.js | 21 + .../Array/prototype/reduce/15.4.4.21-7-5.js | 21 + .../Array/prototype/reduce/15.4.4.21-7-6.js | 27 + .../Array/prototype/reduce/15.4.4.21-7-7.js | 33 + .../Array/prototype/reduce/15.4.4.21-7-8.js | 36 + .../Array/prototype/reduce/15.4.4.21-7-9.js | 36 + .../Array/prototype/reduce/15.4.4.21-8-b-1.js | 29 + .../Array/prototype/reduce/15.4.4.21-8-b-2.js | 31 + .../Array/prototype/reduce/15.4.4.21-8-b-3.js | 45 + .../Array/prototype/reduce/15.4.4.21-8-b-ii-1.js | 23 + .../Array/prototype/reduce/15.4.4.21-8-b-ii-2.js | 26 + .../prototype/reduce/15.4.4.21-8-b-iii-1-1.js | 29 + .../prototype/reduce/15.4.4.21-8-b-iii-1-10.js | 32 + .../prototype/reduce/15.4.4.21-8-b-iii-1-11.js | 43 + .../prototype/reduce/15.4.4.21-8-b-iii-1-12.js | 33 + .../prototype/reduce/15.4.4.21-8-b-iii-1-13.js | 49 + .../prototype/reduce/15.4.4.21-8-b-iii-1-14.js | 38 + .../prototype/reduce/15.4.4.21-8-b-iii-1-15.js | 41 + .../prototype/reduce/15.4.4.21-8-b-iii-1-16.js | 32 + .../prototype/reduce/15.4.4.21-8-b-iii-1-17.js | 34 + .../prototype/reduce/15.4.4.21-8-b-iii-1-18.js | 30 + .../prototype/reduce/15.4.4.21-8-b-iii-1-19.js | 37 + .../prototype/reduce/15.4.4.21-8-b-iii-1-2.js | 24 + .../prototype/reduce/15.4.4.21-8-b-iii-1-20.js | 31 + .../prototype/reduce/15.4.4.21-8-b-iii-1-21.js | 39 + .../prototype/reduce/15.4.4.21-8-b-iii-1-22.js | 30 + .../prototype/reduce/15.4.4.21-8-b-iii-1-25.js | 28 + .../prototype/reduce/15.4.4.21-8-b-iii-1-26.js | 29 + .../prototype/reduce/15.4.4.21-8-b-iii-1-27.js | 30 + .../prototype/reduce/15.4.4.21-8-b-iii-1-28.js | 24 + .../prototype/reduce/15.4.4.21-8-b-iii-1-29.js | 31 + .../prototype/reduce/15.4.4.21-8-b-iii-1-3.js | 38 + .../prototype/reduce/15.4.4.21-8-b-iii-1-30.js | 45 + .../prototype/reduce/15.4.4.21-8-b-iii-1-31.js | 48 + .../prototype/reduce/15.4.4.21-8-b-iii-1-32.js | 38 + .../prototype/reduce/15.4.4.21-8-b-iii-1-33.js | 35 + .../prototype/reduce/15.4.4.21-8-b-iii-1-4.js | 24 + .../prototype/reduce/15.4.4.21-8-b-iii-1-5.js | 44 + .../prototype/reduce/15.4.4.21-8-b-iii-1-6.js | 30 + .../prototype/reduce/15.4.4.21-8-b-iii-1-7.js | 35 + .../prototype/reduce/15.4.4.21-8-b-iii-1-8.js | 26 + .../prototype/reduce/15.4.4.21-8-b-iii-1-9.js | 35 + .../Array/prototype/reduce/15.4.4.21-8-c-1.js | 19 + .../Array/prototype/reduce/15.4.4.21-8-c-2.js | 22 + .../Array/prototype/reduce/15.4.4.21-8-c-3.js | 24 + .../Array/prototype/reduce/15.4.4.21-8-c-4.js | 20 + .../Array/prototype/reduce/15.4.4.21-8-c-5.js | 27 + .../Array/prototype/reduce/15.4.4.21-8-c-6.js | 31 + .../Array/prototype/reduce/15.4.4.21-8-c-7.js | 24 + .../Array/prototype/reduce/15.4.4.21-8-c-8.js | 28 + .../Array/prototype/reduce/15.4.4.21-9-1.js | 21 + .../Array/prototype/reduce/15.4.4.21-9-10.js | 21 + .../Array/prototype/reduce/15.4.4.21-9-2.js | 22 + .../Array/prototype/reduce/15.4.4.21-9-3.js | 23 + .../Array/prototype/reduce/15.4.4.21-9-4.js | 21 + .../Array/prototype/reduce/15.4.4.21-9-5.js | 24 + .../Array/prototype/reduce/15.4.4.21-9-6.js | 26 + .../Array/prototype/reduce/15.4.4.21-9-7.js | 22 + .../Array/prototype/reduce/15.4.4.21-9-8.js | 33 + .../Array/prototype/reduce/15.4.4.21-9-9.js | 32 + .../Array/prototype/reduce/15.4.4.21-9-b-1.js | 18 + .../Array/prototype/reduce/15.4.4.21-9-b-10.js | 41 + .../Array/prototype/reduce/15.4.4.21-9-b-11.js | 36 + .../Array/prototype/reduce/15.4.4.21-9-b-12.js | 40 + .../Array/prototype/reduce/15.4.4.21-9-b-13.js | 34 + .../Array/prototype/reduce/15.4.4.21-9-b-14.js | 36 + .../Array/prototype/reduce/15.4.4.21-9-b-15.js | 39 + .../Array/prototype/reduce/15.4.4.21-9-b-16.js | 41 + .../Array/prototype/reduce/15.4.4.21-9-b-17.js | 40 + .../Array/prototype/reduce/15.4.4.21-9-b-18.js | 38 + .../Array/prototype/reduce/15.4.4.21-9-b-19.js | 40 + .../Array/prototype/reduce/15.4.4.21-9-b-2.js | 33 + .../Array/prototype/reduce/15.4.4.21-9-b-20.js | 38 + .../Array/prototype/reduce/15.4.4.21-9-b-21.js | 46 + .../Array/prototype/reduce/15.4.4.21-9-b-22.js | 43 + .../Array/prototype/reduce/15.4.4.21-9-b-23.js | 40 + .../Array/prototype/reduce/15.4.4.21-9-b-24.js | 36 + .../Array/prototype/reduce/15.4.4.21-9-b-25.js | 40 + .../Array/prototype/reduce/15.4.4.21-9-b-26.js | 33 + .../Array/prototype/reduce/15.4.4.21-9-b-27.js | 36 + .../Array/prototype/reduce/15.4.4.21-9-b-28.js | 39 + .../Array/prototype/reduce/15.4.4.21-9-b-29.js | 41 + .../Array/prototype/reduce/15.4.4.21-9-b-3.js | 39 + .../Array/prototype/reduce/15.4.4.21-9-b-4.js | 40 + .../Array/prototype/reduce/15.4.4.21-9-b-5.js | 38 + .../Array/prototype/reduce/15.4.4.21-9-b-6.js | 40 + .../Array/prototype/reduce/15.4.4.21-9-b-7.js | 38 + .../Array/prototype/reduce/15.4.4.21-9-b-8.js | 46 + .../Array/prototype/reduce/15.4.4.21-9-b-9.js | 36 + .../Array/prototype/reduce/15.4.4.21-9-c-1.js | 25 + .../Array/prototype/reduce/15.4.4.21-9-c-i-1.js | 30 + .../Array/prototype/reduce/15.4.4.21-9-c-i-10.js | 33 + .../Array/prototype/reduce/15.4.4.21-9-c-i-11.js | 44 + .../Array/prototype/reduce/15.4.4.21-9-c-i-12.js | 34 + .../Array/prototype/reduce/15.4.4.21-9-c-i-13.js | 50 + .../Array/prototype/reduce/15.4.4.21-9-c-i-14.js | 39 + .../Array/prototype/reduce/15.4.4.21-9-c-i-15.js | 42 + .../Array/prototype/reduce/15.4.4.21-9-c-i-16.js | 33 + .../Array/prototype/reduce/15.4.4.21-9-c-i-17.js | 35 + .../Array/prototype/reduce/15.4.4.21-9-c-i-18.js | 31 + .../Array/prototype/reduce/15.4.4.21-9-c-i-19.js | 43 + .../Array/prototype/reduce/15.4.4.21-9-c-i-2.js | 25 + .../Array/prototype/reduce/15.4.4.21-9-c-i-20.js | 38 + .../Array/prototype/reduce/15.4.4.21-9-c-i-21.js | 40 + .../Array/prototype/reduce/15.4.4.21-9-c-i-22.js | 31 + .../Array/prototype/reduce/15.4.4.21-9-c-i-25.js | 29 + .../Array/prototype/reduce/15.4.4.21-9-c-i-26.js | 29 + .../Array/prototype/reduce/15.4.4.21-9-c-i-27.js | 29 + .../Array/prototype/reduce/15.4.4.21-9-c-i-28.js | 26 + .../Array/prototype/reduce/15.4.4.21-9-c-i-29.js | 32 + .../Array/prototype/reduce/15.4.4.21-9-c-i-3.js | 39 + .../Array/prototype/reduce/15.4.4.21-9-c-i-30.js | 46 + .../Array/prototype/reduce/15.4.4.21-9-c-i-31.js | 49 + .../Array/prototype/reduce/15.4.4.21-9-c-i-32.js | 39 + .../Array/prototype/reduce/15.4.4.21-9-c-i-33.js | 36 + .../Array/prototype/reduce/15.4.4.21-9-c-i-4.js | 25 + .../Array/prototype/reduce/15.4.4.21-9-c-i-5.js | 47 + .../Array/prototype/reduce/15.4.4.21-9-c-i-6.js | 30 + .../Array/prototype/reduce/15.4.4.21-9-c-i-7.js | 36 + .../Array/prototype/reduce/15.4.4.21-9-c-i-8.js | 27 + .../Array/prototype/reduce/15.4.4.21-9-c-i-9.js | 36 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-1.js | 23 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-10.js | 21 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-11.js | 21 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-12.js | 21 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-13.js | 21 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-14.js | 19 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-16.js | 37 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-17.js | 29 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-18.js | 30 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-19.js | 27 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-2.js | 28 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-20.js | 24 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-21.js | 24 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-22.js | 26 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-23.js | 26 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-24.js | 26 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-25.js | 26 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-26.js | 26 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-27.js | 26 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-28.js | 26 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-29.js | 26 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-3.js | 24 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-30.js | 24 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-31.js | 26 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-32.js | 26 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-33.js | 24 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-34.js | 26 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-35.js | 31 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-37.js | 27 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-4-s.js | 24 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-4.js | 30 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-5.js | 35 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-7.js | 33 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-8.js | 33 + .../Array/prototype/reduce/15.4.4.21-9-c-ii-9.js | 21 + .../built-ins/Array/prototype/reduce/browser.js | 0 .../Array/prototype/reduce/call-with-boolean.js | 20 + .../reduce/callbackfn-resize-arraybuffer.js | 76 + .../built-ins/Array/prototype/reduce/length.js | 30 + .../built-ins/Array/prototype/reduce/name.js | 28 + .../Array/prototype/reduce/not-a-constructor.js | 35 + .../built-ins/Array/prototype/reduce/prop-desc.js | 23 + .../built-ins/Array/prototype/reduce/shell.js | 161 ++ .../Array/prototype/reduceRight/15.4.4.22-1-1.js | 14 + .../Array/prototype/reduceRight/15.4.4.22-1-10.js | 22 + .../Array/prototype/reduceRight/15.4.4.22-1-11.js | 22 + .../Array/prototype/reduceRight/15.4.4.22-1-12.js | 22 + .../Array/prototype/reduceRight/15.4.4.22-1-13.js | 22 + .../Array/prototype/reduceRight/15.4.4.22-1-14.js | 22 + .../Array/prototype/reduceRight/15.4.4.22-1-15.js | 23 + .../Array/prototype/reduceRight/15.4.4.22-1-2.js | 14 + .../Array/prototype/reduceRight/15.4.4.22-1-3.js | 22 + .../Array/prototype/reduceRight/15.4.4.22-1-4.js | 23 + .../Array/prototype/reduceRight/15.4.4.22-1-5.js | 22 + .../Array/prototype/reduceRight/15.4.4.22-1-6.js | 23 + .../Array/prototype/reduceRight/15.4.4.22-1-7.js | 19 + .../Array/prototype/reduceRight/15.4.4.22-1-8.js | 20 + .../Array/prototype/reduceRight/15.4.4.22-1-9.js | 24 + .../Array/prototype/reduceRight/15.4.4.22-10-1.js | 24 + .../Array/prototype/reduceRight/15.4.4.22-10-2.js | 19 + .../Array/prototype/reduceRight/15.4.4.22-10-3.js | 18 + .../Array/prototype/reduceRight/15.4.4.22-10-4.js | 22 + .../Array/prototype/reduceRight/15.4.4.22-10-5.js | 19 + .../Array/prototype/reduceRight/15.4.4.22-10-6.js | 22 + .../Array/prototype/reduceRight/15.4.4.22-10-7.js | 22 + .../Array/prototype/reduceRight/15.4.4.22-10-8.js | 23 + .../Array/prototype/reduceRight/15.4.4.22-2-1.js | 27 + .../Array/prototype/reduceRight/15.4.4.22-2-10.js | 40 + .../Array/prototype/reduceRight/15.4.4.22-2-11.js | 30 + .../Array/prototype/reduceRight/15.4.4.22-2-12.js | 38 + .../Array/prototype/reduceRight/15.4.4.22-2-13.js | 34 + .../Array/prototype/reduceRight/15.4.4.22-2-14.js | 25 + .../Array/prototype/reduceRight/15.4.4.22-2-17.js | 27 + .../Array/prototype/reduceRight/15.4.4.22-2-18.js | 24 + .../Array/prototype/reduceRight/15.4.4.22-2-19.js | 27 + .../Array/prototype/reduceRight/15.4.4.22-2-2.js | 21 + .../Array/prototype/reduceRight/15.4.4.22-2-3.js | 34 + .../Array/prototype/reduceRight/15.4.4.22-2-4.js | 25 + .../Array/prototype/reduceRight/15.4.4.22-2-5.js | 42 + .../Array/prototype/reduceRight/15.4.4.22-2-6.js | 31 + .../Array/prototype/reduceRight/15.4.4.22-2-7.js | 32 + .../Array/prototype/reduceRight/15.4.4.22-2-8.js | 42 + .../Array/prototype/reduceRight/15.4.4.22-2-9.js | 44 + .../Array/prototype/reduceRight/15.4.4.22-3-1.js | 23 + .../Array/prototype/reduceRight/15.4.4.22-3-10.js | 25 + .../Array/prototype/reduceRight/15.4.4.22-3-11.js | 37 + .../Array/prototype/reduceRight/15.4.4.22-3-12.js | 37 + .../Array/prototype/reduceRight/15.4.4.22-3-13.js | 37 + .../Array/prototype/reduceRight/15.4.4.22-3-14.js | 25 + .../Array/prototype/reduceRight/15.4.4.22-3-15.js | 37 + .../Array/prototype/reduceRight/15.4.4.22-3-16.js | 37 + .../Array/prototype/reduceRight/15.4.4.22-3-17.js | 37 + .../Array/prototype/reduceRight/15.4.4.22-3-18.js | 26 + .../Array/prototype/reduceRight/15.4.4.22-3-19.js | 50 + .../Array/prototype/reduceRight/15.4.4.22-3-2.js | 25 + .../Array/prototype/reduceRight/15.4.4.22-3-20.js | 45 + .../Array/prototype/reduceRight/15.4.4.22-3-21.js | 52 + .../Array/prototype/reduceRight/15.4.4.22-3-22.js | 42 + .../Array/prototype/reduceRight/15.4.4.22-3-23.js | 57 + .../Array/prototype/reduceRight/15.4.4.22-3-24.js | 37 + .../Array/prototype/reduceRight/15.4.4.22-3-25.js | 37 + .../Array/prototype/reduceRight/15.4.4.22-3-3.js | 25 + .../Array/prototype/reduceRight/15.4.4.22-3-4.js | 25 + .../Array/prototype/reduceRight/15.4.4.22-3-5.js | 25 + .../Array/prototype/reduceRight/15.4.4.22-3-6.js | 36 + .../Array/prototype/reduceRight/15.4.4.22-3-7.js | 36 + .../Array/prototype/reduceRight/15.4.4.22-3-9.js | 25 + .../Array/prototype/reduceRight/15.4.4.22-4-1.js | 16 + .../Array/prototype/reduceRight/15.4.4.22-4-10.js | 27 + .../Array/prototype/reduceRight/15.4.4.22-4-11.js | 31 + .../Array/prototype/reduceRight/15.4.4.22-4-12.js | 18 + .../Array/prototype/reduceRight/15.4.4.22-4-15.js | 37 + .../Array/prototype/reduceRight/15.4.4.22-4-2.js | 16 + .../Array/prototype/reduceRight/15.4.4.22-4-3.js | 14 + .../Array/prototype/reduceRight/15.4.4.22-4-4.js | 16 + .../Array/prototype/reduceRight/15.4.4.22-4-5.js | 16 + .../Array/prototype/reduceRight/15.4.4.22-4-6.js | 16 + .../Array/prototype/reduceRight/15.4.4.22-4-7.js | 16 + .../Array/prototype/reduceRight/15.4.4.22-4-8.js | 30 + .../Array/prototype/reduceRight/15.4.4.22-4-9.js | 34 + .../Array/prototype/reduceRight/15.4.4.22-5-1.js | 16 + .../Array/prototype/reduceRight/15.4.4.22-5-10.js | 30 + .../Array/prototype/reduceRight/15.4.4.22-5-11.js | 34 + .../Array/prototype/reduceRight/15.4.4.22-5-12.js | 27 + .../Array/prototype/reduceRight/15.4.4.22-5-13.js | 31 + .../Array/prototype/reduceRight/15.4.4.22-5-2.js | 23 + .../Array/prototype/reduceRight/15.4.4.22-5-3.js | 23 + .../Array/prototype/reduceRight/15.4.4.22-5-4.js | 23 + .../Array/prototype/reduceRight/15.4.4.22-5-5.js | 23 + .../Array/prototype/reduceRight/15.4.4.22-5-6.js | 29 + .../Array/prototype/reduceRight/15.4.4.22-5-7.js | 35 + .../Array/prototype/reduceRight/15.4.4.22-5-8.js | 37 + .../Array/prototype/reduceRight/15.4.4.22-5-9.js | 15 + .../Array/prototype/reduceRight/15.4.4.22-7-1.js | 14 + .../Array/prototype/reduceRight/15.4.4.22-7-10.js | 13 + .../Array/prototype/reduceRight/15.4.4.22-7-11.js | 13 + .../Array/prototype/reduceRight/15.4.4.22-7-2.js | 21 + .../Array/prototype/reduceRight/15.4.4.22-7-3.js | 21 + .../Array/prototype/reduceRight/15.4.4.22-7-4.js | 21 + .../Array/prototype/reduceRight/15.4.4.22-7-5.js | 21 + .../Array/prototype/reduceRight/15.4.4.22-7-6.js | 27 + .../Array/prototype/reduceRight/15.4.4.22-7-7.js | 33 + .../Array/prototype/reduceRight/15.4.4.22-7-8.js | 36 + .../Array/prototype/reduceRight/15.4.4.22-7-9.js | 36 + .../Array/prototype/reduceRight/15.4.4.22-8-b-1.js | 31 + .../Array/prototype/reduceRight/15.4.4.22-8-b-2.js | 32 + .../Array/prototype/reduceRight/15.4.4.22-8-b-3.js | 47 + .../prototype/reduceRight/15.4.4.22-8-b-ii-1.js | 25 + .../prototype/reduceRight/15.4.4.22-8-b-ii-2.js | 26 + .../prototype/reduceRight/15.4.4.22-8-b-iii-1-1.js | 29 + .../reduceRight/15.4.4.22-8-b-iii-1-10.js | 32 + .../reduceRight/15.4.4.22-8-b-iii-1-11.js | 43 + .../reduceRight/15.4.4.22-8-b-iii-1-12.js | 34 + .../reduceRight/15.4.4.22-8-b-iii-1-13.js | 49 + .../reduceRight/15.4.4.22-8-b-iii-1-14.js | 40 + .../reduceRight/15.4.4.22-8-b-iii-1-15.js | 41 + .../reduceRight/15.4.4.22-8-b-iii-1-16.js | 32 + .../reduceRight/15.4.4.22-8-b-iii-1-17.js | 34 + .../reduceRight/15.4.4.22-8-b-iii-1-18.js | 30 + .../reduceRight/15.4.4.22-8-b-iii-1-19.js | 36 + .../prototype/reduceRight/15.4.4.22-8-b-iii-1-2.js | 25 + .../reduceRight/15.4.4.22-8-b-iii-1-20.js | 31 + .../reduceRight/15.4.4.22-8-b-iii-1-21.js | 39 + .../reduceRight/15.4.4.22-8-b-iii-1-22.js | 30 + .../reduceRight/15.4.4.22-8-b-iii-1-25.js | 28 + .../reduceRight/15.4.4.22-8-b-iii-1-26.js | 28 + .../reduceRight/15.4.4.22-8-b-iii-1-27.js | 28 + .../reduceRight/15.4.4.22-8-b-iii-1-28.js | 25 + .../reduceRight/15.4.4.22-8-b-iii-1-29.js | 31 + .../prototype/reduceRight/15.4.4.22-8-b-iii-1-3.js | 38 + .../reduceRight/15.4.4.22-8-b-iii-1-30.js | 45 + .../reduceRight/15.4.4.22-8-b-iii-1-31.js | 48 + .../reduceRight/15.4.4.22-8-b-iii-1-32.js | 35 + .../reduceRight/15.4.4.22-8-b-iii-1-33.js | 32 + .../prototype/reduceRight/15.4.4.22-8-b-iii-1-4.js | 24 + .../prototype/reduceRight/15.4.4.22-8-b-iii-1-5.js | 45 + .../prototype/reduceRight/15.4.4.22-8-b-iii-1-6.js | 29 + .../prototype/reduceRight/15.4.4.22-8-b-iii-1-7.js | 34 + .../prototype/reduceRight/15.4.4.22-8-b-iii-1-8.js | 26 + .../prototype/reduceRight/15.4.4.22-8-b-iii-1-9.js | 35 + .../Array/prototype/reduceRight/15.4.4.22-8-c-1.js | 19 + .../Array/prototype/reduceRight/15.4.4.22-8-c-2.js | 22 + .../Array/prototype/reduceRight/15.4.4.22-8-c-3.js | 24 + .../Array/prototype/reduceRight/15.4.4.22-8-c-4.js | 20 + .../Array/prototype/reduceRight/15.4.4.22-8-c-5.js | 27 + .../Array/prototype/reduceRight/15.4.4.22-8-c-6.js | 31 + .../Array/prototype/reduceRight/15.4.4.22-8-c-7.js | 24 + .../Array/prototype/reduceRight/15.4.4.22-8-c-8.js | 28 + .../Array/prototype/reduceRight/15.4.4.22-9-1.js | 23 + .../Array/prototype/reduceRight/15.4.4.22-9-2.js | 22 + .../Array/prototype/reduceRight/15.4.4.22-9-3.js | 23 + .../Array/prototype/reduceRight/15.4.4.22-9-4.js | 21 + .../Array/prototype/reduceRight/15.4.4.22-9-5.js | 24 + .../Array/prototype/reduceRight/15.4.4.22-9-6.js | 25 + .../Array/prototype/reduceRight/15.4.4.22-9-7.js | 22 + .../Array/prototype/reduceRight/15.4.4.22-9-8.js | 35 + .../Array/prototype/reduceRight/15.4.4.22-9-9.js | 29 + .../Array/prototype/reduceRight/15.4.4.22-9-b-1.js | 19 + .../prototype/reduceRight/15.4.4.22-9-b-10.js | 41 + .../prototype/reduceRight/15.4.4.22-9-b-11.js | 36 + .../prototype/reduceRight/15.4.4.22-9-b-12.js | 39 + .../prototype/reduceRight/15.4.4.22-9-b-13.js | 34 + .../prototype/reduceRight/15.4.4.22-9-b-14.js | 36 + .../prototype/reduceRight/15.4.4.22-9-b-15.js | 40 + .../prototype/reduceRight/15.4.4.22-9-b-16.js | 41 + .../prototype/reduceRight/15.4.4.22-9-b-17.js | 40 + .../prototype/reduceRight/15.4.4.22-9-b-18.js | 38 + .../prototype/reduceRight/15.4.4.22-9-b-19.js | 40 + .../Array/prototype/reduceRight/15.4.4.22-9-b-2.js | 33 + .../prototype/reduceRight/15.4.4.22-9-b-20.js | 38 + .../prototype/reduceRight/15.4.4.22-9-b-21.js | 46 + .../prototype/reduceRight/15.4.4.22-9-b-22.js | 43 + .../prototype/reduceRight/15.4.4.22-9-b-23.js | 41 + .../prototype/reduceRight/15.4.4.22-9-b-24.js | 36 + .../prototype/reduceRight/15.4.4.22-9-b-25.js | 40 + .../prototype/reduceRight/15.4.4.22-9-b-26.js | 33 + .../prototype/reduceRight/15.4.4.22-9-b-27.js | 36 + .../prototype/reduceRight/15.4.4.22-9-b-28.js | 39 + .../prototype/reduceRight/15.4.4.22-9-b-29.js | 41 + .../Array/prototype/reduceRight/15.4.4.22-9-b-3.js | 39 + .../Array/prototype/reduceRight/15.4.4.22-9-b-4.js | 40 + .../Array/prototype/reduceRight/15.4.4.22-9-b-5.js | 38 + .../Array/prototype/reduceRight/15.4.4.22-9-b-6.js | 40 + .../Array/prototype/reduceRight/15.4.4.22-9-b-7.js | 38 + .../Array/prototype/reduceRight/15.4.4.22-9-b-8.js | 47 + .../Array/prototype/reduceRight/15.4.4.22-9-b-9.js | 43 + .../Array/prototype/reduceRight/15.4.4.22-9-c-1.js | 25 + .../prototype/reduceRight/15.4.4.22-9-c-i-1.js | 29 + .../prototype/reduceRight/15.4.4.22-9-c-i-10.js | 32 + .../prototype/reduceRight/15.4.4.22-9-c-i-11.js | 43 + .../prototype/reduceRight/15.4.4.22-9-c-i-12.js | 34 + .../prototype/reduceRight/15.4.4.22-9-c-i-13.js | 49 + .../prototype/reduceRight/15.4.4.22-9-c-i-14.js | 39 + .../prototype/reduceRight/15.4.4.22-9-c-i-15.js | 41 + .../prototype/reduceRight/15.4.4.22-9-c-i-16.js | 32 + .../prototype/reduceRight/15.4.4.22-9-c-i-17.js | 34 + .../prototype/reduceRight/15.4.4.22-9-c-i-18.js | 30 + .../prototype/reduceRight/15.4.4.22-9-c-i-19.js | 36 + .../prototype/reduceRight/15.4.4.22-9-c-i-2.js | 24 + .../prototype/reduceRight/15.4.4.22-9-c-i-20.js | 31 + .../prototype/reduceRight/15.4.4.22-9-c-i-21.js | 39 + .../prototype/reduceRight/15.4.4.22-9-c-i-22.js | 30 + .../prototype/reduceRight/15.4.4.22-9-c-i-25.js | 28 + .../prototype/reduceRight/15.4.4.22-9-c-i-26.js | 28 + .../prototype/reduceRight/15.4.4.22-9-c-i-27.js | 28 + .../prototype/reduceRight/15.4.4.22-9-c-i-28.js | 24 + .../prototype/reduceRight/15.4.4.22-9-c-i-29.js | 32 + .../prototype/reduceRight/15.4.4.22-9-c-i-3.js | 38 + .../prototype/reduceRight/15.4.4.22-9-c-i-30.js | 45 + .../prototype/reduceRight/15.4.4.22-9-c-i-31.js | 47 + .../prototype/reduceRight/15.4.4.22-9-c-i-32.js | 36 + .../prototype/reduceRight/15.4.4.22-9-c-i-33.js | 34 + .../prototype/reduceRight/15.4.4.22-9-c-i-4.js | 24 + .../prototype/reduceRight/15.4.4.22-9-c-i-5.js | 44 + .../prototype/reduceRight/15.4.4.22-9-c-i-6.js | 29 + .../prototype/reduceRight/15.4.4.22-9-c-i-7.js | 34 + .../prototype/reduceRight/15.4.4.22-9-c-i-8.js | 26 + .../prototype/reduceRight/15.4.4.22-9-c-i-9.js | 35 + .../prototype/reduceRight/15.4.4.22-9-c-ii-1.js | 23 + .../prototype/reduceRight/15.4.4.22-9-c-ii-10.js | 21 + .../prototype/reduceRight/15.4.4.22-9-c-ii-11.js | 23 + .../prototype/reduceRight/15.4.4.22-9-c-ii-12.js | 25 + .../prototype/reduceRight/15.4.4.22-9-c-ii-13.js | 25 + .../prototype/reduceRight/15.4.4.22-9-c-ii-14.js | 15 + .../prototype/reduceRight/15.4.4.22-9-c-ii-16.js | 29 + .../prototype/reduceRight/15.4.4.22-9-c-ii-17.js | 28 + .../prototype/reduceRight/15.4.4.22-9-c-ii-18.js | 27 + .../prototype/reduceRight/15.4.4.22-9-c-ii-19.js | 25 + .../prototype/reduceRight/15.4.4.22-9-c-ii-2.js | 26 + .../prototype/reduceRight/15.4.4.22-9-c-ii-20.js | 24 + .../prototype/reduceRight/15.4.4.22-9-c-ii-21.js | 24 + .../prototype/reduceRight/15.4.4.22-9-c-ii-22.js | 26 + .../prototype/reduceRight/15.4.4.22-9-c-ii-23.js | 26 + .../prototype/reduceRight/15.4.4.22-9-c-ii-24.js | 26 + .../prototype/reduceRight/15.4.4.22-9-c-ii-25.js | 27 + .../prototype/reduceRight/15.4.4.22-9-c-ii-26.js | 27 + .../prototype/reduceRight/15.4.4.22-9-c-ii-27.js | 27 + .../prototype/reduceRight/15.4.4.22-9-c-ii-28.js | 27 + .../prototype/reduceRight/15.4.4.22-9-c-ii-29.js | 27 + .../prototype/reduceRight/15.4.4.22-9-c-ii-3.js | 24 + .../prototype/reduceRight/15.4.4.22-9-c-ii-30.js | 26 + .../prototype/reduceRight/15.4.4.22-9-c-ii-31.js | 27 + .../prototype/reduceRight/15.4.4.22-9-c-ii-32.js | 27 + .../prototype/reduceRight/15.4.4.22-9-c-ii-33.js | 24 + .../prototype/reduceRight/15.4.4.22-9-c-ii-34.js | 28 + .../prototype/reduceRight/15.4.4.22-9-c-ii-35.js | 31 + .../prototype/reduceRight/15.4.4.22-9-c-ii-37.js | 27 + .../prototype/reduceRight/15.4.4.22-9-c-ii-4-s.js | 24 + .../prototype/reduceRight/15.4.4.22-9-c-ii-4.js | 29 + .../prototype/reduceRight/15.4.4.22-9-c-ii-5.js | 36 + .../prototype/reduceRight/15.4.4.22-9-c-ii-7.js | 35 + .../prototype/reduceRight/15.4.4.22-9-c-ii-8.js | 29 + .../prototype/reduceRight/15.4.4.22-9-c-ii-9.js | 21 + .../Array/prototype/reduceRight/browser.js | 0 .../prototype/reduceRight/call-with-boolean.js | 20 + .../reduceRight/callbackfn-resize-arraybuffer.js | 81 + .../reduceRight/length-near-integer-limit.js | 59 + .../Array/prototype/reduceRight/length.js | 30 + .../built-ins/Array/prototype/reduceRight/name.js | 28 + .../prototype/reduceRight/not-a-constructor.js | 35 + .../Array/prototype/reduceRight/prop-desc.js | 23 + .../built-ins/Array/prototype/reduceRight/shell.js | 161 ++ .../Array/prototype/reverse/S15.4.4.8_A1_T1.js | 43 + .../Array/prototype/reverse/S15.4.4.8_A1_T2.js | 108 + .../Array/prototype/reverse/S15.4.4.8_A2_T1.js | 113 + .../Array/prototype/reverse/S15.4.4.8_A2_T2.js | 113 + .../Array/prototype/reverse/S15.4.4.8_A2_T3.js | 113 + .../Array/prototype/reverse/S15.4.4.8_A3_T3.js | 38 + .../Array/prototype/reverse/S15.4.4.8_A4_T1.js | 62 + .../Array/prototype/reverse/S15.4.4.8_A4_T2.js | 63 + .../Array/prototype/reverse/array-has-one-entry.js | 25 + .../built-ins/Array/prototype/reverse/browser.js | 0 .../Array/prototype/reverse/call-with-boolean.js | 20 + .../reverse/get_if_present_with_delete.js | 39 + .../length-exceeding-integer-limit-with-object.js | 35 + .../length-exceeding-integer-limit-with-proxy.js | 122 ++ .../built-ins/Array/prototype/reverse/length.js | 30 + .../built-ins/Array/prototype/reverse/name.js | 28 + .../Array/prototype/reverse/not-a-constructor.js | 35 + .../built-ins/Array/prototype/reverse/prop-desc.js | 23 + .../built-ins/Array/prototype/reverse/shell.js | 33 + .../test262/built-ins/Array/prototype/shell.js | 0 .../Array/prototype/shift/S15.4.4.9_A1.1_T1.js | 33 + .../Array/prototype/shift/S15.4.4.9_A1.2_T1.js | 60 + .../Array/prototype/shift/S15.4.4.9_A2_T1.js | 49 + .../Array/prototype/shift/S15.4.4.9_A2_T2.js | 71 + .../Array/prototype/shift/S15.4.4.9_A2_T3.js | 37 + .../Array/prototype/shift/S15.4.4.9_A2_T4.js | 48 + .../Array/prototype/shift/S15.4.4.9_A2_T5.js | 126 ++ .../Array/prototype/shift/S15.4.4.9_A3_T3.js | 33 + .../Array/prototype/shift/S15.4.4.9_A4_T1.js | 58 + .../Array/prototype/shift/S15.4.4.9_A4_T2.js | 59 + .../built-ins/Array/prototype/shift/browser.js | 0 .../Array/prototype/shift/call-with-boolean.js | 20 + .../built-ins/Array/prototype/shift/length.js | 30 + .../built-ins/Array/prototype/shift/name.js | 28 + .../Array/prototype/shift/not-a-constructor.js | 35 + .../built-ins/Array/prototype/shift/prop-desc.js | 23 + .../prototype/shift/set-length-array-is-frozen.js | 45 + .../set-length-array-length-is-non-writable.js | 45 + .../shift/set-length-zero-array-is-frozen.js | 34 + ...set-length-zero-array-length-is-non-writable.js | 34 + .../built-ins/Array/prototype/shift/shell.js | 0 ...ows-when-this-value-length-is-writable-false.js | 37 + .../Array/prototype/slice/15.4.4.10-10-c-ii-1.js | 25 + .../Array/prototype/slice/S15.4.4.10_A1.1_T1.js | 40 + .../Array/prototype/slice/S15.4.4.10_A1.1_T2.js | 28 + .../Array/prototype/slice/S15.4.4.10_A1.1_T3.js | 28 + .../Array/prototype/slice/S15.4.4.10_A1.1_T4.js | 28 + .../Array/prototype/slice/S15.4.4.10_A1.1_T5.js | 36 + .../Array/prototype/slice/S15.4.4.10_A1.1_T6.js | 36 + .../Array/prototype/slice/S15.4.4.10_A1.1_T7.js | 36 + .../Array/prototype/slice/S15.4.4.10_A1.2_T1.js | 32 + .../Array/prototype/slice/S15.4.4.10_A1.2_T2.js | 32 + .../Array/prototype/slice/S15.4.4.10_A1.2_T3.js | 32 + .../Array/prototype/slice/S15.4.4.10_A1.2_T4.js | 48 + .../Array/prototype/slice/S15.4.4.10_A1.3_T1.js | 40 + .../Array/prototype/slice/S15.4.4.10_A1.3_T2.js | 28 + .../Array/prototype/slice/S15.4.4.10_A1.3_T3.js | 28 + .../Array/prototype/slice/S15.4.4.10_A1.3_T4.js | 28 + .../Array/prototype/slice/S15.4.4.10_A1.4_T1.js | 40 + .../Array/prototype/slice/S15.4.4.10_A1.4_T2.js | 36 + .../Array/prototype/slice/S15.4.4.10_A1.4_T3.js | 44 + .../Array/prototype/slice/S15.4.4.10_A1.4_T4.js | 28 + .../Array/prototype/slice/S15.4.4.10_A1.5_T1.js | 34 + .../Array/prototype/slice/S15.4.4.10_A1.5_T2.js | 34 + .../Array/prototype/slice/S15.4.4.10_A2.1_T1.js | 34 + .../Array/prototype/slice/S15.4.4.10_A2.1_T2.js | 38 + .../Array/prototype/slice/S15.4.4.10_A2.1_T3.js | 26 + .../Array/prototype/slice/S15.4.4.10_A2.1_T4.js | 38 + .../Array/prototype/slice/S15.4.4.10_A2.1_T5.js | 45 + .../Array/prototype/slice/S15.4.4.10_A2.2_T1.js | 34 + .../Array/prototype/slice/S15.4.4.10_A2.2_T2.js | 26 + .../Array/prototype/slice/S15.4.4.10_A2.2_T3.js | 46 + .../Array/prototype/slice/S15.4.4.10_A2.2_T4.js | 26 + .../Array/prototype/slice/S15.4.4.10_A2.2_T5.js | 45 + .../Array/prototype/slice/S15.4.4.10_A2_T1.js | 49 + .../Array/prototype/slice/S15.4.4.10_A2_T2.js | 49 + .../Array/prototype/slice/S15.4.4.10_A2_T3.js | 49 + .../Array/prototype/slice/S15.4.4.10_A2_T4.js | 49 + .../Array/prototype/slice/S15.4.4.10_A2_T5.js | 47 + .../Array/prototype/slice/S15.4.4.10_A2_T6.js | 47 + .../Array/prototype/slice/S15.4.4.10_A3_T1.js | 19 + .../Array/prototype/slice/S15.4.4.10_A3_T2.js | 19 + .../Array/prototype/slice/S15.4.4.10_A3_T3.js | 24 + .../Array/prototype/slice/S15.4.4.10_A4_T1.js | 27 + .../built-ins/Array/prototype/slice/browser.js | 0 .../Array/prototype/slice/call-with-boolean.js | 13 + .../prototype/slice/create-ctor-non-object.js | 45 + .../Array/prototype/slice/create-ctor-poisoned.js | 29 + .../slice/create-non-array-invalid-len.js | 44 + .../Array/prototype/slice/create-non-array.js | 35 + .../slice/create-proto-from-ctor-realm-array.js | 45 + .../create-proto-from-ctor-realm-non-array.js | 46 + .../slice/create-proxied-array-invalid-len.js | 54 + .../Array/prototype/slice/create-proxy.js | 41 + .../Array/prototype/slice/create-revoked-proxy.js | 41 + .../Array/prototype/slice/create-species-abrupt.js | 35 + .../prototype/slice/create-species-neg-zero.js | 47 + .../prototype/slice/create-species-non-ctor.js | 41 + .../Array/prototype/slice/create-species-null.js | 35 + .../prototype/slice/create-species-poisoned.js | 34 + .../Array/prototype/slice/create-species-undef.js | 36 + .../Array/prototype/slice/create-species.js | 45 + ...length-exceeding-integer-limit-proxied-array.js | 59 + .../slice/length-exceeding-integer-limit.js | 50 + .../built-ins/Array/prototype/slice/length.js | 30 + .../built-ins/Array/prototype/slice/name.js | 28 + .../Array/prototype/slice/not-a-constructor.js | 35 + .../built-ins/Array/prototype/slice/prop-desc.js | 23 + .../built-ins/Array/prototype/slice/shell.js | 0 .../prototype/slice/target-array-non-extensible.js | 41 + .../target-array-with-non-configurable-property.js | 43 + .../target-array-with-non-writable-property.js | 38 + .../Array/prototype/some/15.4.4.17-1-1.js | 14 + .../Array/prototype/some/15.4.4.17-1-10.js | 18 + .../Array/prototype/some/15.4.4.17-1-11.js | 20 + .../Array/prototype/some/15.4.4.17-1-12.js | 20 + .../Array/prototype/some/15.4.4.17-1-13.js | 18 + .../Array/prototype/some/15.4.4.17-1-14.js | 19 + .../Array/prototype/some/15.4.4.17-1-15.js | 19 + .../Array/prototype/some/15.4.4.17-1-2.js | 14 + .../Array/prototype/some/15.4.4.17-1-3.js | 18 + .../Array/prototype/some/15.4.4.17-1-4.js | 20 + .../Array/prototype/some/15.4.4.17-1-5.js | 18 + .../Array/prototype/some/15.4.4.17-1-6.js | 20 + .../Array/prototype/some/15.4.4.17-1-7.js | 15 + .../Array/prototype/some/15.4.4.17-1-8.js | 17 + .../Array/prototype/some/15.4.4.17-1-9.js | 21 + .../Array/prototype/some/15.4.4.17-2-1.js | 29 + .../Array/prototype/some/15.4.4.17-2-10.js | 39 + .../Array/prototype/some/15.4.4.17-2-11.js | 30 + .../Array/prototype/some/15.4.4.17-2-12.js | 38 + .../Array/prototype/some/15.4.4.17-2-13.js | 34 + .../Array/prototype/some/15.4.4.17-2-14.js | 26 + .../Array/prototype/some/15.4.4.17-2-17.js | 27 + .../Array/prototype/some/15.4.4.17-2-18.js | 26 + .../Array/prototype/some/15.4.4.17-2-19.js | 29 + .../Array/prototype/some/15.4.4.17-2-2.js | 22 + .../Array/prototype/some/15.4.4.17-2-3.js | 35 + .../Array/prototype/some/15.4.4.17-2-4.js | 28 + .../Array/prototype/some/15.4.4.17-2-5.js | 44 + .../Array/prototype/some/15.4.4.17-2-6.js | 34 + .../Array/prototype/some/15.4.4.17-2-7.js | 35 + .../Array/prototype/some/15.4.4.17-2-8.js | 42 + .../Array/prototype/some/15.4.4.17-2-9.js | 47 + .../Array/prototype/some/15.4.4.17-3-1.js | 24 + .../Array/prototype/some/15.4.4.17-3-10.js | 24 + .../Array/prototype/some/15.4.4.17-3-11.js | 29 + .../Array/prototype/some/15.4.4.17-3-12.js | 29 + .../Array/prototype/some/15.4.4.17-3-13.js | 29 + .../Array/prototype/some/15.4.4.17-3-14.js | 34 + .../Array/prototype/some/15.4.4.17-3-15.js | 29 + .../Array/prototype/some/15.4.4.17-3-16.js | 27 + .../Array/prototype/some/15.4.4.17-3-17.js | 29 + .../Array/prototype/some/15.4.4.17-3-18.js | 27 + .../Array/prototype/some/15.4.4.17-3-19.js | 37 + .../Array/prototype/some/15.4.4.17-3-2.js | 28 + .../Array/prototype/some/15.4.4.17-3-20.js | 37 + .../Array/prototype/some/15.4.4.17-3-21.js | 44 + .../Array/prototype/some/15.4.4.17-3-22.js | 43 + .../Array/prototype/some/15.4.4.17-3-23.js | 51 + .../Array/prototype/some/15.4.4.17-3-24.js | 29 + .../Array/prototype/some/15.4.4.17-3-25.js | 27 + .../Array/prototype/some/15.4.4.17-3-28.js | 24 + .../Array/prototype/some/15.4.4.17-3-29.js | 28 + .../Array/prototype/some/15.4.4.17-3-3.js | 24 + .../Array/prototype/some/15.4.4.17-3-4.js | 24 + .../Array/prototype/some/15.4.4.17-3-5.js | 24 + .../Array/prototype/some/15.4.4.17-3-6.js | 29 + .../Array/prototype/some/15.4.4.17-3-7.js | 29 + .../Array/prototype/some/15.4.4.17-3-8.js | 26 + .../Array/prototype/some/15.4.4.17-3-9.js | 26 + .../Array/prototype/some/15.4.4.17-4-1.js | 14 + .../Array/prototype/some/15.4.4.17-4-10.js | 27 + .../Array/prototype/some/15.4.4.17-4-11.js | 31 + .../Array/prototype/some/15.4.4.17-4-12.js | 15 + .../Array/prototype/some/15.4.4.17-4-15.js | 35 + .../Array/prototype/some/15.4.4.17-4-2.js | 16 + .../Array/prototype/some/15.4.4.17-4-3.js | 14 + .../Array/prototype/some/15.4.4.17-4-4.js | 14 + .../Array/prototype/some/15.4.4.17-4-5.js | 14 + .../Array/prototype/some/15.4.4.17-4-6.js | 14 + .../Array/prototype/some/15.4.4.17-4-7.js | 16 + .../Array/prototype/some/15.4.4.17-4-8.js | 30 + .../Array/prototype/some/15.4.4.17-4-9.js | 34 + .../Array/prototype/some/15.4.4.17-5-1-s.js | 22 + .../Array/prototype/some/15.4.4.17-5-1.js | 22 + .../Array/prototype/some/15.4.4.17-5-10.js | 17 + .../Array/prototype/some/15.4.4.17-5-11.js | 17 + .../Array/prototype/some/15.4.4.17-5-12.js | 17 + .../Array/prototype/some/15.4.4.17-5-13.js | 17 + .../Array/prototype/some/15.4.4.17-5-14.js | 15 + .../Array/prototype/some/15.4.4.17-5-15.js | 17 + .../Array/prototype/some/15.4.4.17-5-16.js | 17 + .../Array/prototype/some/15.4.4.17-5-17.js | 15 + .../Array/prototype/some/15.4.4.17-5-18.js | 17 + .../Array/prototype/some/15.4.4.17-5-19.js | 21 + .../Array/prototype/some/15.4.4.17-5-2.js | 22 + .../Array/prototype/some/15.4.4.17-5-21.js | 17 + .../Array/prototype/some/15.4.4.17-5-22.js | 15 + .../Array/prototype/some/15.4.4.17-5-23.js | 15 + .../Array/prototype/some/15.4.4.17-5-24.js | 15 + .../Array/prototype/some/15.4.4.17-5-25.js | 23 + .../Array/prototype/some/15.4.4.17-5-3.js | 22 + .../Array/prototype/some/15.4.4.17-5-4.js | 25 + .../Array/prototype/some/15.4.4.17-5-5.js | 23 + .../Array/prototype/some/15.4.4.17-5-6.js | 22 + .../Array/prototype/some/15.4.4.17-5-7.js | 15 + .../Array/prototype/some/15.4.4.17-5-9.js | 17 + .../Array/prototype/some/15.4.4.17-7-1.js | 28 + .../Array/prototype/some/15.4.4.17-7-2.js | 25 + .../Array/prototype/some/15.4.4.17-7-3.js | 25 + .../Array/prototype/some/15.4.4.17-7-4.js | 25 + .../Array/prototype/some/15.4.4.17-7-5.js | 27 + .../Array/prototype/some/15.4.4.17-7-6.js | 29 + .../Array/prototype/some/15.4.4.17-7-8.js | 25 + .../Array/prototype/some/15.4.4.17-7-9.js | 35 + .../Array/prototype/some/15.4.4.17-7-b-1.js | 25 + .../Array/prototype/some/15.4.4.17-7-b-10.js | 35 + .../Array/prototype/some/15.4.4.17-7-b-11.js | 32 + .../Array/prototype/some/15.4.4.17-7-b-12.js | 38 + .../Array/prototype/some/15.4.4.17-7-b-13.js | 32 + .../Array/prototype/some/15.4.4.17-7-b-14.js | 30 + .../Array/prototype/some/15.4.4.17-7-b-15.js | 37 + .../Array/prototype/some/15.4.4.17-7-b-16.js | 39 + .../Array/prototype/some/15.4.4.17-7-b-2.js | 29 + .../Array/prototype/some/15.4.4.17-7-b-3.js | 33 + .../Array/prototype/some/15.4.4.17-7-b-4.js | 38 + .../Array/prototype/some/15.4.4.17-7-b-5.js | 36 + .../Array/prototype/some/15.4.4.17-7-b-6.js | 37 + .../Array/prototype/some/15.4.4.17-7-b-7.js | 35 + .../Array/prototype/some/15.4.4.17-7-b-8.js | 39 + .../Array/prototype/some/15.4.4.17-7-b-9.js | 37 + .../Array/prototype/some/15.4.4.17-7-c-i-1.js | 27 + .../Array/prototype/some/15.4.4.17-7-c-i-10.js | 31 + .../Array/prototype/some/15.4.4.17-7-c-i-11.js | 40 + .../Array/prototype/some/15.4.4.17-7-c-i-12.js | 32 + .../Array/prototype/some/15.4.4.17-7-c-i-13.js | 46 + .../Array/prototype/some/15.4.4.17-7-c-i-14.js | 37 + .../Array/prototype/some/15.4.4.17-7-c-i-15.js | 37 + .../Array/prototype/some/15.4.4.17-7-c-i-16.js | 29 + .../Array/prototype/some/15.4.4.17-7-c-i-17.js | 28 + .../Array/prototype/some/15.4.4.17-7-c-i-18.js | 27 + .../Array/prototype/some/15.4.4.17-7-c-i-19.js | 31 + .../Array/prototype/some/15.4.4.17-7-c-i-2.js | 22 + .../Array/prototype/some/15.4.4.17-7-c-i-20.js | 30 + .../Array/prototype/some/15.4.4.17-7-c-i-21.js | 32 + .../Array/prototype/some/15.4.4.17-7-c-i-22.js | 25 + .../Array/prototype/some/15.4.4.17-7-c-i-25.js | 25 + .../Array/prototype/some/15.4.4.17-7-c-i-26.js | 35 + .../Array/prototype/some/15.4.4.17-7-c-i-27.js | 40 + .../Array/prototype/some/15.4.4.17-7-c-i-28.js | 41 + .../Array/prototype/some/15.4.4.17-7-c-i-29.js | 43 + .../Array/prototype/some/15.4.4.17-7-c-i-3.js | 34 + .../Array/prototype/some/15.4.4.17-7-c-i-30.js | 34 + .../Array/prototype/some/15.4.4.17-7-c-i-31.js | 33 + .../Array/prototype/some/15.4.4.17-7-c-i-4.js | 24 + .../Array/prototype/some/15.4.4.17-7-c-i-5.js | 42 + .../Array/prototype/some/15.4.4.17-7-c-i-6.js | 29 + .../Array/prototype/some/15.4.4.17-7-c-i-7.js | 32 + .../Array/prototype/some/15.4.4.17-7-c-i-8.js | 24 + .../Array/prototype/some/15.4.4.17-7-c-i-9.js | 33 + .../Array/prototype/some/15.4.4.17-7-c-ii-1.js | 22 + .../Array/prototype/some/15.4.4.17-7-c-ii-10.js | 15 + .../Array/prototype/some/15.4.4.17-7-c-ii-11.js | 15 + .../Array/prototype/some/15.4.4.17-7-c-ii-12.js | 15 + .../Array/prototype/some/15.4.4.17-7-c-ii-13.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-ii-16.js | 22 + .../Array/prototype/some/15.4.4.17-7-c-ii-17.js | 22 + .../Array/prototype/some/15.4.4.17-7-c-ii-18.js | 23 + .../Array/prototype/some/15.4.4.17-7-c-ii-19.js | 26 + .../Array/prototype/some/15.4.4.17-7-c-ii-2.js | 23 + .../Array/prototype/some/15.4.4.17-7-c-ii-20.js | 26 + .../Array/prototype/some/15.4.4.17-7-c-ii-21.js | 35 + .../Array/prototype/some/15.4.4.17-7-c-ii-22.js | 35 + .../Array/prototype/some/15.4.4.17-7-c-ii-23.js | 23 + .../Array/prototype/some/15.4.4.17-7-c-ii-3.js | 28 + .../Array/prototype/some/15.4.4.17-7-c-ii-4.js | 28 + .../Array/prototype/some/15.4.4.17-7-c-ii-5.js | 30 + .../Array/prototype/some/15.4.4.17-7-c-ii-6.js | 21 + .../Array/prototype/some/15.4.4.17-7-c-ii-7.js | 34 + .../Array/prototype/some/15.4.4.17-7-c-ii-8.js | 26 + .../Array/prototype/some/15.4.4.17-7-c-ii-9.js | 15 + .../Array/prototype/some/15.4.4.17-7-c-iii-1.js | 24 + .../Array/prototype/some/15.4.4.17-7-c-iii-10.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-11.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-12.js | 20 + .../Array/prototype/some/15.4.4.17-7-c-iii-13.js | 21 + .../Array/prototype/some/15.4.4.17-7-c-iii-14.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-15.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-16.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-17.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-18.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-19.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-2.js | 24 + .../Array/prototype/some/15.4.4.17-7-c-iii-20.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-21.js | 15 + .../Array/prototype/some/15.4.4.17-7-c-iii-22.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-23.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-24.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-25.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-26.js | 19 + .../Array/prototype/some/15.4.4.17-7-c-iii-28.js | 47 + .../Array/prototype/some/15.4.4.17-7-c-iii-29.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-3.js | 26 + .../Array/prototype/some/15.4.4.17-7-c-iii-4.js | 22 + .../Array/prototype/some/15.4.4.17-7-c-iii-5.js | 21 + .../Array/prototype/some/15.4.4.17-7-c-iii-6.js | 21 + .../Array/prototype/some/15.4.4.17-7-c-iii-7.js | 21 + .../Array/prototype/some/15.4.4.17-7-c-iii-8.js | 17 + .../Array/prototype/some/15.4.4.17-7-c-iii-9.js | 17 + .../Array/prototype/some/15.4.4.17-8-1.js | 14 + .../Array/prototype/some/15.4.4.17-8-10.js | 27 + .../Array/prototype/some/15.4.4.17-8-11.js | 25 + .../Array/prototype/some/15.4.4.17-8-12.js | 24 + .../Array/prototype/some/15.4.4.17-8-13.js | 25 + .../Array/prototype/some/15.4.4.17-8-2.js | 23 + .../Array/prototype/some/15.4.4.17-8-3.js | 23 + .../Array/prototype/some/15.4.4.17-8-4.js | 23 + .../Array/prototype/some/15.4.4.17-8-5.js | 23 + .../Array/prototype/some/15.4.4.17-8-6.js | 29 + .../Array/prototype/some/15.4.4.17-8-7.js | 35 + .../Array/prototype/some/15.4.4.17-8-8.js | 38 + .../built-ins/Array/prototype/some/browser.js | 0 .../Array/prototype/some/call-with-boolean.js | 20 + .../some/callbackfn-resize-arraybuffer.js | 74 + .../built-ins/Array/prototype/some/length.js | 30 + .../test262/built-ins/Array/prototype/some/name.js | 28 + .../Array/prototype/some/not-a-constructor.js | 31 + .../built-ins/Array/prototype/some/prop-desc.js | 23 + .../built-ins/Array/prototype/some/shell.js | 161 ++ .../Array/prototype/sort/S15.4.4.11_A1.1_T1.js | 27 + .../Array/prototype/sort/S15.4.4.11_A1.2_T1.js | 45 + .../Array/prototype/sort/S15.4.4.11_A1.2_T2.js | 51 + .../Array/prototype/sort/S15.4.4.11_A1.3_T1.js | 27 + .../Array/prototype/sort/S15.4.4.11_A1.4_T1.js | 42 + .../Array/prototype/sort/S15.4.4.11_A1.4_T2.js | 48 + .../Array/prototype/sort/S15.4.4.11_A1.5_T1.js | 40 + .../Array/prototype/sort/S15.4.4.11_A2.1_T1.js | 26 + .../Array/prototype/sort/S15.4.4.11_A2.1_T2.js | 26 + .../Array/prototype/sort/S15.4.4.11_A2.1_T3.js | 36 + .../Array/prototype/sort/S15.4.4.11_A2.2_T1.js | 31 + .../Array/prototype/sort/S15.4.4.11_A2.2_T2.js | 31 + .../Array/prototype/sort/S15.4.4.11_A2.2_T3.js | 41 + .../Array/prototype/sort/S15.4.4.11_A3_T1.js | 54 + .../Array/prototype/sort/S15.4.4.11_A3_T2.js | 62 + .../Array/prototype/sort/S15.4.4.11_A4_T3.js | 37 + .../Array/prototype/sort/S15.4.4.11_A5_T1.js | 18 + .../Array/prototype/sort/S15.4.4.11_A6_T2.js | 63 + .../Array/prototype/sort/S15.4.4.11_A8.js | 25 + .../built-ins/Array/prototype/sort/browser.js | 0 .../built-ins/Array/prototype/sort/bug_596_1.js | 26 + .../built-ins/Array/prototype/sort/bug_596_2.js | 57 + .../Array/prototype/sort/call-with-primitive.js | 32 + .../sort/comparefn-nonfunction-call-throws.js | 97 + .../built-ins/Array/prototype/sort/length.js | 30 + .../test262/built-ins/Array/prototype/sort/name.js | 28 + .../Array/prototype/sort/not-a-constructor.js | 31 + .../prototype/sort/precise-comparefn-throws.js | 54 + .../sort/precise-getter-appends-elements.js | 51 + .../sort/precise-getter-decreases-length.js | 41 + .../sort/precise-getter-deletes-predecessor.js | 45 + .../sort/precise-getter-deletes-successor.js | 46 + .../sort/precise-getter-increases-length.js | 51 + .../prototype/sort/precise-getter-pops-elements.js | 42 + .../sort/precise-getter-sets-predecessor.js | 43 + .../sort/precise-getter-sets-successor.js | 43 + .../prototype/sort/precise-prototype-accessors.js | 44 + .../prototype/sort/precise-prototype-element.js | 29 + .../sort/precise-setter-appends-elements.js | 44 + .../sort/precise-setter-decreases-length.js | 39 + .../sort/precise-setter-deletes-predecessor.js | 42 + .../sort/precise-setter-deletes-successor.js | 41 + .../sort/precise-setter-increases-length.js | 45 + .../prototype/sort/precise-setter-pops-elements.js | 40 + .../sort/precise-setter-sets-predecessor.js | 41 + .../sort/precise-setter-sets-successor.js | 41 + .../built-ins/Array/prototype/sort/prop-desc.js | 23 + .../built-ins/Array/prototype/sort/shell.js | 0 .../Array/prototype/sort/stability-11-elements.js | 38 + .../prototype/sort/stability-2048-elements.js | 2083 ++++++++++++++++++ .../Array/prototype/sort/stability-5-elements.js | 29 + .../Array/prototype/sort/stability-513-elements.js | 548 +++++ .../Array/prototype/splice/15.4.4.12-9-a-1.js | 17 + .../Array/prototype/splice/15.4.4.12-9-c-ii-1.js | 40 + .../Array/prototype/splice/S15.4.4.12_A1.1_T1.js | 44 + .../Array/prototype/splice/S15.4.4.12_A1.1_T2.js | 52 + .../Array/prototype/splice/S15.4.4.12_A1.1_T3.js | 44 + .../Array/prototype/splice/S15.4.4.12_A1.1_T4.js | 52 + .../Array/prototype/splice/S15.4.4.12_A1.1_T5.js | 44 + .../Array/prototype/splice/S15.4.4.12_A1.1_T6.js | 52 + .../Array/prototype/splice/S15.4.4.12_A1.2_T1.js | 36 + .../Array/prototype/splice/S15.4.4.12_A1.2_T2.js | 36 + .../Array/prototype/splice/S15.4.4.12_A1.2_T3.js | 44 + .../Array/prototype/splice/S15.4.4.12_A1.2_T4.js | 44 + .../Array/prototype/splice/S15.4.4.12_A1.2_T5.js | 44 + .../Array/prototype/splice/S15.4.4.12_A1.3_T1.js | 36 + .../Array/prototype/splice/S15.4.4.12_A1.3_T2.js | 36 + .../Array/prototype/splice/S15.4.4.12_A1.3_T3.js | 44 + .../Array/prototype/splice/S15.4.4.12_A1.3_T4.js | 44 + .../Array/prototype/splice/S15.4.4.12_A1.3_T5.js | 44 + .../Array/prototype/splice/S15.4.4.12_A1.4_T1.js | 44 + .../Array/prototype/splice/S15.4.4.12_A1.4_T2.js | 52 + .../Array/prototype/splice/S15.4.4.12_A1.4_T3.js | 44 + .../Array/prototype/splice/S15.4.4.12_A1.4_T4.js | 52 + .../Array/prototype/splice/S15.4.4.12_A1.4_T5.js | 44 + .../Array/prototype/splice/S15.4.4.12_A1.4_T6.js | 52 + .../Array/prototype/splice/S15.4.4.12_A1.5_T1.js | 42 + .../Array/prototype/splice/S15.4.4.12_A1.5_T2.js | 42 + .../Array/prototype/splice/S15.4.4.12_A2.1_T1.js | 42 + .../Array/prototype/splice/S15.4.4.12_A2.1_T2.js | 42 + .../Array/prototype/splice/S15.4.4.12_A2.1_T3.js | 38 + .../Array/prototype/splice/S15.4.4.12_A2.1_T4.js | 42 + .../Array/prototype/splice/S15.4.4.12_A2.1_T5.js | 49 + .../Array/prototype/splice/S15.4.4.12_A2.2_T1.js | 42 + .../Array/prototype/splice/S15.4.4.12_A2.2_T2.js | 34 + .../Array/prototype/splice/S15.4.4.12_A2.2_T3.js | 42 + .../Array/prototype/splice/S15.4.4.12_A2.2_T4.js | 34 + .../Array/prototype/splice/S15.4.4.12_A2.2_T5.js | 49 + .../Array/prototype/splice/S15.4.4.12_A2_T1.js | 65 + .../Array/prototype/splice/S15.4.4.12_A2_T2.js | 55 + .../Array/prototype/splice/S15.4.4.12_A2_T3.js | 55 + .../Array/prototype/splice/S15.4.4.12_A2_T4.js | 65 + .../Array/prototype/splice/S15.4.4.12_A3_T1.js | 37 + .../Array/prototype/splice/S15.4.4.12_A3_T3.js | 32 + .../Array/prototype/splice/S15.4.4.12_A4_T1.js | 74 + .../Array/prototype/splice/S15.4.4.12_A4_T2.js | 74 + .../Array/prototype/splice/S15.4.4.12_A4_T3.js | 67 + .../Array/prototype/splice/S15.4.4.12_A6.1_T1.js | 26 + .../Array/prototype/splice/S15.4.4.12_A6.1_T2.js | 20 + .../Array/prototype/splice/S15.4.4.12_A6.1_T3.js | 26 + .../built-ins/Array/prototype/splice/browser.js | 0 .../Array/prototype/splice/call-with-boolean.js | 13 + .../prototype/splice/called_with_one_argument.js | 27 + .../splice/clamps-length-to-integer-limit.js | 39 + .../prototype/splice/create-ctor-non-object.js | 45 + .../Array/prototype/splice/create-ctor-poisoned.js | 29 + .../splice/create-non-array-invalid-len.js | 44 + .../Array/prototype/splice/create-non-array.js | 36 + .../splice/create-proto-from-ctor-realm-array.js | 45 + .../create-proto-from-ctor-realm-non-array.js | 46 + .../Array/prototype/splice/create-proxy.js | 41 + .../Array/prototype/splice/create-revoked-proxy.js | 41 + .../prototype/splice/create-species-abrupt.js | 35 + ...reate-species-length-exceeding-integer-limit.js | 91 + .../prototype/splice/create-species-neg-zero.js | 51 + .../prototype/splice/create-species-non-ctor.js | 41 + .../Array/prototype/splice/create-species-null.js | 35 + .../prototype/splice/create-species-poisoned.js | 34 + .../splice/create-species-undef-invalid-len.js | 56 + .../Array/prototype/splice/create-species-undef.js | 36 + .../Array/prototype/splice/create-species.js | 45 + ...ngth-and-deleteCount-exceeding-integer-limit.js | 57 + .../length-exceeding-integer-limit-shrink-array.js | 67 + .../splice/length-near-integer-limit-grow-array.js | 65 + .../built-ins/Array/prototype/splice/length.js | 30 + .../built-ins/Array/prototype/splice/name.js | 28 + .../Array/prototype/splice/not-a-constructor.js | 35 + .../built-ins/Array/prototype/splice/prop-desc.js | 23 + .../splice/property-traps-order-with-species.js | 40 + .../Array/prototype/splice/set_length_no_args.js | 36 + .../built-ins/Array/prototype/splice/shell.js | 33 + .../splice/target-array-non-extensible.js | 41 + .../target-array-with-non-configurable-property.js | 43 + .../target-array-with-non-writable-property.js | 38 + .../splice/throws-if-integer-limit-exceeded.js | 43 + .../prototype/toLocaleString/S15.4.4.3_A1_T1.js | 28 + .../prototype/toLocaleString/S15.4.4.3_A3_T1.js | 25 + .../Array/prototype/toLocaleString/browser.js | 0 .../invoke-element-tolocalestring.js | 65 + .../Array/prototype/toLocaleString/length.js | 30 + .../Array/prototype/toLocaleString/name.js | 28 + .../prototype/toLocaleString/not-a-constructor.js | 35 + .../toLocaleString/primitive_this_value-strict.js | 33 + .../primitive_this_value_getter-strict.js | 38 + .../Array/prototype/toLocaleString/prop-desc.js | 23 + .../Array/prototype/toLocaleString/shell.js | 0 .../Array/prototype/toReversed/browser.js | 0 .../prototype/toReversed/frozen-this-value.js | 20 + .../prototype/toReversed/get-descending-order.js | 51 + .../prototype/toReversed/holes-not-preserved.js | 31 + .../Array/prototype/toReversed/ignores-species.js | 33 + .../Array/prototype/toReversed/immutable.js | 18 + .../prototype/toReversed/length-casted-to-zero.js | 22 + .../toReversed/length-decreased-while-iterating.js | 34 + .../length-exceeding-array-length-limit.js | 40 + .../toReversed/length-increased-while-iterating.js | 32 + .../Array/prototype/toReversed/length-tolength.js | 31 + .../Array/prototype/toReversed/metadata/browser.js | 0 .../Array/prototype/toReversed/metadata/length.js | 32 + .../Array/prototype/toReversed/metadata/name.js | 30 + .../toReversed/metadata/property-descriptor.js | 27 + .../Array/prototype/toReversed/metadata/shell.js | 0 .../prototype/toReversed/not-a-constructor.js | 35 + .../built-ins/Array/prototype/toReversed/shell.js | 0 .../prototype/toReversed/this-value-boolean.js | 31 + .../prototype/toReversed/this-value-nullish.js | 24 + .../prototype/toReversed/zero-or-one-element.js | 22 + .../built-ins/Array/prototype/toSorted/browser.js | 0 .../comparefn-called-after-get-elements.js | 45 + .../prototype/toSorted/comparefn-not-a-function.js | 35 + .../toSorted/comparefn-stop-after-error.js | 44 + .../Array/prototype/toSorted/frozen-this-value.js | 20 + .../prototype/toSorted/holes-not-preserved.js | 27 + .../Array/prototype/toSorted/ignores-species.js | 32 + .../Array/prototype/toSorted/immutable.js | 18 + .../prototype/toSorted/length-casted-to-zero.js | 22 + .../toSorted/length-decreased-while-iterating.js | 33 + .../length-exceeding-array-length-limit.js | 41 + .../toSorted/length-increased-while-iterating.js | 31 + .../Array/prototype/toSorted/length-tolength.js | 31 + .../Array/prototype/toSorted/metadata/browser.js | 0 .../Array/prototype/toSorted/metadata/length.js | 32 + .../Array/prototype/toSorted/metadata/name.js | 30 + .../toSorted/metadata/property-descriptor.js | 27 + .../Array/prototype/toSorted/metadata/shell.js | 0 .../Array/prototype/toSorted/not-a-constructor.js | 35 + .../built-ins/Array/prototype/toSorted/shell.js | 0 .../Array/prototype/toSorted/this-value-boolean.js | 32 + .../Array/prototype/toSorted/this-value-nullish.js | 24 + .../prototype/toSorted/zero-or-one-element.js | 22 + .../built-ins/Array/prototype/toSpliced/browser.js | 0 ...unt-clamped-between-zero-and-remaining-count.js | 39 + .../prototype/toSpliced/deleteCount-missing.js | 22 + .../prototype/toSpliced/deleteCount-undefined.js | 31 + .../toSpliced/discarded-element-not-read.js | 54 + .../prototype/toSpliced/elements-read-in-order.js | 61 + .../Array/prototype/toSpliced/frozen-this-value.js | 20 + .../prototype/toSpliced/holes-not-preserved.js | 43 + .../Array/prototype/toSpliced/ignores-species.js | 32 + .../Array/prototype/toSpliced/immutable.js | 19 + .../prototype/toSpliced/length-casted-to-zero.js | 23 + .../toSpliced/length-clamped-to-2pow53minus1.js | 36 + .../toSpliced/length-decreased-while-iterating.js | 46 + .../length-exceeding-array-length-limit.js | 78 + .../toSpliced/length-increased-while-iterating.js | 39 + .../Array/prototype/toSpliced/length-tolength.js | 31 + .../Array/prototype/toSpliced/metadata/browser.js | 0 .../Array/prototype/toSpliced/metadata/length.js | 32 + .../Array/prototype/toSpliced/metadata/name.js | 30 + .../toSpliced/metadata/property-descriptor.js | 27 + .../Array/prototype/toSpliced/metadata/shell.js | 0 .../prototype/toSpliced/mutate-while-iterating.js | 52 + .../Array/prototype/toSpliced/not-a-constructor.js | 34 + .../built-ins/Array/prototype/toSpliced/shell.js | 0 .../toSpliced/start-and-deleteCount-missing.js | 29 + .../toSpliced/start-and-deleteCount-undefineds.js | 31 + .../toSpliced/start-bigger-than-length.js | 25 + .../toSpliced/start-neg-infinity-is-zero.js | 24 + .../start-neg-less-than-minus-length-is-zero.js | 24 + .../toSpliced/start-neg-subtracted-from-length.js | 24 + .../start-undefined-and-deleteCount-missing.js | 28 + .../prototype/toSpliced/this-value-boolean.js | 31 + .../prototype/toSpliced/this-value-nullish.js | 24 + .../Array/prototype/toSpliced/unmodified.js | 17 + .../Array/prototype/toString/S15.4.4.2_A1_T1.js | 33 + .../Array/prototype/toString/S15.4.4.2_A1_T2.js | 56 + .../Array/prototype/toString/S15.4.4.2_A1_T3.js | 85 + .../Array/prototype/toString/S15.4.4.2_A1_T4.js | 100 + .../Array/prototype/toString/S15.4.4.2_A3_T1.js | 18 + .../built-ins/Array/prototype/toString/browser.js | 0 .../Array/prototype/toString/call-with-boolean.js | 20 + .../built-ins/Array/prototype/toString/length.js | 31 + .../built-ins/Array/prototype/toString/name.js | 28 + .../toString/non-callable-join-string-tag.js | 69 + .../Array/prototype/toString/not-a-constructor.js | 35 + .../Array/prototype/toString/prop-desc.js | 23 + .../built-ins/Array/prototype/toString/shell.js | 0 .../Array/prototype/unshift/S15.4.4.13_A1_T1.js | 49 + .../Array/prototype/unshift/S15.4.4.13_A1_T2.js | 52 + .../Array/prototype/unshift/S15.4.4.13_A2_T1.js | 61 + .../Array/prototype/unshift/S15.4.4.13_A2_T2.js | 88 + .../Array/prototype/unshift/S15.4.4.13_A2_T3.js | 120 ++ .../Array/prototype/unshift/S15.4.4.13_A3_T2.js | 40 + .../Array/prototype/unshift/S15.4.4.13_A4_T1.js | 70 + .../Array/prototype/unshift/S15.4.4.13_A4_T2.js | 68 + .../built-ins/Array/prototype/unshift/browser.js | 0 .../Array/prototype/unshift/call-with-boolean.js | 12 + .../prototype/unshift/clamps-to-integer-limit.js | 35 + .../prototype/unshift/length-near-integer-limit.js | 63 + .../built-ins/Array/prototype/unshift/length.js | 34 + .../built-ins/Array/prototype/unshift/name.js | 28 + .../Array/prototype/unshift/not-a-constructor.js | 35 + .../built-ins/Array/prototype/unshift/prop-desc.js | 23 + .../unshift/set-length-array-is-frozen.js | 50 + .../set-length-array-length-is-non-writable.js | 50 + .../unshift/set-length-zero-array-is-frozen.js | 38 + ...set-length-zero-array-length-is-non-writable.js | 38 + .../built-ins/Array/prototype/unshift/shell.js | 0 .../unshift/throws-if-integer-limit-exceeded.js | 40 + .../unshift/throws-with-string-receiver.js | 47 + .../built-ins/Array/prototype/values/browser.js | 0 .../Array/prototype/values/iteration-mutable.js | 41 + .../built-ins/Array/prototype/values/iteration.js | 35 + .../built-ins/Array/prototype/values/length.js | 27 + .../built-ins/Array/prototype/values/name.js | 28 + .../Array/prototype/values/not-a-constructor.js | 35 + .../built-ins/Array/prototype/values/prop-desc.js | 19 + .../values/returns-iterator-from-object.js | 27 + .../Array/prototype/values/returns-iterator.js | 32 + .../built-ins/Array/prototype/values/shell.js | 0 .../prototype/values/this-val-non-obj-coercible.js | 20 + .../built-ins/Array/prototype/with/browser.js | 0 .../Array/prototype/with/frozen-this-value.js | 20 + .../Array/prototype/with/holes-not-preserved.js | 32 + .../Array/prototype/with/ignores-species.js | 32 + .../built-ins/Array/prototype/with/immutable.js | 19 + .../with/index-bigger-or-eq-than-length.js | 37 + .../Array/prototype/with/index-casted-to-number.js | 29 + .../Array/prototype/with/index-negative.js | 29 + .../with/index-smaller-than-minus-length.js | 39 + .../with/length-decreased-while-iterating.js | 42 + .../with/length-exceeding-array-length-limit.js | 41 + .../with/length-increased-while-iterating.js | 34 + .../Array/prototype/with/length-tolength.js | 32 + .../Array/prototype/with/metadata/browser.js | 0 .../Array/prototype/with/metadata/length.js | 32 + .../Array/prototype/with/metadata/name.js | 30 + .../prototype/with/metadata/property-descriptor.js | 27 + .../Array/prototype/with/metadata/shell.js | 0 .../Array/prototype/with/no-get-replaced-index.js | 32 + .../Array/prototype/with/not-a-constructor.js | 35 + .../built-ins/Array/prototype/with/shell.js | 0 .../Array/prototype/with/this-value-boolean.js | 41 + .../Array/prototype/with/this-value-nullish.js | 24 + js/src/tests/test262/built-ins/Array/shell.js | 24 + 3107 files changed, 98266 insertions(+) create mode 100644 js/src/tests/test262/built-ins/Array/15.4.5-1.js create mode 100644 js/src/tests/test262/built-ins/Array/15.4.5.1-5-1.js create mode 100644 js/src/tests/test262/built-ins/Array/15.4.5.1-5-2.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.1_A1.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.1_A1.1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.1_A1.1_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.1_A1.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.1_A1.3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.1_A2.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.1_A2.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.1_A3.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.1_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.2.1_A2.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.2.1_A2.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.3_A1.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.3_A1.1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.3_A1.1_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.5.1_A1.2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.5.1_A2.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.5.1_A2.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.5.1_A2.3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.5.2_A1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.5.2_A1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.5.2_A2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.5.2_A3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.5.2_A3_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4.5.2_A3_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4_A1.1_T10.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4_A1.1_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4_A1.1_T5.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4_A1.1_T6.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4_A1.1_T7.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4_A1.1_T8.js create mode 100644 js/src/tests/test262/built-ins/Array/S15.4_A1.1_T9.js create mode 100644 js/src/tests/test262/built-ins/Array/Symbol.species/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/Symbol.species/length.js create mode 100644 js/src/tests/test262/built-ins/Array/Symbol.species/return-value.js create mode 100644 js/src/tests/test262/built-ins/Array/Symbol.species/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/Symbol.species/symbol-species-name.js create mode 100644 js/src/tests/test262/built-ins/Array/Symbol.species/symbol-species.js create mode 100644 js/src/tests/test262/built-ins/Array/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/from/Array.from-descriptor.js create mode 100644 js/src/tests/test262/built-ins/Array/from/Array.from-name.js create mode 100644 js/src/tests/test262/built-ins/Array/from/Array.from_arity.js create mode 100644 js/src/tests/test262/built-ins/Array/from/Array.from_forwards-length-for-array-likes.js create mode 100644 js/src/tests/test262/built-ins/Array/from/array-like-has-length-but-no-indexes-with-values.js create mode 100644 js/src/tests/test262/built-ins/Array/from/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/from/calling-from-valid-1-noStrict.js create mode 100644 js/src/tests/test262/built-ins/Array/from/calling-from-valid-1-onlyStrict-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/from/calling-from-valid-2.js create mode 100644 js/src/tests/test262/built-ins/Array/from/elements-added-after.js create mode 100644 js/src/tests/test262/built-ins/Array/from/elements-deleted-after.js create mode 100644 js/src/tests/test262/built-ins/Array/from/elements-updated-after.js create mode 100644 js/src/tests/test262/built-ins/Array/from/from-array.js create mode 100644 js/src/tests/test262/built-ins/Array/from/from-string.js create mode 100644 js/src/tests/test262/built-ins/Array/from/get-iter-method-err.js create mode 100644 js/src/tests/test262/built-ins/Array/from/items-is-arraybuffer.js create mode 100644 js/src/tests/test262/built-ins/Array/from/items-is-null-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-adv-err.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-cstm-ctor-err.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-cstm-ctor.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-get-iter-err.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-get-iter-val-err.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-map-fn-args.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-map-fn-err.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-map-fn-return.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-map-fn-this-arg.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-map-fn-this-non-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-map-fn-this-strict-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-set-elem-prop-err.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-set-elem-prop-non-writable.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-set-elem-prop.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-set-length-err.js create mode 100644 js/src/tests/test262/built-ins/Array/from/iter-set-length.js create mode 100644 js/src/tests/test262/built-ins/Array/from/mapfn-is-not-callable-typeerror.js create mode 100644 js/src/tests/test262/built-ins/Array/from/mapfn-is-symbol-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/from/mapfn-throws-exception.js create mode 100644 js/src/tests/test262/built-ins/Array/from/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/from/proto-from-ctor-realm.js create mode 100644 js/src/tests/test262/built-ins/Array/from/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/from/source-array-boundary.js create mode 100644 js/src/tests/test262/built-ins/Array/from/source-object-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/from/source-object-iterator-1.js create mode 100644 js/src/tests/test262/built-ins/Array/from/source-object-iterator-2.js create mode 100644 js/src/tests/test262/built-ins/Array/from/source-object-length-set-elem-prop-err.js create mode 100644 js/src/tests/test262/built-ins/Array/from/source-object-length-set-elem-prop-non-writable.js create mode 100644 js/src/tests/test262/built-ins/Array/from/source-object-length.js create mode 100644 js/src/tests/test262/built-ins/Array/from/source-object-missing.js create mode 100644 js/src/tests/test262/built-ins/Array/from/source-object-without.js create mode 100644 js/src/tests/test262/built-ins/Array/from/this-null.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-async-mapped-awaits-once.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-input-does-not-await-input.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-input-iteration-err.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-input.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-add-to-empty.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-add-to-singleton.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-add.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-mutate.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-remove.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraybuffer.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-holes.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-length-accessor-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-promise.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-too-long.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-exists.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-not-callable.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-null.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-sync.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-bigint.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-function.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-exists.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-not-callable.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-null.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-promise.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-null-undefined.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-number.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-object-not-arraylike.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-operations.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-string.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-symbol.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-uses-intrinsic-iterator-symbols.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/builtin.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/length.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-arraylike.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-iterable-async.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-iterable-sync.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-throws-close-async-iterator.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-throws-close-sync-iterator.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/mapfn-not-callable.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/mapfn-result-awaited-once-per-iteration.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-arraylike.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-iterable-async.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-iterable-sync.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-throws-close-async-iterator.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-throws-close-sync-iterator.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/name.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-does-not-use-array-prototype.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-element-access-err.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-awaits-callback-result-once.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-callback-err.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-element-rejects.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-sync-mapped-callback-err.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-sync-mapped-callback-err.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-non-promise-thenable.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-async-mapped-awaits-once.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-awaits-once.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-sync-mapped-awaits-once.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-then-method-err.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/returned-promise-resolves-to-array.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/returns-promise.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-input-with-non-promise-thenable.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-input-with-thenable.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-input.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-iteration-err.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-awaits-once.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-callback-err.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-awaits-once.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-element-rejects.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-awaits-once.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-callback-err.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-then-method-err.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-operations.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-bad-length-setter.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-readonly-elements.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-readonly-length.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-unsettable-element-closes-async-iterator.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-unsettable-element-closes-sync-iterator.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-unsettable-element.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/this-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/this-non-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/thisarg-object.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/thisarg-omitted-sloppy.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/thisarg-omitted-strict-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/thisarg-primitive-sloppy.js create mode 100644 js/src/tests/test262/built-ins/Array/fromAsync/thisarg-primitive-strict-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/is-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-1.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-2.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-3.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-4.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-5.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-6.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-7.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-1.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-10.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-11.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-12.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-13.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-15.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-2.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-3.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-4.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-5.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-6.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-7.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-8.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-9.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-2-1.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-2-2.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-2-3.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/descriptor.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/name.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/proxy-revoked.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/proxy.js create mode 100644 js/src/tests/test262/built-ins/Array/isArray/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/length.js create mode 100644 js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-1.js create mode 100644 js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-2.js create mode 100644 js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-3.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T5.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.4_A1.3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/length/S15.4.5.2_A3_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/length/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order-set.js create mode 100644 js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order.js create mode 100644 js/src/tests/test262/built-ins/Array/length/define-own-prop-length-error.js create mode 100644 js/src/tests/test262/built-ins/Array/length/define-own-prop-length-no-value-order.js create mode 100644 js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-order.js create mode 100644 js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-realm.js create mode 100644 js/src/tests/test262/built-ins/Array/length/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/name.js create mode 100644 js/src/tests/test262/built-ins/Array/of/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/of/construct-this-with-the-number-of-arguments.js create mode 100644 js/src/tests/test262/built-ins/Array/of/creates-a-new-array-from-arguments.js create mode 100644 js/src/tests/test262/built-ins/Array/of/does-not-use-prototype-properties.js create mode 100644 js/src/tests/test262/built-ins/Array/of/does-not-use-set-for-indices.js create mode 100644 js/src/tests/test262/built-ins/Array/of/length.js create mode 100644 js/src/tests/test262/built-ins/Array/of/name.js create mode 100644 js/src/tests/test262/built-ins/Array/of/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/of/of.js create mode 100644 js/src/tests/test262/built-ins/Array/of/proto-from-ctor-realm.js create mode 100644 js/src/tests/test262/built-ins/Array/of/return-a-custom-instance.js create mode 100644 js/src/tests/test262/built-ins/Array/of/return-a-new-array-object.js create mode 100644 js/src/tests/test262/built-ins/Array/of/return-abrupt-from-contructor.js create mode 100644 js/src/tests/test262/built-ins/Array/of/return-abrupt-from-data-property-using-proxy.js create mode 100644 js/src/tests/test262/built-ins/Array/of/return-abrupt-from-data-property.js create mode 100644 js/src/tests/test262/built-ins/Array/of/return-abrupt-from-setting-length.js create mode 100644 js/src/tests/test262/built-ins/Array/of/sets-length.js create mode 100644 js/src/tests/test262/built-ins/Array/of/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/property-cast-boolean-primitive.js create mode 100644 js/src/tests/test262/built-ins/Array/property-cast-nan-infinity.js create mode 100644 js/src/tests/test262/built-ins/Array/property-cast-number.js create mode 100644 js/src/tests/test262/built-ins/Array/proto-from-ctor-realm-one.js create mode 100644 js/src/tests/test262/built-ins/Array/proto-from-ctor-realm-two.js create mode 100644 js/src/tests/test262/built-ins/Array/proto-from-ctor-realm-zero.js create mode 100644 js/src/tests/test262/built-ins/Array/proto.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/array-find-from-last.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/value.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/at/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/at/index-argument-tointeger.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/at/index-non-numeric-argument-tointeger.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/at/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/at/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/at/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/at/return-abrupt-from-this.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/at/returns-item-relative-index.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/at/returns-item.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/at/returns-undefined-for-out-of-range-index.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/at/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/15.4.4.4-5-b-iii-3-b-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/15.4.4.4-5-c-i-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-length-to-string-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-length-value-of-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-negative-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-primitive-non-number-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-string-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-to-length-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_holey-sloppy-arguments.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_large-typed-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_length-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_no-prototype.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_non-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments-with-dupes.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_small-typed-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-boolean-wrapper.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-function.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-getter-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-number-wrapper.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-reg-exp.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-sparse-object.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-string-wrapper.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_strict-arguments.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/arg-length-exceeding-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/arg-length-near-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-ctor-non-object.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-ctor-poisoned.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-non-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-proto-from-ctor-realm-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-proxy.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-revoked-proxy.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-species-abrupt.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-species-non-ctor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-species-non-extensible-spreadable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-species-non-extensible.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-species-null.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-species-poisoned.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-species-undef.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-configurable-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-writable-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/create-species.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-get-err.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-get-order.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-proxy.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-val-falsey.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-val-truthy.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-val-undefined.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/concat/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-end.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start-change-start.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start-change-target.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-target.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/fill-holes.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/length-near-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-end.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-end.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-start.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-target.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-start.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-target.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-out-of-bounds-end.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-target-and-start.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-target-start-and-end.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-delete-proxy-target.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-delete-target.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-end-as-symbol.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-end.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-get-start-value.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-has-start.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-set-target-value.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-start-as-symbol.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-start.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-target-as-symbol.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-target.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-this-length-as-symbol.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-this-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-this.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-this.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/copyWithin/undefined-end.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/iteration-mutable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/iteration.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/return-abrupt-from-this.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator-from-object.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-0-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-1-s.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/callbackfn-resize-arraybuffer.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/every/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/exotic-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/coerced-indexes.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-custom-start-and-end.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-relative-end.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-relative-start.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/fill-values.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/length-near-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-end-as-symbol.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-end.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-setting-property-value.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-start-as-symbol.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-start.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-this-length-as-symbol.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-this-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-this.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/return-this.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/fill/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-1-s.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/callbackfn-resize-arraybuffer.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/create-ctor-non-object.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/create-ctor-poisoned.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/create-non-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/create-proto-from-ctor-realm-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/create-proto-from-ctor-realm-non-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/create-proxy.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/create-revoked-proxy.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/create-species-abrupt.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/create-species-non-ctor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/create-species-null.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/create-species-poisoned.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/create-species-undef.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/create-species.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/target-array-non-extensible.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/target-array-with-non-configurable-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/filter/target-array-with-non-writable-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/array-altered-during-loop.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/callbackfn-resize-arraybuffer.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/predicate-call-parameters.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/predicate-call-this-non-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/predicate-call-this-strict-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/predicate-called-for-each-array-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/predicate-is-not-callable-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/predicate-not-called-on-empty-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-predicate-call.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-this-length-as-symbol.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-this-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-this.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/return-found-value-predicate-result-is-true.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/return-undefined-if-predicate-returns-false-value.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/find/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/array-altered-during-loop.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/callbackfn-resize-arraybuffer.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-call-parameters.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-call-this-non-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-call-this-strict-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-called-for-each-array-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-is-not-callable-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-not-called-on-empty-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-predicate-call.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-this-length-as-symbol.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-this-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-this.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/return-index-predicate-result-is-true.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findIndex/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/array-altered-during-loop.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/callbackfn-resize-arraybuffer.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/maximum-index.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-call-parameters.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-call-this-non-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-call-this-strict-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-called-for-each-array-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-is-not-callable-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-not-called-on-empty-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-predicate-call.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-this-length-as-symbol.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-this-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-this.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/return-found-value-predicate-result-is-true.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/return-undefined-if-predicate-returns-false-value.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLast/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/array-altered-during-loop.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/callbackfn-resize-arraybuffer.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/maximum-index.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-call-parameters.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-call-this-non-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-call-this-strict-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-called-for-each-array-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-is-not-callable-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-not-called-on-empty-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-predicate-call.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-this-length-as-symbol.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-this-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-this.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-index-predicate-result-is-true.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/findLastIndex/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/array-like-objects.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/bound-function-call.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/empty-array-elements.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/empty-object-elements.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/non-numeric-depth-should-not-throw.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/non-object-ctor-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/null-undefined-elements.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/null-undefined-input-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/positive-infinity.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/proxy-access-count.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/symbol-object-create-null-depth-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/target-array-non-extensible.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/target-array-with-non-configurable-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flat/target-array-with-non-writable-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects-nested.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects-poisoned-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects-typedarrays.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/bound-function-argument.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/depth-always-one.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/non-callable-argument-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/proxy-access-count.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/target-array-non-extensible.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/target-array-with-non-configurable-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/target-array-with-non-writable-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-non-object.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor-poisoned-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-null-undefined-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/flatMap/thisArg-argument-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1-s.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/forEach/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-infinity.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-minus-zero.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/get-prop.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/length-boundaries.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/length-zero-returns-false.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/no-arg.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-get-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-get-prop.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tointeger-fromindex.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tonumber-length-symbol.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tonumber-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/samevaluezero.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/search-found-returns-true.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/search-not-found-returns-false.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/sparse.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/this-is-not-object.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/tointeger-fromindex.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/tolength-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/using-fromindex.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/includes/values-are-not-cached.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-10-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-10-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-32.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-33.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-6-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-iii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-iii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/fromindex-zero-conversion.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/length-near-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/length-zero-returns-minus-one.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/indexOf/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A4_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A5_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A6.6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/join/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/keys/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/keys/iteration-mutable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/keys/iteration.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/keys/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/keys/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/keys/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/keys/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/keys/return-abrupt-from-this.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/keys/returns-iterator-from-object.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/keys/returns-iterator.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/keys/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-32.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-33.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/fromindex-zero-conversion.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-near-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-zero-returns-minus-one.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-1-s.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-6-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-6-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/callbackfn-resize-arraybuffer.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-ctor-non-object.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-ctor-poisoned.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-non-array-invalid-len.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-non-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-proto-from-ctor-realm-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-proto-from-ctor-realm-non-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-proxy.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-revoked-proxy.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-species-abrupt.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-species-non-ctor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-species-null.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-species-poisoned.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-species-undef-invalid-len.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-species-undef.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/create-species.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/target-array-non-extensible.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/target-array-with-non-configurable-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/map/target-array-with-non-writable-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/methods-called-as-functions.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A1.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A1.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A3_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A3_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A4_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A4_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/clamps-to-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/length-near-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/set-length-array-is-frozen.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/set-length-array-length-is-non-writable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/set-length-zero-array-is-frozen.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/set-length-zero-array-length-is-non-writable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/pop/throws-with-string-receiver.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/proto.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A4_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A4_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A4_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A5_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/clamps-to-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/length-near-integer-limit-set-failure.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/length-near-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/set-length-array-is-frozen.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/set-length-array-length-is-non-writable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/set-length-zero-array-is-frozen.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/set-length-zero-array-length-is-non-writable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/throws-if-integer-limit-exceeded.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/push/throws-with-string-receiver.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-32.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-33.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-32.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-33.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-32.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-33.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-34.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-35.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-37.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4-s.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduce/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-32.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-33.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-32.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-33.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-32.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-33.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-34.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-35.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-37.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-4-s.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/callbackfn-resize-arraybuffer.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/length-near-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reduceRight/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A3_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A4_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A4_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/array-has-one-entry.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/get_if_present_with_delete.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-object.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-proxy.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/reverse/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A1.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A1.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A3_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A4_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A4_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/set-length-array-is-frozen.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/set-length-array-length-is-non-writable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/set-length-zero-array-is-frozen.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/set-length-zero-array-length-is-non-writable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/shift/throws-when-this-value-length-is-writable-false.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/15.4.4.10-10-c-ii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.5_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.5_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A3_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A3_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A4_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-ctor-non-object.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-ctor-poisoned.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-non-array-invalid-len.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-non-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-proto-from-ctor-realm-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-proto-from-ctor-realm-non-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-proxied-array-invalid-len.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-proxy.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-revoked-proxy.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-species-abrupt.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-species-neg-zero.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-species-non-ctor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-species-null.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-species-poisoned.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-species-undef.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/create-species.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/length-exceeding-integer-limit-proxied-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/length-exceeding-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/target-array-non-extensible.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/target-array-with-non-configurable-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/slice/target-array-with-non-writable-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-1-s.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-27.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-30.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-31.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-14.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-15.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-16.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-17.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-18.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-19.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-20.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-21.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-22.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-23.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-24.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-25.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-26.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-28.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-29.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-9.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-10.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-11.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-12.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-13.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-7.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/callbackfn-resize-arraybuffer.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/some/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.4_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.4_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.5_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A3_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A4_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A5_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A6_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A8.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/bug_596_1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/bug_596_2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/call-with-primitive.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/comparefn-nonfunction-call-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-comparefn-throws.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-appends-elements.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-decreases-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-deletes-predecessor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-deletes-successor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-increases-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-pops-elements.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-sets-predecessor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-sets-successor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-prototype-accessors.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-prototype-element.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-appends-elements.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-decreases-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-deletes-predecessor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-deletes-successor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-increases-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-pops-elements.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-sets-predecessor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-sets-successor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/stability-11-elements.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/stability-2048-elements.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/stability-5-elements.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/sort/stability-513-elements.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/15.4.4.12-9-a-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/15.4.4.12-9-c-ii-1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T6.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.5_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.5_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T5.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A3_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/called_with_one_argument.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/clamps-length-to-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-ctor-non-object.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-ctor-poisoned.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-non-array-invalid-len.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-non-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-proto-from-ctor-realm-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-proto-from-ctor-realm-non-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-proxy.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-revoked-proxy.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-species-abrupt.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-species-length-exceeding-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-species-neg-zero.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-species-non-ctor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-species-null.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-species-poisoned.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-species-undef-invalid-len.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-species-undef.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/create-species.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/length-and-deleteCount-exceeding-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/length-exceeding-integer-limit-shrink-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/length-near-integer-limit-grow-array.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/property-traps-order-with-species.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/set_length_no_args.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/target-array-non-extensible.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/target-array-with-non-configurable-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/target-array-with-non-writable-property.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/splice/throws-if-integer-limit-exceeded.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toLocaleString/S15.4.4.3_A1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toLocaleString/S15.4.4.3_A3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toLocaleString/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toLocaleString/invoke-element-tolocalestring.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toLocaleString/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toLocaleString/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toLocaleString/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toLocaleString/primitive_this_value-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toLocaleString/primitive_this_value_getter-strict.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toLocaleString/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toLocaleString/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/frozen-this-value.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/get-descending-order.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/holes-not-preserved.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/ignores-species.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/immutable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/length-casted-to-zero.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/length-tolength.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/property-descriptor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/this-value-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/this-value-nullish.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toReversed/zero-or-one-element.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/frozen-this-value.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/holes-not-preserved.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/ignores-species.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/immutable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/length-casted-to-zero.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/length-tolength.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/property-descriptor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-nullish.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSorted/zero-or-one-element.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/deleteCount-missing.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/elements-read-in-order.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/frozen-this-value.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/holes-not-preserved.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/ignores-species.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/immutable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-tolength.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/property-descriptor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/mutate-while-iterating.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/this-value-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/this-value-nullish.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/unmodified.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T4.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A3_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toString/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toString/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toString/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toString/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toString/non-callable-join-string-tag.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toString/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toString/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toString/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A1_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A1_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_T3.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A3_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A4_T1.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A4_T2.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/call-with-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/clamps-to-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/length-near-integer-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-array-is-frozen.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-array-length-is-non-writable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-zero-array-is-frozen.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-zero-array-length-is-non-writable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/throws-if-integer-limit-exceeded.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/unshift/throws-with-string-receiver.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/values/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/values/iteration-mutable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/values/iteration.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/values/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/values/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/values/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/values/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/values/returns-iterator-from-object.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/values/returns-iterator.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/values/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/values/this-val-non-obj-coercible.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/frozen-this-value.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/holes-not-preserved.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/ignores-species.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/immutable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/index-casted-to-number.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/index-negative.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/index-smaller-than-minus-length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/length-decreased-while-iterating.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/length-increased-while-iterating.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/length-tolength.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/metadata/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/metadata/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/metadata/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/metadata/property-descriptor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/metadata/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/no-get-replaced-index.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/shell.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/this-value-boolean.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/with/this-value-nullish.js create mode 100644 js/src/tests/test262/built-ins/Array/shell.js (limited to 'js/src/tests/test262/built-ins/Array') diff --git a/js/src/tests/test262/built-ins/Array/15.4.5-1.js b/js/src/tests/test262/built-ins/Array/15.4.5-1.js new file mode 100644 index 0000000000..5cefc5f280 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/15.4.5-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.4.5-1 +description: Array instances have [[Class]] set to 'Array' +---*/ + +var a = []; +var s = Object.prototype.toString.call(a); + +assert.sameValue(s, '[object Array]', 'The value of s is expected to be "[object Array]"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/15.4.5.1-5-1.js b/js/src/tests/test262/built-ins/Array/15.4.5.1-5-1.js new file mode 100644 index 0000000000..ca5c6f88e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/15.4.5.1-5-1.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.4.5.1-5-1 +description: > + Defining a property named 4294967295 (2**32-1)(not an array + element) +---*/ + +var a = []; +a[4294967295] = "not an array element"; + +assert.sameValue(a[4294967295], "not an array element", 'The value of a[4294967295] is expected to be "not an array element"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/15.4.5.1-5-2.js b/js/src/tests/test262/built-ins/Array/15.4.5.1-5-2.js new file mode 100644 index 0000000000..c0157dd77f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/15.4.5.1-5-2.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.4.5.1-5-2 +description: > + Defining a property named 4294967295 (2**32-1) doesn't change + length of the array +---*/ + +var a = [0, 1, 2]; +a[4294967295] = "not an array element"; + +assert.sameValue(a.length, 3, 'The value of a.length is expected to be 3'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.1_A1.1_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.1_A1.1_T1.js new file mode 100644 index 0000000000..94bd07777f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.1_A1.1_T1.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.1_A1.1_T1 +description: > + Create new property of Array.prototype. When new Array object has + this property +---*/ + +Array.prototype.myproperty = 42; +var x = Array(); +assert.sameValue(x.myproperty, 42, 'The value of x.myproperty is expected to be 42'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(x, 'myproperty'), + false, + 'Object.prototype.hasOwnProperty.call(Array(), "myproperty") must return false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.1_A1.1_T2.js b/js/src/tests/test262/built-ins/Array/S15.4.1_A1.1_T2.js new file mode 100644 index 0000000000..864c449d4b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.1_A1.1_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.1_A1.1_T2 +description: Array.prototype.toString = Object.prototype.toString +---*/ + +Array.prototype.toString = Object.prototype.toString; +var x = Array(); +assert.sameValue(x.toString(), "[object Array]", 'x.toString() must return "[object Array]"'); + +Array.prototype.toString = Object.prototype.toString; +var x = Array(0, 1, 2); +assert.sameValue(x.toString(), "[object Array]", 'x.toString() must return "[object Array]"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.1_A1.1_T3.js b/js/src/tests/test262/built-ins/Array/S15.4.1_A1.1_T3.js new file mode 100644 index 0000000000..81e7b2db31 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.1_A1.1_T3.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.1_A1.1_T3 +description: Checking use isPrototypeOf +---*/ + +assert.sameValue( + Array.prototype.isPrototypeOf(Array()), + true, + 'Array.prototype.isPrototypeOf(Array()) must return true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.1_A1.2_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.1_A1.2_T1.js new file mode 100644 index 0000000000..c398a6535c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.1_A1.2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The [[Class]] property of the newly constructed object is set to "Array" +es5id: 15.4.1_A1.2_T1 +description: Checking use Object.prototype.toString +---*/ + +var x = Array(); +x.getClass = Object.prototype.toString; +assert.sameValue(x.getClass(), "[object Array]", 'x.getClass() must return "[object Array]"'); + +var x = Array(0, 1, 2); +x.getClass = Object.prototype.toString; +assert.sameValue(x.getClass(), "[object Array]", 'x.getClass() must return "[object Array]"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.1_A1.3_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.1_A1.3_T1.js new file mode 100644 index 0000000000..cbb64bf166 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.1_A1.3_T1.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + This description of Array constructor applies if and only if + the Array constructor is given no arguments or at least two arguments +es5id: 15.4.1_A1.3_T1 +description: Checking case when Array constructor is given one argument +---*/ + +var x = Array(2); + +assert.notSameValue(x.length, 1, 'The value of x.length is not 1'); +assert.notSameValue(x[0], 2, 'The value of x[0] is not 2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.1_A2.1_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.1_A2.1_T1.js new file mode 100644 index 0000000000..335ea90b3c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.1_A2.1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The length property of the newly constructed object; + is set to the number of arguments +es5id: 15.4.1_A2.1_T1 +description: Array constructor is given no arguments or at least two arguments +---*/ +assert.sameValue(Array().length, 0, 'The value of Array().length is expected to be 0'); +assert.sameValue(Array(0, 1, 0, 1).length, 4, 'The value of Array(0, 1, 0, 1).length is expected to be 4'); + +assert.sameValue( + Array(undefined, undefined).length, + 2, + 'The value of Array(undefined, undefined).length is expected to be 2' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.1_A2.2_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.1_A2.2_T1.js new file mode 100644 index 0000000000..b2cbaa38fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.1_A2.2_T1.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The 0 property of the newly constructed object is set to item0 + (if supplied); the 1 property of the newly constructed object is set to item1 + (if supplied); and, in general, for as many arguments as there are, the k property + of the newly constructed object is set to argument k, where the first argument is + considered to be argument number 0 +es5id: 15.4.1_A2.2_T1 +description: Checking correct work this algorithm +---*/ + +var x = Array( + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 +); + +for (var i = 0; i < 100; i++) { + var result = true; + if (x[i] !== i) { + result = false; + } +} + +assert.sameValue(result, true, 'The value of result is expected to be true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.1_A3.1_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.1_A3.1_T1.js new file mode 100644 index 0000000000..1e762e4a9f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.1_A3.1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When Array is called as a function rather than as a constructor, + it creates and initialises a new Array object +es5id: 15.4.1_A3.1_T1 +description: Checking use typeof, instanceof +---*/ + +assert.sameValue(typeof Array(), "object", 'The value of `typeof Array()` is expected to be "object"'); + +assert.sameValue( + Array() instanceof Array, + true, + 'The result of evaluating (Array() instanceof Array) is expected to be true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.1_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.1_T1.js new file mode 100644 index 0000000000..e682359d1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.2.1_A1.1_T1 +description: > + Create new property of Array.prototype. When new Array object has + this property +---*/ + +Array.prototype.myproperty = 1; +var x = new Array(); +assert.sameValue(x.myproperty, 1, 'The value of x.myproperty is expected to be 1'); +assert.sameValue(x.hasOwnProperty('myproperty'), false, 'x.hasOwnProperty("myproperty") must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.1_T2.js b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.1_T2.js new file mode 100644 index 0000000000..17a7a33d2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.1_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.2.1_A1.1_T2 +description: Array.prototype.toString = Object.prototype.toString +---*/ + +Array.prototype.toString = Object.prototype.toString; +var x = new Array(); +assert.sameValue(x.toString(), "[object Array]", 'x.toString() must return "[object Array]"'); + +Array.prototype.toString = Object.prototype.toString; +var x = new Array(0, 1, 2); +assert.sameValue(x.toString(), "[object Array]", 'x.toString() must return "[object Array]"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.1_T3.js b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.1_T3.js new file mode 100644 index 0000000000..4bc7de6ea3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.1_T3.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.2.1_A1.1_T3 +description: Checking use isPrototypeOf +---*/ +assert.sameValue( + Array.prototype.isPrototypeOf(new Array()), + true, + 'Array.prototype.isPrototypeOf(new Array()) must return true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.2_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.2_T1.js new file mode 100644 index 0000000000..080ed96634 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The [[Class]] property of the newly constructed object is set to "Array" +es5id: 15.4.2.1_A1.2_T1 +description: Checking use Object.prototype.toString +---*/ + +var x = new Array(); +x.getClass = Object.prototype.toString; +assert.sameValue(x.getClass(), "[object Array]", 'x.getClass() must return "[object Array]"'); + +var x = new Array(0, 1, 2); +x.getClass = Object.prototype.toString; +assert.sameValue(x.getClass(), "[object Array]", 'x.getClass() must return "[object Array]"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.3_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.3_T1.js new file mode 100644 index 0000000000..15c5531212 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.3_T1.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + This description of Array constructor applies if and only if + the Array constructor is given no arguments or at least two arguments +es5id: 15.4.2.1_A1.3_T1 +description: Checking case when Array constructor is given one argument +---*/ + +var x = new Array(2); + +assert.notSameValue(x.length, 1, 'The value of x.length is not 1'); +assert.notSameValue(x[0], 2, 'The value of x[0] is not 2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.2.1_A2.1_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A2.1_T1.js new file mode 100644 index 0000000000..c2e82b8c81 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A2.1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The length property of the newly constructed object; + is set to the number of arguments +es5id: 15.4.2.1_A2.1_T1 +description: Array constructor is given no arguments or at least two arguments +---*/ +assert.sameValue(new Array().length, 0, 'The value of new Array().length is expected to be 0'); +assert.sameValue(new Array(0, 1, 0, 1).length, 4, 'The value of new Array(0, 1, 0, 1).length is expected to be 4'); + +assert.sameValue( + new Array(undefined, undefined).length, + 2, + 'The value of new Array(undefined, undefined).length is expected to be 2' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.2.1_A2.2_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A2.2_T1.js new file mode 100644 index 0000000000..8b56efd0ac --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A2.2_T1.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The 0 property of the newly constructed object is set to item0 + (if supplied); the 1 property of the newly constructed object is set to item1 + (if supplied); and, in general, for as many arguments as there are, the k property + of the newly constructed object is set to argument k, where the first argument is + considered to be argument number 0 +es5id: 15.4.2.1_A2.2_T1 +description: Checking correct work this algorithm +---*/ + +var x = new Array( + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 +); + +for (var i = 0; i < 100; i++) { + var result = true; + if (x[i] !== i) { + result = false; + } +} + +assert.sameValue(result, true, 'The value of result is expected to be true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.3_A1.1_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.3_A1.1_T1.js new file mode 100644 index 0000000000..c6872c6a8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.3_A1.1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The value of the internal [[Prototype]] property of + the Array constructor is the Function prototype object +es5id: 15.4.3_A1.1_T1 +description: > + Create new property of Function.prototype. When Array constructor + has this property +---*/ + +Function.prototype.myproperty = 1; + +assert.sameValue(Array.myproperty, 1, 'The value of Array.myproperty is expected to be 1'); +assert.sameValue(Array.hasOwnProperty('myproperty'), false, 'Array.hasOwnProperty("myproperty") must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.3_A1.1_T2.js b/js/src/tests/test262/built-ins/Array/S15.4.3_A1.1_T2.js new file mode 100644 index 0000000000..53fbd5f169 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.3_A1.1_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The value of the internal [[Prototype]] property of + the Array constructor is the Function prototype object +es5id: 15.4.3_A1.1_T2 +description: Function.prototype.toString = Object.prototype.toString +---*/ + +Function.prototype.toString = Object.prototype.toString; + +assert.sameValue( + Array.toString(), + "[object Function]", + 'Array.toString() must return "[object Function]"' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.3_A1.1_T3.js b/js/src/tests/test262/built-ins/Array/S15.4.3_A1.1_T3.js new file mode 100644 index 0000000000..ac8d7021b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.3_A1.1_T3.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The value of the internal [[Prototype]] property of + the Array constructor is the Function prototype object +es5id: 15.4.3_A1.1_T3 +description: Checking use isPrototypeOf +---*/ +assert.sameValue( + Function.prototype.isPrototypeOf(Array), + true, + 'Function.prototype.isPrototypeOf(Array) must return true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.5.1_A1.2_T2.js b/js/src/tests/test262/built-ins/Array/S15.4.5.1_A1.2_T2.js new file mode 100644 index 0000000000..aa7add8256 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.1_A1.2_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + For every integer k that is less than the value of + the length property of A but not less than ToUint32(length), + if A itself has a property (not an inherited property) named ToString(k), + then delete that property +es5id: 15.4.5.1_A1.2_T2 +description: Checking an inherited property +---*/ + +Array.prototype[2] = -1; +var x = [0, 1, 2]; +assert.sameValue(x[2], 2, 'The value of x[2] is expected to be 2'); + +x.length = 2; +assert.sameValue(x[2], -1, 'The value of x[2] is expected to be -1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.5.1_A2.1_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.5.1_A2.1_T1.js new file mode 100644 index 0000000000..7edca01d0f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.1_A2.1_T1.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If P is not an array index, return + (Create a property with name P, set its value to V and give it empty attributes) +es5id: 15.4.5.1_A2.1_T1 +description: P in [4294967295, -1, true] +---*/ + +var x = []; +x[4294967295] = 1; +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); +assert.sameValue(x[4294967295], 1, 'The value of x[4294967295] is expected to be 1'); + +x = []; +x[-1] = 1; +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); +assert.sameValue(x[-1], 1, 'The value of x[-1] is expected to be 1'); + +x = []; +x[true] = 1; +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); +assert.sameValue(x[true], 1, 'The value of x[true] is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.5.1_A2.2_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.5.1_A2.2_T1.js new file mode 100644 index 0000000000..0cf2eab493 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.1_A2.2_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If ToUint32(P) is less than the value of + the length property of A, then return +es5id: 15.4.5.1_A2.2_T1 +description: length === 100, P in [0, 98, 99] +---*/ + +var x = Array(100); +x[0] = 1; +assert.sameValue(x.length, 100, 'The value of x.length is expected to be 100'); + +x[98] = 1; +assert.sameValue(x.length, 100, 'The value of x.length is expected to be 100'); + +x[99] = 1; +assert.sameValue(x.length, 100, 'The value of x.length is expected to be 100'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.5.1_A2.3_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.5.1_A2.3_T1.js new file mode 100644 index 0000000000..9a0a14eaba --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.1_A2.3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If ToUint32(P) is less than the value of + the length property of A, change (or set) length to ToUint32(P)+1 +es5id: 15.4.5.1_A2.3_T1 +description: length = 100, P in [100, 199] +---*/ + +var x = Array(100); +x[100] = 1; +assert.sameValue(x.length, 101, 'The value of x.length is expected to be 101'); + +x[199] = 1; +assert.sameValue(x.length, 200, 'The value of x.length is expected to be 200'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.5.2_A1_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A1_T1.js new file mode 100644 index 0000000000..6da4cde919 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A1_T1.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Every Array object has a length property whose value is + always a nonnegative integer less than 2^32. The value of the length property is + numerically greater than the name of every property whose name is an array index +es5id: 15.4.5.2_A1_T1 +description: Checking boundary points +---*/ + +var x = []; +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); + +x[0] = 1; +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); + +x[1] = 1; +assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); + +x[2147483648] = 1; +assert.sameValue(x.length, 2147483649, 'The value of x.length is expected to be 2147483649'); + +x[4294967294] = 1; +assert.sameValue(x.length, 4294967295, 'The value of x.length is expected to be 4294967295'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.5.2_A1_T2.js b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A1_T2.js new file mode 100644 index 0000000000..7cca401c04 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A1_T2.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Every Array object has a length property whose value is + always a nonnegative integer less than 2^32. The value of the length property is + numerically greater than the name of every property whose name is an array index +es5id: 15.4.5.2_A1_T2 +description: P = "2^32 - 1" is not index array +---*/ + +var x = []; +x[4294967295] = 1; +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); + +var y = []; +y[1] = 1; +y[4294967295] = 1; +assert.sameValue(y.length, 2, 'The value of y.length is expected to be 2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.5.2_A2_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A2_T1.js new file mode 100644 index 0000000000..f4f37defe3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A2_T1.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If a property is added whose name is an array index, + the length property is changed +es5id: 15.4.5.2_A2_T1 +description: Checking length property +---*/ + +var x = []; +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); + +x[0] = 1; +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); + +x[1] = 1; +assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); + +x[9] = 1; +assert.sameValue(x.length, 10, 'The value of x.length is expected to be 10'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.5.2_A3_T1.js b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A3_T1.js new file mode 100644 index 0000000000..bf423b476c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A3_T1.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If the length property is changed, every property whose name + is an array index whose value is not smaller than the new length is automatically deleted +es5id: 15.4.5.2_A3_T1 +description: > + If new length greater than the name of every property whose name + is an array index +---*/ + +var x = []; +x.length = 1; +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); + +x[5] = 1; +x.length = 10; +assert.sameValue(x.length, 10, 'The value of x.length is expected to be 10'); +assert.sameValue(x[5], 1, 'The value of x[5] is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.5.2_A3_T2.js b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A3_T2.js new file mode 100644 index 0000000000..1a7de49f02 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A3_T2.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If the length property is changed, every property whose name + is an array index whose value is not smaller than the new length is automatically deleted +es5id: 15.4.5.2_A3_T2 +description: > + If new length greater than the name of every property whose name + is an array index +---*/ + +var x = []; +x[1] = 1; +x[3] = 3; +x[5] = 5; +x.length = 4; +assert.sameValue(x.length, 4, 'The value of x.length is expected to be 4'); +assert.sameValue(x[5], undefined, 'The value of x[5] is expected to equal undefined'); +assert.sameValue(x[3], 3, 'The value of x[3] is expected to be 3'); + +x.length = new Number(6); +assert.sameValue(x[5], undefined, 'The value of x[5] is expected to equal undefined'); + +x.length = 0; +assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined'); + +x.length = 1; +assert.sameValue(x[1], undefined, 'The value of x[1] is expected to equal undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4.5.2_A3_T3.js b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A3_T3.js new file mode 100644 index 0000000000..63bee67493 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A3_T3.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If the length property is changed, every property whose name + is an array index whose value is not smaller than the new length is automatically deleted +es5id: 15.4.5.2_A3_T3 +description: "[[Put]] (length, 4294967296)" +---*/ + +var x = []; +x.length = 4294967295; +assert.sameValue(x.length, 4294967295, 'The value of x.length is expected to be 4294967295'); + +try { + x = []; + x.length = 4294967296; + throw new Test262Error('#2.1: x = []; x.length = 4294967296 throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T10.js b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T10.js new file mode 100644 index 0000000000..6ba208ed86 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T10.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T10 +description: Array index is power of two +---*/ + +var x = []; +var k = 1; +for (var i = 0; i < 32; i++) { + k = k * 2; + x[k - 2] = k; +} + +k = 1; +for (i = 0; i < 32; i++) { + k = k * 2; + assert.sameValue(x[k - 2], k, 'The value of x[k - 2] is expected to equal the value of k'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T4.js b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T4.js new file mode 100644 index 0000000000..8918ed2b08 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T4.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T4 +description: Checking for string primitive +---*/ + +var x = []; +x["0"] = 0; +assert.sameValue(x[0], 0, 'The value of x[0] is expected to be 0'); + +var y = []; +y["1"] = 1; +assert.sameValue(y[1], 1, 'The value of y[1] is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T5.js b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T5.js new file mode 100644 index 0000000000..eced3ea7c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T5.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T5 +description: Checking for null and undefined +---*/ + +var x = []; +x[null] = 0; +assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined'); +assert.sameValue(x["null"], 0, 'The value of x["null"] is expected to be 0'); + +var y = []; +y[undefined] = 0; +assert.sameValue(y[0], undefined, 'The value of y[0] is expected to equal undefined'); +assert.sameValue(y["undefined"], 0, 'The value of y["undefined"] is expected to be 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T6.js b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T6.js new file mode 100644 index 0000000000..ba9403e479 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T6.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T6 +description: Checking for Boolean object +---*/ + +var x = []; +x[new Boolean(true)] = 1; +assert.sameValue(x[1], undefined, 'The value of x[1] is expected to equal undefined'); +assert.sameValue(x["true"], 1, 'The value of x["true"] is expected to be 1'); + +x[new Boolean(false)] = 0; +assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined'); +assert.sameValue(x["false"], 0, 'The value of x["false"] is expected to be 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T7.js b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T7.js new file mode 100644 index 0000000000..119c825b16 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T7.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T7 +description: Checking for Number object +---*/ + +var x = []; +x[new Number(0)] = 0; +assert.sameValue(x[0], 0, 'The value of x[0] is expected to be 0'); + +var y = []; +y[new Number(1)] = 1; +assert.sameValue(y[1], 1, 'The value of y[1] is expected to be 1'); + +var z = []; +z[new Number(1.1)] = 1; +assert.sameValue(z["1.1"], 1, 'The value of z["1.1"] is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T8.js b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T8.js new file mode 100644 index 0000000000..feb6e094a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T8.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T8 +description: Checking for Number object +---*/ + +var x = []; +x[new String("0")] = 0; +assert.sameValue(x[0], 0, 'The value of x[0] is expected to be 0'); + +var y = []; +y[new String("1")] = 1; +assert.sameValue(y[1], 1, 'The value of y[1] is expected to be 1'); + +var z = []; +z[new String("1.1")] = 1; +assert.sameValue(z["1.1"], 1, 'The value of z["1.1"] is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T9.js b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T9.js new file mode 100644 index 0000000000..2b56d5a27b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T9.js @@ -0,0 +1,121 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T9 +description: If Type(value) is Object, evaluate ToPrimitive(value, String) +---*/ + +var x = []; +var object = { + valueOf: function() { + return 1 + } +}; +x[object] = 0; +assert.sameValue(x["[object Object]"], 0, 'The value of x["[object Object]"] is expected to be 0'); + +x = []; +var object = { + valueOf: function() { + return 1 + }, + toString: function() { + return 0 + } +}; +x[object] = 0; +assert.sameValue(x[0], 0, 'The value of x[0] is expected to be 0'); + +x = []; +var object = { + valueOf: function() { + return 1 + }, + toString: function() { + return {} + } +}; +x[object] = 0; +assert.sameValue(x[1], 0, 'The value of x[1] is expected to be 0'); + +try { + x = []; + var object = { + valueOf: function() { + throw "error" + }, + toString: function() { + return 1 + } + }; + x[object] = 0; + assert.sameValue(x[1], 0, 'The value of x[1] is expected to be 0'); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} + +x = []; +var object = { + toString: function() { + return 1 + } +}; +x[object] = 0; +assert.sameValue(x[1], 0, 'The value of x[1] is expected to be 0'); + +x = []; +var object = { + valueOf: function() { + return {} + }, + toString: function() { + return 1 + } +} +x[object] = 0; +assert.sameValue(x[1], 0, 'The value of x[1] is expected to be 0'); + +try { + x = []; + var object = { + valueOf: function() { + return 1 + }, + toString: function() { + throw "error" + } + }; + x[object]; + throw new Test262Error('#7.1: x = []; var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; x[object] throw "error". Actual: ' + (x[object])); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} + +try { + x = []; + var object = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + x[object]; + throw new Test262Error('#8.1: x = []; var object = {valueOf: function() {return {}}, toString: function() {return {}}}; x[object] throw TypeError. Actual: ' + (x[object])); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/Symbol.species/browser.js b/js/src/tests/test262/built-ins/Array/Symbol.species/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/Symbol.species/length.js b/js/src/tests/test262/built-ins/Array/Symbol.species/length.js new file mode 100644 index 0000000000..a0744b86ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/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. + +/*--- +es6id: 22.1.2.5 +description: > + get Array [ @@species ].length is 0. +info: | + get Array [ @@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(Array, 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/Array/Symbol.species/return-value.js b/js/src/tests/test262/built-ins/Array/Symbol.species/return-value.js new file mode 100644 index 0000000000..96c47838e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/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-array-@@species +description: Return value of @@species accessor method +info: | + 1. Return the this value. +features: [Symbol.species] +---*/ + +var thisVal = {}; +var accessor = Object.getOwnPropertyDescriptor(Array, Symbol.species).get; + +assert.sameValue(accessor.call(thisVal), thisVal); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/Symbol.species/shell.js b/js/src/tests/test262/built-ins/Array/Symbol.species/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/Symbol.species/symbol-species-name.js b/js/src/tests/test262/built-ins/Array/Symbol.species/symbol-species-name.js new file mode 100644 index 0000000000..8c943ef709 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/Symbol.species/symbol-species-name.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. +/*--- +es6id: 22.1.2.5 +description: > + Array[Symbol.species] accessor property get name +info: | + 22.1.2.5 get Array [ @@species ] + + ... + The value of the name property of this function is "get [Symbol.species]". +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(Array, Symbol.species); + +assert.sameValue( + descriptor.get.name, + 'get [Symbol.species]' +); + +verifyNotEnumerable(descriptor.get, 'name'); +verifyNotWritable(descriptor.get, 'name'); +verifyConfigurable(descriptor.get, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/Symbol.species/symbol-species.js b/js/src/tests/test262/built-ins/Array/Symbol.species/symbol-species.js new file mode 100644 index 0000000000..5aa214e570 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/Symbol.species/symbol-species.js @@ -0,0 +1,23 @@ +// Copyright 2015 Cubane Canada, Inc. All rights reserved. +// See LICENSE for details. + +/*--- +info: | + Array has a property at `Symbol.species` +esid: sec-get-array-@@species +author: Sam Mikes +description: Array[Symbol.species] exists per spec +includes: [propertyHelper.js] +features: [Symbol.species] +---*/ + +var desc = Object.getOwnPropertyDescriptor(Array, Symbol.species); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, 'function'); + +verifyNotWritable(Array, Symbol.species, Symbol.species); +verifyNotEnumerable(Array, Symbol.species); +verifyConfigurable(Array, Symbol.species); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/browser.js b/js/src/tests/test262/built-ins/Array/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/constructor.js b/js/src/tests/test262/built-ins/Array/constructor.js new file mode 100644 index 0000000000..294e63ad80 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/constructor.js @@ -0,0 +1,12 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-constructor-array +description: > + The Array constructor is a built-in function +---*/ + +assert.sameValue(typeof Array, 'function', 'The value of `typeof Array` is expected to be "function"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/Array.from-descriptor.js b/js/src/tests/test262/built-ins/Array/from/Array.from-descriptor.js new file mode 100644 index 0000000000..4d68536a30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/Array.from-descriptor.js @@ -0,0 +1,14 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Testing descriptor property of Array.from +includes: [propertyHelper.js] +esid: sec-array.from +---*/ + +verifyWritable(Array, "from"); +verifyNotEnumerable(Array, "from"); +verifyConfigurable(Array, "from"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/Array.from-name.js b/js/src/tests/test262/built-ins/Array/from/Array.from-name.js new file mode 100644 index 0000000000..267647c639 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/Array.from-name.js @@ -0,0 +1,32 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.from +description: '`name` property' +info: | + ES6 Section 17: + + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value is a + String. Unless otherwise specified, this value is the name that is given to + the function in this specification. + + [...] + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.from.name, + 'from', + 'The value of Array.from.name is expected to be "from"' +); + +verifyNotEnumerable(Array.from, 'name'); +verifyNotWritable(Array.from, 'name'); +verifyConfigurable(Array.from, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/Array.from_arity.js b/js/src/tests/test262/built-ins/Array/from/Array.from_arity.js new file mode 100644 index 0000000000..68b3287765 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/Array.from_arity.js @@ -0,0 +1,23 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +/*--- +esid: sec-array.from +description: > + The length property of the Array.from method is 1. +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + + ... + + The length property of the from method is 1. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.from.length, 1, 'The value of Array.from.length is expected to be 1'); + +verifyNotEnumerable(Array.from, 'length'); +verifyNotWritable(Array.from, 'length'); +verifyConfigurable(Array.from, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/Array.from_forwards-length-for-array-likes.js b/js/src/tests/test262/built-ins/Array/from/Array.from_forwards-length-for-array-likes.js new file mode 100644 index 0000000000..8bb73635ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/Array.from_forwards-length-for-array-likes.js @@ -0,0 +1,41 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +/*--- +esid: sec-array.from +description: > + If this is a constructor, and items doesn't have an @@iterator, + returns a new instance of this +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + + 4. Let usingIterator be GetMethod(items, @@iterator). + ... + 6. If usingIterator is not undefined, then + ... + 12. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 13. Else, + a. Let A be ArrayCreate(len). + ... + 19. Return A. +---*/ + +var result; + +function MyCollection() { + this.args = arguments; +} + +result = Array.from.call(MyCollection, { + length: 42 +}); + +assert.sameValue(result.args.length, 1, 'The value of result.args.length is expected to be 1'); +assert.sameValue(result.args[0], 42, 'The value of result.args[0] is expected to be 42'); +assert( + result instanceof MyCollection, + 'The result of evaluating (result instanceof MyCollection) is expected to be true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/array-like-has-length-but-no-indexes-with-values.js b/js/src/tests/test262/built-ins/Array/from/array-like-has-length-but-no-indexes-with-values.js new file mode 100644 index 0000000000..e83db0f656 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/array-like-has-length-but-no-indexes-with-values.js @@ -0,0 +1,41 @@ +// Copyright (c) 2021 Rick Waldron. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-array.from +description: > + Creates an array with length that is equal to the value of the + length property of the given array-like, regardless of + the presence of corresponding indices and values. +info: | + Array.from ( items [ , mapfn [ , thisArg ] ] ) + + 7. Let arrayLike be ! ToObject(items). + 8. Let len be ? LengthOfArrayLike(arrayLike). + 9. If IsConstructor(C) is true, then + a. Let A be ? Construct(C, « 𝔽(len) »). + 10. Else, + a. Let A be ? ArrayCreate(len). + +includes: [compareArray.js] +---*/ + +const length = 5; + +const newlyCreatedArray = Array.from({ length }); +assert.sameValue( + newlyCreatedArray.length, + length, + "The newly created array's length is equal to the value of the length property for the provided array like object" +); +assert.compareArray(newlyCreatedArray, [undefined, undefined, undefined, undefined, undefined]); + +const newlyCreatedAndMappedArray = Array.from({ length }).map(x => 1); +assert.sameValue( + newlyCreatedAndMappedArray.length, + length, + "The newly created and mapped array's length is equal to the value of the length property for the provided array like object" +); +assert.compareArray(newlyCreatedAndMappedArray, [1, 1, 1, 1, 1]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/browser.js b/js/src/tests/test262/built-ins/Array/from/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/from/calling-from-valid-1-noStrict.js b/js/src/tests/test262/built-ins/Array/from/calling-from-valid-1-noStrict.js new file mode 100644 index 0000000000..21eb245493 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/calling-from-valid-1-noStrict.js @@ -0,0 +1,68 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.from +description: Map function without thisArg on non strict mode +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + + ... + 10. Let len be ToLength(Get(arrayLike, "length")). + 11. ReturnIfAbrupt(len). + 12. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 13. Else, + b. Let A be ArrayCreate(len). + 14. ReturnIfAbrupt(A). + 15. Let k be 0. + 16. Repeat, while k < len + a. Let Pk be ToString(k). + b. Let kValue be Get(arrayLike, Pk). + c. ReturnIfAbrupt(kValue). + d. If mapping is true, then + i. Let mappedValue be Call(mapfn, T, «kValue, k»). + ... +flags: [noStrict] +---*/ + +var list = { + '0': 41, + '1': 42, + '2': 43, + length: 3 +}; +var calls = []; + +function mapFn(value) { + calls.push({ + args: arguments, + thisArg: this + }); + return value * 2; +} + +var result = Array.from(list, mapFn); + +assert.sameValue(result.length, 3, 'The value of result.length is expected to be 3'); +assert.sameValue(result[0], 82, 'The value of result[0] is expected to be 82'); +assert.sameValue(result[1], 84, 'The value of result[1] is expected to be 84'); +assert.sameValue(result[2], 86, 'The value of result[2] is expected to be 86'); + +assert.sameValue(calls.length, 3, 'The value of calls.length is expected to be 3'); + +assert.sameValue(calls[0].args.length, 2, 'The value of calls[0].args.length is expected to be 2'); +assert.sameValue(calls[0].args[0], 41, 'The value of calls[0].args[0] is expected to be 41'); +assert.sameValue(calls[0].args[1], 0, 'The value of calls[0].args[1] is expected to be 0'); +assert.sameValue(calls[0].thisArg, this, 'The value of calls[0].thisArg is expected to be this'); + +assert.sameValue(calls[1].args.length, 2, 'The value of calls[1].args.length is expected to be 2'); +assert.sameValue(calls[1].args[0], 42, 'The value of calls[1].args[0] is expected to be 42'); +assert.sameValue(calls[1].args[1], 1, 'The value of calls[1].args[1] is expected to be 1'); +assert.sameValue(calls[1].thisArg, this, 'The value of calls[1].thisArg is expected to be this'); + +assert.sameValue(calls[2].args.length, 2, 'The value of calls[2].args.length is expected to be 2'); +assert.sameValue(calls[2].args[0], 43, 'The value of calls[2].args[0] is expected to be 43'); +assert.sameValue(calls[2].args[1], 2, 'The value of calls[2].args[1] is expected to be 2'); +assert.sameValue(calls[2].thisArg, this, 'The value of calls[2].thisArg is expected to be this'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/calling-from-valid-1-onlyStrict-strict.js b/js/src/tests/test262/built-ins/Array/from/calling-from-valid-1-onlyStrict-strict.js new file mode 100644 index 0000000000..415c0f8a35 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/calling-from-valid-1-onlyStrict-strict.js @@ -0,0 +1,69 @@ +'use strict'; +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.from +description: Map function without thisArg on strict mode +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + + ... + 10. Let len be ToLength(Get(arrayLike, "length")). + 11. ReturnIfAbrupt(len). + 12. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 13. Else, + b. Let A be ArrayCreate(len). + 14. ReturnIfAbrupt(A). + 15. Let k be 0. + 16. Repeat, while k < len + a. Let Pk be ToString(k). + b. Let kValue be Get(arrayLike, Pk). + c. ReturnIfAbrupt(kValue). + d. If mapping is true, then + i. Let mappedValue be Call(mapfn, T, «kValue, k»). + ... +flags: [onlyStrict] +---*/ + +var list = { + '0': 41, + '1': 42, + '2': 43, + length: 3 +}; +var calls = []; + +function mapFn(value) { + calls.push({ + args: arguments, + thisArg: this + }); + return value * 2; +} + +var result = Array.from(list, mapFn); + +assert.sameValue(result.length, 3, 'The value of result.length is expected to be 3'); +assert.sameValue(result[0], 82, 'The value of result[0] is expected to be 82'); +assert.sameValue(result[1], 84, 'The value of result[1] is expected to be 84'); +assert.sameValue(result[2], 86, 'The value of result[2] is expected to be 86'); + +assert.sameValue(calls.length, 3, 'The value of calls.length is expected to be 3'); + +assert.sameValue(calls[0].args.length, 2, 'The value of calls[0].args.length is expected to be 2'); +assert.sameValue(calls[0].args[0], 41, 'The value of calls[0].args[0] is expected to be 41'); +assert.sameValue(calls[0].args[1], 0, 'The value of calls[0].args[1] is expected to be 0'); +assert.sameValue(calls[0].thisArg, undefined, 'The value of calls[0].thisArg is expected to equal undefined'); + +assert.sameValue(calls[1].args.length, 2, 'The value of calls[1].args.length is expected to be 2'); +assert.sameValue(calls[1].args[0], 42, 'The value of calls[1].args[0] is expected to be 42'); +assert.sameValue(calls[1].args[1], 1, 'The value of calls[1].args[1] is expected to be 1'); +assert.sameValue(calls[1].thisArg, undefined, 'The value of calls[1].thisArg is expected to equal undefined'); + +assert.sameValue(calls[2].args.length, 2, 'The value of calls[2].args.length is expected to be 2'); +assert.sameValue(calls[2].args[0], 43, 'The value of calls[2].args[0] is expected to be 43'); +assert.sameValue(calls[2].args[1], 2, 'The value of calls[2].args[1] is expected to be 2'); +assert.sameValue(calls[2].thisArg, undefined, 'The value of calls[2].thisArg is expected to equal undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/calling-from-valid-2.js b/js/src/tests/test262/built-ins/Array/from/calling-from-valid-2.js new file mode 100644 index 0000000000..835f3d3b97 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/calling-from-valid-2.js @@ -0,0 +1,69 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-array.from +description: Calling from with a valid map function with thisArg +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + + ... + 10. Let len be ToLength(Get(arrayLike, "length")). + 11. ReturnIfAbrupt(len). + 12. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 13. Else, + b. Let A be ArrayCreate(len). + 14. ReturnIfAbrupt(A). + 15. Let k be 0. + 16. Repeat, while k < len + a. Let Pk be ToString(k). + b. Let kValue be Get(arrayLike, Pk). + c. ReturnIfAbrupt(kValue). + d. If mapping is true, then + i. Let mappedValue be Call(mapfn, T, «kValue, k»). + ... +---*/ + +var list = { + '0': 41, + '1': 42, + '2': 43, + length: 3 +}; +var calls = []; +var thisArg = {}; + +function mapFn(value) { + calls.push({ + args: arguments, + thisArg: this + }); + return value * 2; +} + +var result = Array.from(list, mapFn, thisArg); + +assert.sameValue(result.length, 3, 'The value of result.length is expected to be 3'); +assert.sameValue(result[0], 82, 'The value of result[0] is expected to be 82'); +assert.sameValue(result[1], 84, 'The value of result[1] is expected to be 84'); +assert.sameValue(result[2], 86, 'The value of result[2] is expected to be 86'); + +assert.sameValue(calls.length, 3, 'The value of calls.length is expected to be 3'); + +assert.sameValue(calls[0].args.length, 2, 'The value of calls[0].args.length is expected to be 2'); +assert.sameValue(calls[0].args[0], 41, 'The value of calls[0].args[0] is expected to be 41'); +assert.sameValue(calls[0].args[1], 0, 'The value of calls[0].args[1] is expected to be 0'); +assert.sameValue(calls[0].thisArg, thisArg, 'The value of calls[0].thisArg is expected to equal the value of thisArg'); + +assert.sameValue(calls[1].args.length, 2, 'The value of calls[1].args.length is expected to be 2'); +assert.sameValue(calls[1].args[0], 42, 'The value of calls[1].args[0] is expected to be 42'); +assert.sameValue(calls[1].args[1], 1, 'The value of calls[1].args[1] is expected to be 1'); +assert.sameValue(calls[1].thisArg, thisArg, 'The value of calls[1].thisArg is expected to equal the value of thisArg'); + +assert.sameValue(calls[2].args.length, 2, 'The value of calls[2].args.length is expected to be 2'); +assert.sameValue(calls[2].args[0], 43, 'The value of calls[2].args[0] is expected to be 43'); +assert.sameValue(calls[2].args[1], 2, 'The value of calls[2].args[1] is expected to be 2'); +assert.sameValue(calls[2].thisArg, thisArg, 'The value of calls[2].thisArg is expected to equal the value of thisArg'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/elements-added-after.js b/js/src/tests/test262/built-ins/Array/from/elements-added-after.js new file mode 100644 index 0000000000..7676448d32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/elements-added-after.js @@ -0,0 +1,40 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Elements added after the call to from +esid: sec-array.from +---*/ + +var arrayIndex = -1; +var originalLength = 7; +var obj = { + length: originalLength, + 0: 2, + 1: 4, + 2: 8, + 3: 16, + 4: 32, + 5: 64, + 6: 128 +}; +var array = [2, 4, 8, 16, 32, 64, 128]; + +function mapFn(value, index) { + arrayIndex++; + assert.sameValue(value, obj[arrayIndex], 'The value of value is expected to equal the value of obj[arrayIndex]'); + assert.sameValue(index, arrayIndex, 'The value of index is expected to equal the value of arrayIndex'); + obj[originalLength + arrayIndex] = 2 * arrayIndex + 1; + + return obj[arrayIndex]; +} + + +var a = Array.from(obj, mapFn); +assert.sameValue(a.length, array.length, 'The value of a.length is expected to equal the value of array.length'); + +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], array[j], 'The value of a[j] is expected to equal the value of array[j]'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/elements-deleted-after.js b/js/src/tests/test262/built-ins/Array/from/elements-deleted-after.js new file mode 100644 index 0000000000..5b63a932aa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/elements-deleted-after.js @@ -0,0 +1,34 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: > + Elements deleted after the call started and before visited are not + visited +esid: sec-array.from +---*/ + +var originalArray = [0, 1, -2, 4, -8, 16]; +var array = [0, 1, -2, 4, -8, 16]; +var a = []; +var arrayIndex = -1; + +function mapFn(value, index) { + this.arrayIndex++; + assert.sameValue(value, array[this.arrayIndex], 'The value of value is expected to equal the value of array[this.arrayIndex]'); + assert.sameValue(index, this.arrayIndex, 'The value of index is expected to equal the value of this.arrayIndex'); + + array.splice(array.length - 1, 1); + return 127; +} + + +a = Array.from(array, mapFn, this); + +assert.sameValue(a.length, originalArray.length / 2, 'The value of a.length is expected to be originalArray.length / 2'); + +for (var j = 0; j < originalArray.length / 2; j++) { + assert.sameValue(a[j], 127, 'The value of a[j] is expected to be 127'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/elements-updated-after.js b/js/src/tests/test262/built-ins/Array/from/elements-updated-after.js new file mode 100644 index 0000000000..210aaf5fd4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/elements-updated-after.js @@ -0,0 +1,29 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Elements are updated after the call to from +esid: sec-array.from +---*/ + +var array = [127, 4, 8, 16, 32, 64, 128]; +var arrayIndex = -1; + +function mapFn(value, index) { + arrayIndex++; + if (index + 1 < array.length) { + array[index + 1] = 127; + } + assert.sameValue(value, 127, 'The value of value is expected to be 127'); + assert.sameValue(index, arrayIndex, 'The value of index is expected to equal the value of arrayIndex'); + + return value; +} + +var a = Array.from(array, mapFn); +assert.sameValue(a.length, array.length, 'The value of a.length is expected to equal the value of array.length'); +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], 127, 'The value of a[j] is expected to be 127'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/from-array.js b/js/src/tests/test262/built-ins/Array/from/from-array.js new file mode 100644 index 0000000000..708a4779bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/from-array.js @@ -0,0 +1,25 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Passing a valid array +esid: sec-array.from +---*/ + +var array = [0, 'foo', , Infinity]; +var result = Array.from(array); + +assert.sameValue(result.length, 4, 'The value of result.length is expected to be 4'); +assert.sameValue(result[0], 0, 'The value of result[0] is expected to be 0'); +assert.sameValue(result[1], 'foo', 'The value of result[1] is expected to be "foo"'); +assert.sameValue(result[2], undefined, 'The value of result[2] is expected to equal undefined'); +assert.sameValue(result[3], Infinity, 'The value of result[3] is expected to equal Infinity'); + +assert.notSameValue( + result, array, + 'The value of result is expected to not equal the value of `array`' +); + +assert(result instanceof Array, 'The result of evaluating (result instanceof Array) is expected to be true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/from-string.js b/js/src/tests/test262/built-ins/Array/from/from-string.js new file mode 100644 index 0000000000..88772a85ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/from-string.js @@ -0,0 +1,19 @@ +// Copyright (c) 2014 Hank Yates. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.from +description: Testing Array.from when passed a String +author: Hank Yates (hankyates@gmail.com) +---*/ + +var arrLikeSource = 'Test'; +var result = Array.from(arrLikeSource); + +assert.sameValue(result.length, 4, 'The value of result.length is expected to be 4'); +assert.sameValue(result[0], 'T', 'The value of result[0] is expected to be "T"'); +assert.sameValue(result[1], 'e', 'The value of result[1] is expected to be "e"'); +assert.sameValue(result[2], 's', 'The value of result[2] is expected to be "s"'); +assert.sameValue(result[3], 't', 'The value of result[3] is expected to be "t"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/get-iter-method-err.js b/js/src/tests/test262/built-ins/Array/from/get-iter-method-err.js new file mode 100644 index 0000000000..c7795c53d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/get-iter-method-err.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-array.from +description: Error accessing items' `Symbol.iterator` attribute +info: | + [...] + 4. Let usingIterator be GetMethod(items, @@iterator). + 5. ReturnIfAbrupt(usingIterator). +features: [Symbol.iterator] +---*/ + +var items = {}; +Object.defineProperty(items, Symbol.iterator, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + Array.from(items); +}, 'Array.from(items) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/items-is-arraybuffer.js b/js/src/tests/test262/built-ins/Array/from/items-is-arraybuffer.js new file mode 100644 index 0000000000..6a93179741 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/items-is-arraybuffer.js @@ -0,0 +1,21 @@ +// Copyright 2015 Leonardo Balter. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.from +description: Return empty array if items argument is an ArrayBuffer +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + + ... + 4. Let usingIterator be GetMethod(items, @@iterator). + 5. ReturnIfAbrupt(usingIterator). + ... +---*/ + +var arrayBuffer = new ArrayBuffer(7); + +var result = Array.from(arrayBuffer); + +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/items-is-null-throws.js b/js/src/tests/test262/built-ins/Array/from/items-is-null-throws.js new file mode 100644 index 0000000000..4142bc2553 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/items-is-null-throws.js @@ -0,0 +1,19 @@ +// Copyright 2015 Leonardo Balter. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.from +description: Throws a TypeError if items argument is null +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + + ... + 4. Let usingIterator be GetMethod(items, @@iterator). + 5. ReturnIfAbrupt(usingIterator). + ... +---*/ + +assert.throws(TypeError, function() { + Array.from(null); +}, 'Array.from(null) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-adv-err.js b/js/src/tests/test262/built-ins/Array/from/iter-adv-err.js new file mode 100644 index 0000000000..66030a8e68 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-adv-err.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-array.from +description: Error advancing iterator +info: | + [...] + 6. If usingIterator is not undefined, then + [...] + g. Repeat + i. Let Pk be ToString(k). + ii. Let next be IteratorStep(iterator). + iii. ReturnIfAbrupt(next). +features: [Symbol.iterator] +---*/ + +var items = {}; +items[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + Array.from(items); +}, 'Array.from(items) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-cstm-ctor-err.js b/js/src/tests/test262/built-ins/Array/from/iter-cstm-ctor-err.js new file mode 100644 index 0000000000..5b54e6d9e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-cstm-ctor-err.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-array.from +description: > + Error creating object with custom constructor (traversed via iterator) +info: | + [...] + 6. If usingIterator is not undefined, then + a. If IsConstructor(C) is true, then + i. Let A be Construct(C). + b. Else, + i. Let A be ArrayCreate(0). + c. ReturnIfAbrupt(A). +features: [Symbol.iterator] +---*/ + +var C = function() { + throw new Test262Error(); +}; +var items = {}; +items[Symbol.iterator] = function() {}; + +assert.throws(Test262Error, function() { + Array.from.call(C, items); +}, 'Array.from.call(C, items) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-cstm-ctor.js b/js/src/tests/test262/built-ins/Array/from/iter-cstm-ctor.js new file mode 100644 index 0000000000..28922e7062 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-cstm-ctor.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-array.from +description: Creating object with custom constructor (traversed via iterator) +info: | + [...] + 6. If usingIterator is not undefined, then + a. If IsConstructor(C) is true, then + i. Let A be Construct(C). + b. Else, + i. Let A be ArrayCreate(0). + c. ReturnIfAbrupt(A). +features: [Symbol.iterator] +---*/ + +var thisVal, args; +var callCount = 0; +var C = function() { + thisVal = this; + args = arguments; + callCount += 1; +}; +var result; +var items = {}; +items[Symbol.iterator] = function() { + return { + next: function() { + return { + done: true + }; + } + }; +}; + +result = Array.from.call(C, items); + +assert( + result instanceof C, 'The result of evaluating (result instanceof C) is expected to be true' +); +assert.sameValue( + result.constructor, + C, + 'The value of result.constructor is expected to equal the value of C' +); +assert.sameValue(callCount, 1, 'The value of callCount is expected to be 1'); +assert.sameValue(thisVal, result, 'The value of thisVal is expected to equal the value of result'); +assert.sameValue(args.length, 0, 'The value of args.length is expected to be 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-get-iter-err.js b/js/src/tests/test262/built-ins/Array/from/iter-get-iter-err.js new file mode 100644 index 0000000000..278207b6b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-get-iter-err.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-array.from +description: Error creating iterator object +info: | + [...] + 6. If usingIterator is not undefined, then + [...] + d. Let iterator be GetIterator(items, usingIterator). + e. ReturnIfAbrupt(iterator). +features: [Symbol.iterator] +---*/ + +var itemsPoisonedSymbolIterator = {}; +itemsPoisonedSymbolIterator[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + Array.from(itemsPoisonedSymbolIterator); +}, 'Array.from(itemsPoisonedSymbolIterator) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-get-iter-val-err.js b/js/src/tests/test262/built-ins/Array/from/iter-get-iter-val-err.js new file mode 100644 index 0000000000..c7ce81ce0b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-get-iter-val-err.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-array.from +description: Error retrieving value of iterator result +info: | + [...] + 6. If usingIterator is not undefined, then + [...] + g. Repeat + [...] + v. Let nextValue be IteratorValue(next). + vi. ReturnIfAbrupt(nextValue). +features: [Symbol.iterator] +---*/ + +var itemsPoisonedIteratorValue = {}; +var poisonedValue = {}; +Object.defineProperty(poisonedValue, 'value', { + get: function() { + throw new Test262Error(); + } +}); +itemsPoisonedIteratorValue[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + Array.from(itemsPoisonedIteratorValue); +}, 'Array.from(itemsPoisonedIteratorValue) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-map-fn-args.js b/js/src/tests/test262/built-ins/Array/from/iter-map-fn-args.js new file mode 100644 index 0000000000..bab7631d3f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-map-fn-args.js @@ -0,0 +1,73 @@ +// 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-array.from +description: > + Arguments of mapping function (traversed via iterator) +info: | + [...] + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. + b. If thisArg was supplied, let T be thisArg; else let T be undefined. + c. Let mapping be true + [...] + 6. If usingIterator is not undefined, then + [...] + g. Repeat + [...] + vii. If mapping is true, then + 1. Let mappedValue be Call(mapfn, T, «nextValue, k»). + 2. If mappedValue is an abrupt completion, return + IteratorClose(iterator, mappedValue). + 3. Let mappedValue be mappedValue.[[value]]. +features: [Symbol.iterator] +---*/ + +var args = []; +var firstResult = { + done: false, + value: {} +}; +var secondResult = { + done: false, + value: {} +}; +var mapFn = function(value, idx) { + args.push(arguments); +}; +var items = {}; +var nextResult = firstResult; +var nextNextResult = secondResult; + +items[Symbol.iterator] = function() { + return { + next: function() { + var result = nextResult; + nextResult = nextNextResult; + nextNextResult = { + done: true + }; + + return result; + } + }; +}; + +Array.from(items, mapFn); + +assert.sameValue(args.length, 2, 'The value of args.length is expected to be 2'); + +assert.sameValue(args[0].length, 2, 'The value of args[0].length is expected to be 2'); +assert.sameValue( + args[0][0], firstResult.value, 'The value of args[0][0] is expected to equal the value of firstResult.value' +); +assert.sameValue(args[0][1], 0, 'The value of args[0][1] is expected to be 0'); + +assert.sameValue(args[1].length, 2, 'The value of args[1].length is expected to be 2'); +assert.sameValue( + args[1][0], secondResult.value, 'The value of args[1][0] is expected to equal the value of secondResult.value' +); +assert.sameValue(args[1][1], 1, 'The value of args[1][1] is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-map-fn-err.js b/js/src/tests/test262/built-ins/Array/from/iter-map-fn-err.js new file mode 100644 index 0000000000..beeca8e4eb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-map-fn-err.js @@ -0,0 +1,43 @@ +// 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-array.from +description: Error invoking map function (traversed via iterator) +info: | + [...] + 6. If usingIterator is not undefined, then + [...] + g. Repeat + [...] + vii. If mapping is true, then + 1. Let mappedValue be Call(mapfn, T, «nextValue, k»). + 2. If mappedValue is an abrupt completion, return + IteratorClose(iterator, mappedValue). +features: [Symbol.iterator] +---*/ + +var closeCount = 0; +var mapFn = function() { + throw new Test262Error(); +}; +var items = {}; +items[Symbol.iterator] = function() { + return { + return: function() { + closeCount += 1; + }, + next: function() { + return { + done: false + }; + } + }; +}; + +assert.throws(Test262Error, function() { + Array.from(items, mapFn); +}, 'Array.from(items, mapFn) throws a Test262Error exception'); + +assert.sameValue(closeCount, 1, 'The value of closeCount is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-map-fn-return.js b/js/src/tests/test262/built-ins/Array/from/iter-map-fn-return.js new file mode 100644 index 0000000000..075bc6cd30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-map-fn-return.js @@ -0,0 +1,72 @@ +// 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-array.from +description: Value returned by mapping function (traversed via iterator) +info: | + [...] + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. + b. If thisArg was supplied, let T be thisArg; else let T be undefined. + c. Let mapping be true + [...] + 6. If usingIterator is not undefined, then + [...] + g. Repeat + [...] + vii. If mapping is true, then + 1. Let mappedValue be Call(mapfn, T, «nextValue, k»). + 2. If mappedValue is an abrupt completion, return + IteratorClose(iterator, mappedValue). + 3. Let mappedValue be mappedValue.[[value]]. +features: [Symbol.iterator] +---*/ + +var thisVals = []; +var nextResult = { + done: false, + value: {} +}; +var nextNextResult = { + done: false, + value: {} +}; +var firstReturnVal = {}; +var secondReturnVal = {}; +var mapFn = function(value, idx) { + var returnVal = nextReturnVal; + nextReturnVal = nextNextReturnVal; + nextNextReturnVal = null; + return returnVal; +}; +var nextReturnVal = firstReturnVal; +var nextNextReturnVal = secondReturnVal; +var items = {}; +var result; + +items[Symbol.iterator] = function() { + return { + next: function() { + var result = nextResult; + nextResult = nextNextResult; + nextNextResult = { + done: true + }; + + return result; + } + }; +}; + +result = Array.from(items, mapFn); + +assert.sameValue(result.length, 2, 'The value of result.length is expected to be 2'); +assert.sameValue(result[0], firstReturnVal, 'The value of result[0] is expected to equal the value of firstReturnVal'); +assert.sameValue( + result[1], + secondReturnVal, + 'The value of result[1] is expected to equal the value of secondReturnVal' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-map-fn-this-arg.js b/js/src/tests/test262/built-ins/Array/from/iter-map-fn-this-arg.js new file mode 100644 index 0000000000..16e9381caf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-map-fn-this-arg.js @@ -0,0 +1,59 @@ +// 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-array.from +description: > + `this` value of mapping function with custom `this` argument (traversed via iterator) +info: | + [...] + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. + b. If thisArg was supplied, let T be thisArg; else let T be undefined. + c. Let mapping be true + [...] + 6. If usingIterator is not undefined, then + [...] + g. Repeat + [...] + vii. If mapping is true, then + 1. Let mappedValue be Call(mapfn, T, «nextValue, k»). +features: [Symbol.iterator] +---*/ + +var thisVals = []; +var nextResult = { + done: false, + value: {} +}; +var nextNextResult = { + done: false, + value: {} +}; +var mapFn = function() { + thisVals.push(this); +}; +var items = {}; +var thisVal = {}; + +items[Symbol.iterator] = function() { + return { + next: function() { + var result = nextResult; + nextResult = nextNextResult; + nextNextResult = { + done: true + }; + + return result; + } + }; +}; + +Array.from(items, mapFn, thisVal); + +assert.sameValue(thisVals.length, 2, 'The value of thisVals.length is expected to be 2'); +assert.sameValue(thisVals[0], thisVal, 'The value of thisVals[0] is expected to equal the value of thisVal'); +assert.sameValue(thisVals[1], thisVal, 'The value of thisVals[1] is expected to equal the value of thisVal'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-map-fn-this-non-strict.js b/js/src/tests/test262/built-ins/Array/from/iter-map-fn-this-non-strict.js new file mode 100644 index 0000000000..bd54bcfa19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-map-fn-this-non-strict.js @@ -0,0 +1,62 @@ +// 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-array.from +description: > + `this` value of mapping function in non-strict mode (traversed via iterator) +info: | + [...] + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. + b. If thisArg was supplied, let T be thisArg; else let T be undefined. + c. Let mapping be true + [...] + 6. If usingIterator is not undefined, then + [...] + g. Repeat + [...] + vii. If mapping is true, then + 1. Let mappedValue be Call(mapfn, T, «nextValue, k»). +features: [Symbol.iterator] +flags: [noStrict] +---*/ + +var thisVals = []; +var nextResult = { + done: false, + value: {} +}; +var nextNextResult = { + done: false, + value: {} +}; +var mapFn = function() { + thisVals.push(this); +}; +var items = {}; +var global = function() { + return this; +}(); + +items[Symbol.iterator] = function() { + return { + next: function() { + var result = nextResult; + nextResult = nextNextResult; + nextNextResult = { + done: true + }; + + return result; + } + }; +}; + +Array.from(items, mapFn); + +assert.sameValue(thisVals.length, 2, 'The value of thisVals.length is expected to be 2'); +assert.sameValue(thisVals[0], global, 'The value of thisVals[0] is expected to equal the value of global'); +assert.sameValue(thisVals[1], global, 'The value of thisVals[1] is expected to equal the value of global'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-map-fn-this-strict-strict.js b/js/src/tests/test262/built-ins/Array/from/iter-map-fn-this-strict-strict.js new file mode 100644 index 0000000000..0404185f10 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-map-fn-this-strict-strict.js @@ -0,0 +1,60 @@ +'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-array.from +description: > + `this` value of mapping function in strict mode (traversed via iterator) +info: | + [...] + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. + b. If thisArg was supplied, let T be thisArg; else let T be undefined. + c. Let mapping be true + [...] + 6. If usingIterator is not undefined, then + [...] + g. Repeat + [...] + vii. If mapping is true, then + 1. Let mappedValue be Call(mapfn, T, «nextValue, k»). +features: [Symbol.iterator] +flags: [onlyStrict] +---*/ + +var thisVals = []; +var nextResult = { + done: false, + value: {} +}; +var nextNextResult = { + done: false, + value: {} +}; +var mapFn = function() { + thisVals.push(this); +}; +var items = {}; + +items[Symbol.iterator] = function() { + return { + next: function() { + var result = nextResult; + nextResult = nextNextResult; + nextNextResult = { + done: true + }; + + return result; + } + }; +}; + +Array.from(items, mapFn); + +assert.sameValue(thisVals.length, 2, 'The value of thisVals.length is expected to be 2'); +assert.sameValue(thisVals[0], undefined, 'The value of thisVals[0] is expected to equal undefined'); +assert.sameValue(thisVals[1], undefined, 'The value of thisVals[1] is expected to equal undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-set-elem-prop-err.js b/js/src/tests/test262/built-ins/Array/from/iter-set-elem-prop-err.js new file mode 100644 index 0000000000..96ce7a6f71 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-set-elem-prop-err.js @@ -0,0 +1,54 @@ +// 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-array.from +description: Error setting property on result value (traversed via iterator) +info: | + [...] + 6. If usingIterator is not undefined, then + [...] + g. Repeat + [...] + ix. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, + mappedValue). + x. If defineStatus is an abrupt completion, return + IteratorClose(iterator, defineStatus). +features: [Symbol.iterator] +---*/ + +var constructorSetsIndex0ConfigurableFalse = function() { + Object.defineProperty(this, '0', { + writable: true, + configurable: false + }); +}; +var closeCount = 0; +var items = {}; +var nextResult = { + done: false +}; + +items[Symbol.iterator] = function() { + return { + return: function() { + closeCount += 1; + }, + next: function() { + var result = nextResult; + + nextResult = { + done: true + }; + + return result; + } + }; +}; + +assert.throws(TypeError, function() { + Array.from.call(constructorSetsIndex0ConfigurableFalse, items); +}, 'Array.from.call(constructorSetsIndex0ConfigurableFalse, items) throws a TypeError exception'); + +assert.sameValue(closeCount, 1, 'The value of closeCount is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-set-elem-prop-non-writable.js b/js/src/tests/test262/built-ins/Array/from/iter-set-elem-prop-non-writable.js new file mode 100644 index 0000000000..ff34d68d11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-set-elem-prop-non-writable.js @@ -0,0 +1,45 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.from +description: > + Non-writable properties are overwritten by CreateDataProperty. + (result object's "0" is non-writable, items is iterable) +info: | + Array.from ( items [ , mapfn [ , thisArg ] ] ) + + [...] + 5. If usingIterator is not undefined, then + [...] + e. Repeat, + [...] + viii. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, mappedValue). + [...] +features: [generators] +includes: [propertyHelper.js] +---*/ + +var items = function* () { + yield 2; +}; + +var A = function(_length) { + Object.defineProperty(this, "0", { + value: 1, + writable: false, + enumerable: false, + configurable: true, + }); +}; + +var res = Array.from.call(A, items()); + +verifyProperty(res, "0", { + value: 2, + writable: true, + enumerable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-set-elem-prop.js b/js/src/tests/test262/built-ins/Array/from/iter-set-elem-prop.js new file mode 100644 index 0000000000..20f0573f98 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-set-elem-prop.js @@ -0,0 +1,60 @@ +// 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-array.from +description: Setting property on result value (traversed via iterator) +info: | + [...] + 6. If usingIterator is not undefined, then + [...] + g. Repeat + [...] + ix. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, + mappedValue). +features: [Symbol.iterator] +---*/ + +var items = {}; +var firstIterResult = { + done: false, + value: {} +}; +var secondIterResult = { + done: false, + value: {} +}; +var thirdIterResult = { + done: true, + value: {} +}; +var nextIterResult = firstIterResult; +var nextNextIterResult = secondIterResult; +var result; + +items[Symbol.iterator] = function() { + return { + next: function() { + var result = nextIterResult; + + nextIterResult = nextNextIterResult; + nextNextIterResult = thirdIterResult; + + return result; + } + }; +}; + +result = Array.from(items); + +assert.sameValue( + result[0], + firstIterResult.value, + 'The value of result[0] is expected to equal the value of firstIterResult.value' +); +assert.sameValue( + result[1], + secondIterResult.value, + 'The value of result[1] is expected to equal the value of secondIterResult.value' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-set-length-err.js b/js/src/tests/test262/built-ins/Array/from/iter-set-length-err.js new file mode 100644 index 0000000000..215ca22e1e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-set-length-err.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-array.from +description: Error setting length of object (traversed via iterator) +info: | + [...] + 6. If usingIterator is not undefined, then + [...] + g. Repeat + [...] + iv. If next is false, then + 1. Let setStatus be Set(A, "length", k, true). + 2. ReturnIfAbrupt(setStatus). +features: [Symbol.iterator] +---*/ + +var poisonedPrototypeLength = function() {}; +var items = {}; +Object.defineProperty(poisonedPrototypeLength.prototype, 'length', { + set: function(_) { + throw new Test262Error(); + } +}); +items[Symbol.iterator] = function() { + return { + next: function() { + return { + done: true + }; + } + }; +}; + +assert.throws(Test262Error, function() { + Array.from.call(poisonedPrototypeLength, items); +}, 'Array.from.call(poisonedPrototypeLength, items) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/iter-set-length.js b/js/src/tests/test262/built-ins/Array/from/iter-set-length.js new file mode 100644 index 0000000000..341e0b4a14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-set-length.js @@ -0,0 +1,48 @@ +// 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-array.from +description: Setting length of object (traversed via iterator) +info: | + [...] + 6. If usingIterator is not undefined, then + [...] + g. Repeat + [...] + iv. If next is false, then + 1. Let setStatus be Set(A, "length", k, true). + 2. ReturnIfAbrupt(setStatus). + 3. Return A. +features: [Symbol.iterator] +---*/ + +var items = {}; +var result, nextIterResult, lastIterResult; +items[Symbol.iterator] = function() { + return { + next: function() { + var result = nextIterResult; + nextIterResult = lastIterResult; + return result; + } + }; +}; + +nextIterResult = lastIterResult = { + done: true +}; +result = Array.from(items); + +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); + +nextIterResult = { + done: false +}; +lastIterResult = { + done: true +}; +result = Array.from(items); + +assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/mapfn-is-not-callable-typeerror.js b/js/src/tests/test262/built-ins/Array/from/mapfn-is-not-callable-typeerror.js new file mode 100644 index 0000000000..663355bf7e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/mapfn-is-not-callable-typeerror.js @@ -0,0 +1,36 @@ +// Copyright 2015 Leonardo Balter. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.from +description: Throws a TypeError if mapFn is not callable +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + + ... + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Array.from([], null); +}, 'Array.from([], null) throws a TypeError exception'); + +assert.throws(TypeError, function() { + Array.from([], {}); +}, 'Array.from([], {}) throws a TypeError exception'); + +assert.throws(TypeError, function() { + Array.from([], 'string'); +}, 'Array.from([], "string") throws a TypeError exception'); + +assert.throws(TypeError, function() { + Array.from([], true); +}, 'Array.from([], true) throws a TypeError exception'); + +assert.throws(TypeError, function() { + Array.from([], 42); +}, 'Array.from([], 42) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/mapfn-is-symbol-throws.js b/js/src/tests/test262/built-ins/Array/from/mapfn-is-symbol-throws.js new file mode 100644 index 0000000000..8583e376c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/mapfn-is-symbol-throws.js @@ -0,0 +1,22 @@ +// Copyright 2015 Leonardo Balter. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.from +description: Throws a TypeError if mapFn is not callable (Symbol) +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + + ... + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. + ... +features: + - Symbol +---*/ + +assert.throws(TypeError, function() { + Array.from([], Symbol('1')); +}, 'Array.from([], Symbol("1")) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/mapfn-throws-exception.js b/js/src/tests/test262/built-ins/Array/from/mapfn-throws-exception.js new file mode 100644 index 0000000000..3b3148e616 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/mapfn-throws-exception.js @@ -0,0 +1,20 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: mapFn throws an exception +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var array = [2, 4, 8, 16, 32, 64, 128]; + +function mapFnThrows(value, index, obj) { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + Array.from(array, mapFnThrows); +}, 'Array.from(array, mapFnThrows) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/from/not-a-constructor.js new file mode 100644 index 0000000000..067c4e88ad --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/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: > + Array.from 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, arrow-function] +---*/ + +assert.sameValue(isConstructor(Array.from), false, 'isConstructor(Array.from) must return false'); + +assert.throws(TypeError, () => { + new Array.from([]); +}, 'new Array.from([]) throws a TypeError exception'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/Array/from/proto-from-ctor-realm.js new file mode 100644 index 0000000000..2debc14d02 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/proto-from-ctor-realm.js @@ -0,0 +1,37 @@ +// 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-array.from +es6id: 22.1.2.1 +description: Default [[Prototype]] value derived from realm of the constructor +info: | + [...] + 5. If usingIterator is not undefined, then + a. If IsConstructor(C) is true, then + i. Let A be ? Construct(C). + [...] + + 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] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var a = Array.from.call(C, []); + +assert.sameValue( + Object.getPrototypeOf(a), + other.Object.prototype, + 'Object.getPrototypeOf(Array.from.call(C, [])) returns other.Object.prototype' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/shell.js b/js/src/tests/test262/built-ins/Array/from/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/from/source-array-boundary.js b/js/src/tests/test262/built-ins/Array/from/source-array-boundary.js new file mode 100644 index 0000000000..69b35e4003 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/source-array-boundary.js @@ -0,0 +1,30 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Source array with boundary values +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var array = [Number.MAX_VALUE, Number.MIN_VALUE, Number.NaN, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY]; +var arrayIndex = -1; + +function mapFn(value, index) { + this.arrayIndex++; + assert.sameValue(value, array[this.arrayIndex], 'The value of value is expected to equal the value of array[this.arrayIndex]'); + assert.sameValue(index, this.arrayIndex, 'The value of index is expected to equal the value of this.arrayIndex'); + + return value; +} + +var a = Array.from(array, mapFn, this); + +assert.sameValue(a.length, array.length, 'The value of a.length is expected to equal the value of array.length'); +assert.sameValue(a[0], Number.MAX_VALUE, 'The value of a[0] is expected to equal the value of Number.MAX_VALUE'); +assert.sameValue(a[1], Number.MIN_VALUE, 'The value of a[1] is expected to equal the value of Number.MIN_VALUE'); +assert.sameValue(a[2], Number.NaN, 'The value of a[2] is expected to equal the value of Number.NaN'); +assert.sameValue(a[3], Number.NEGATIVE_INFINITY, 'The value of a[3] is expected to equal the value of Number.NEGATIVE_INFINITY'); +assert.sameValue(a[4], Number.POSITIVE_INFINITY, 'The value of a[4] is expected to equal the value of Number.POSITIVE_INFINITY'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/source-object-constructor.js b/js/src/tests/test262/built-ins/Array/from/source-object-constructor.js new file mode 100644 index 0000000000..7a0d1db9f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/source-object-constructor.js @@ -0,0 +1,17 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: > + Array.from uses a constructor other than Array. +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +assert.sameValue( + Array.from.call(Object, []).constructor, + Object, + 'The value of Array.from.call(Object, []).constructor is expected to equal the value of Object' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/source-object-iterator-1.js b/js/src/tests/test262/built-ins/Array/from/source-object-iterator-1.js new file mode 100644 index 0000000000..908e5dad16 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/source-object-iterator-1.js @@ -0,0 +1,34 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Source object has iterator which throws +esid: sec-array.from +es6id: 22.1.2.1 +features: [Symbol.iterator] +---*/ + +var array = [2, 4, 8, 16, 32, 64, 128]; +var obj = { + [Symbol.iterator]() { + return { + index: 0, + next() { + throw new Test262Error(); + }, + isDone: false, + get val() { + this.index++; + if (this.index > 7) { + this.isDone = true; + } + return 1 << this.index; + } + }; + } +}; +assert.throws(Test262Error, function() { + Array.from(obj); +}, 'Array.from(obj) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/source-object-iterator-2.js b/js/src/tests/test262/built-ins/Array/from/source-object-iterator-2.js new file mode 100644 index 0000000000..3f56c3ae78 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/source-object-iterator-2.js @@ -0,0 +1,39 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Source object has iterator +esid: sec-array.from +es6id: 22.1.2.1 +features: [Symbol.iterator] +---*/ + +var array = [2, 4, 8, 16, 32, 64, 128]; +var obj = { + [Symbol.iterator]() { + return { + index: 0, + next() { + return { + value: this.val, + done: this.isDone + }; + }, + isDone: false, + get val() { + this.index++; + if (this.index > 7) { + this.isDone = true; + } + return 1 << this.index; + } + }; + } +}; +var a = Array.from.call(Object, obj); +assert.sameValue(typeof a, typeof {}, 'The value of `typeof a` is expected to be typeof {}'); +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], array[j], 'The value of a[j] is expected to equal the value of array[j]'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/source-object-length-set-elem-prop-err.js b/js/src/tests/test262/built-ins/Array/from/source-object-length-set-elem-prop-err.js new file mode 100644 index 0000000000..119e5898b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/source-object-length-set-elem-prop-err.js @@ -0,0 +1,54 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.from +description: > + TypeError is thrown if CreateDataProperty fails. + (items is not iterable) +info: | + Array.from ( items [ , mapfn [ , thisArg ] ] ) + + [...] + 4. Let usingIterator be ? GetMethod(items, @@iterator). + 5. If usingIterator is not undefined, then + [...] + 6. NOTE: items is not an Iterable so assume it is an array-like object. + [...] + 12. Repeat, while k < len + [...] + e. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +---*/ + +var items = { + length: 1, +}; + +var A1 = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; + +assert.throws(TypeError, function() { + Array.from.call(A1, items); +}, 'Array.from.call(A1, items) throws a TypeError exception'); + +var A2 = function(_length) { + Object.defineProperty(this, "0", { + writable: true, + configurable: false, + }); +}; + +assert.throws(TypeError, function() { + Array.from.call(A2, items); +}, 'Array.from.call(A2, items) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/source-object-length-set-elem-prop-non-writable.js b/js/src/tests/test262/built-ins/Array/from/source-object-length-set-elem-prop-non-writable.js new file mode 100644 index 0000000000..0ade4a3579 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/source-object-length-set-elem-prop-non-writable.js @@ -0,0 +1,48 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.from +description: > + Non-writable properties are overwritten by CreateDataProperty. + (result object's "0" is non-writable, items is not iterable) +info: | + Array.from ( items [ , mapfn [ , thisArg ] ] ) + + [...] + 4. Let usingIterator be ? GetMethod(items, @@iterator). + 5. If usingIterator is not undefined, then + [...] + 6. NOTE: items is not an Iterable so assume it is an array-like object. + [...] + 12. Repeat, while k < len + [...] + e. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue). + [...] +includes: [propertyHelper.js] +---*/ + +var items = { + "0": 2, + length: 1, +}; + +var A = function(_length) { + Object.defineProperty(this, "0", { + value: 1, + writable: false, + enumerable: false, + configurable: true, + }); +}; + +var res = Array.from.call(A, items); + +verifyProperty(res, "0", { + value: 2, + writable: true, + enumerable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/source-object-length.js b/js/src/tests/test262/built-ins/Array/from/source-object-length.js new file mode 100644 index 0000000000..c9262c824b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/source-object-length.js @@ -0,0 +1,27 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: > + Source is an object with length property and one item is deleted + from the source +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var array = [2, 4, 0, 16]; +var expectedArray = [2, 4, , 16]; +var obj = { + length: 4, + 0: 2, + 1: 4, + 2: 0, + 3: 16 +}; +delete obj[2]; +var a = Array.from(obj); +for (var j = 0; j < expectedArray.length; j++) { + assert.sameValue(a[j], expectedArray[j], 'The value of a[j] is expected to equal the value of expectedArray[j]'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/source-object-missing.js b/js/src/tests/test262/built-ins/Array/from/source-object-missing.js new file mode 100644 index 0000000000..0acd29a694 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/source-object-missing.js @@ -0,0 +1,24 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Source is an object with missing values +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var array = [2, 4, , 16]; +var obj = { + length: 4, + 0: 2, + 1: 4, + 3: 16 +}; + +var a = Array.from.call(Object, obj); +assert.sameValue(typeof a, "object", 'The value of `typeof a` is expected to be "object"'); +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], array[j], 'The value of a[j] is expected to equal the value of array[j]'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/source-object-without.js b/js/src/tests/test262/built-ins/Array/from/source-object-without.js new file mode 100644 index 0000000000..d3f131aead --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/source-object-without.js @@ -0,0 +1,20 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Source is an object without length property +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var obj = { + 0: 2, + 1: 4, + 2: 8, + 3: 16 +} + +var a = Array.from(obj); +assert.sameValue(a.length, 0, 'The value of a.length is expected to be 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/this-null.js b/js/src/tests/test262/built-ins/Array/from/this-null.js new file mode 100644 index 0000000000..a46feccd51 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/this-null.js @@ -0,0 +1,14 @@ +// Copyright 2015 Leonardo Balter. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.from +es6id: 22.1.2.1 +description: Does not throw if this is null +---*/ + +var result = Array.from.call(null, []); + +assert(result instanceof Array, 'The result of evaluating (result instanceof Array) is expected to be true'); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-async-mapped-awaits-once.js b/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-async-mapped-awaits-once.js new file mode 100644 index 0000000000..19fea4fdfa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-async-mapped-awaits-once.js @@ -0,0 +1,31 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Async-iterable awaits each input once with mapping callback +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + async function* generateInput () { + yield* [ 0, 1, 2 ]; + } + const input = generateInput(); + let awaitCounter = 0; + await Array.fromAsync(input, v => { + return { + // This “then” method should occur three times: + // one for each value from the input. + then (resolve, reject) { + awaitCounter ++; + resolve(v); + }, + }; + }); + assert.sameValue(awaitCounter, 3); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-input-does-not-await-input.js b/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-input-does-not-await-input.js new file mode 100644 index 0000000000..7512a69e3f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-input-does-not-await-input.js @@ -0,0 +1,39 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Async-iterable input does not await input values. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const prom = Promise.resolve({}); + const expected = [ prom ]; + + function createInput () { + return { + // The following async iterator will yield one value + // (the promise named “prom”). + [Symbol.asyncIterator]() { + let i = 0; + return { + async next() { + if (i > 0) { + return { done: true }; + } + i++; + return { value: prom, done: false } + }, + }; + }, + }; + } + + const input = createInput(); + const output = await Array.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-input-iteration-err.js b/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-input-iteration-err.js new file mode 100644 index 0000000000..c4c9baec1e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-input-iteration-err.js @@ -0,0 +1,21 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync promise rejects if iteration of input fails. +flags: [async] +features: [Array.fromAsync] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + async function *generateInput () { + throw new Test262Error('This error should be propagated.'); + } + const input = generateInput(); + const outputPromise = Array.fromAsync(input); + await assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-input.js b/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-input.js new file mode 100644 index 0000000000..edf1c21de9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-input.js @@ -0,0 +1,24 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Async-iterable input is transferred to the output array. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expected = [ 0, 1, 2 ]; + + async function* generateInput () { + yield* expected; + } + + const input = generateInput(); + const output = await Array.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-add-to-empty.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-add-to-empty.js new file mode 100644 index 0000000000..ac4687646e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-add-to-empty.js @@ -0,0 +1,45 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync respects array mutation +info: | + Array.fromAsync + 3.j.ii.3. Let next be ? Await(IteratorStep(iteratorRecord)). + + IteratorStep + 1. Let result be ? IteratorNext(iteratorRecord). + + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + + %AsyncFromSyncIteratorPrototype%.next + 6.a. Let result be Completion(IteratorNext(syncIteratorRecord)). + + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + + Array.prototype [ @@iterator ] ( ) + Array.prototype.values ( ) + 2. Return CreateArrayIterator(O, value). + + CreateArrayIterator + 1.b.iii. If index ≥ len, return NormalCompletion(undefined). +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const items = []; + const promise = Array.fromAsync(items); + // By the time we get here, the first next() call has already happened, and returned + // { done: true }. We then return from the loop in Array.fromAsync 3.j.ii. with the empty array, + // and the following line no longer affects that. + items.push(7); + const result = await promise; + assert.compareArray(result, []); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-add-to-singleton.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-add-to-singleton.js new file mode 100644 index 0000000000..4cc0f501fa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-add-to-singleton.js @@ -0,0 +1,44 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync respects array mutation +info: | + Array.fromAsync + 3.j.ii.3. Let next be ? Await(IteratorStep(iteratorRecord)). + + IteratorStep + 1. Let result be ? IteratorNext(iteratorRecord). + + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + + %AsyncFromSyncIteratorPrototype%.next + 6.a. Let result be Completion(IteratorNext(syncIteratorRecord)). + + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + + Array.prototype [ @@iterator ] ( ) + Array.prototype.values ( ) + 2. Return CreateArrayIterator(O, value). + + CreateArrayIterator + 1.b.iii. If index ≥ len, return NormalCompletion(undefined). +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const items = [1]; + const promise = Array.fromAsync(items); + // At this point, the first element of `items` has been read, but the iterator will take other + // changes into account. + items.push(7); + const result = await promise; + assert.compareArray(result, [1, 7]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-add.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-add.js new file mode 100644 index 0000000000..6cf02babb9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-add.js @@ -0,0 +1,44 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync respects array mutation +info: | + Array.fromAsync + 3.j.ii.3. Let next be ? Await(IteratorStep(iteratorRecord)). + + IteratorStep + 1. Let result be ? IteratorNext(iteratorRecord). + + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + + %AsyncFromSyncIteratorPrototype%.next + 6.a. Let result be Completion(IteratorNext(syncIteratorRecord)). + + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + + Array.prototype [ @@iterator ] ( ) + Array.prototype.values ( ) + 2. Return CreateArrayIterator(O, value). + + CreateArrayIterator + 1.b.iii. If index ≥ len, return NormalCompletion(undefined). +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const items = [1, 2, 3]; + const promise = Array.fromAsync(items); + // At this point, the first element of `items` has been read, but the iterator will take other + // changes into account. + items.push(4); + const result = await promise; + assert.compareArray(result, [1, 2, 3, 4]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-mutate.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-mutate.js new file mode 100644 index 0000000000..2d910d2524 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-mutate.js @@ -0,0 +1,45 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync respects array mutation +info: | + Array.fromAsync + 3.j.ii.3. Let next be ? Await(IteratorStep(iteratorRecord)). + + IteratorStep + 1. Let result be ? IteratorNext(iteratorRecord). + + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + + %AsyncFromSyncIteratorPrototype%.next + 6.a. Let result be Completion(IteratorNext(syncIteratorRecord)). + + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + + Array.prototype [ @@iterator ] ( ) + Array.prototype.values ( ) + 2. Return CreateArrayIterator(O, value). + + CreateArrayIterator + 1.b.iii. If index ≥ len, return NormalCompletion(undefined). +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const items = [1, 2, 3]; + const promise = Array.fromAsync(items); + // At this point, the first element of `items` has been read, but the iterator will take other + // changes into account. + items[0] = 7; + items[1] = 8; + const result = await promise; + assert.compareArray(result, [1, 8, 3]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-remove.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-remove.js new file mode 100644 index 0000000000..6733b42260 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-array-remove.js @@ -0,0 +1,44 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync respects array mutation +info: | + Array.fromAsync + 3.j.ii.3. Let next be ? Await(IteratorStep(iteratorRecord)). + + IteratorStep + 1. Let result be ? IteratorNext(iteratorRecord). + + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + + %AsyncFromSyncIteratorPrototype%.next + 6.a. Let result be Completion(IteratorNext(syncIteratorRecord)). + + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + + Array.prototype [ @@iterator ] ( ) + Array.prototype.values ( ) + 2. Return CreateArrayIterator(O, value). + + CreateArrayIterator + 1.b.iii. If index ≥ len, return NormalCompletion(undefined). +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const items = [1, 2, 3]; + const promise = Array.fromAsync(items); + // At this point, the first element of `items` has been read, but the iterator will take other + // changes into account. + items.pop(); + const result = await promise; + assert.compareArray(result, [1, 2]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraybuffer.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraybuffer.js new file mode 100644 index 0000000000..59df9897b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraybuffer.js @@ -0,0 +1,18 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync doesn't special-case ArrayBuffer +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const items = new ArrayBuffer(7); + const result = await Array.fromAsync(items); + assert.compareArray(result, []); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-holes.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-holes.js new file mode 100644 index 0000000000..5396f9015b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-holes.js @@ -0,0 +1,25 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Array-like object with holes treats the holes as undefined +info: | + 3.k.vii.2. Let _kValue_ be ? Get(_arrayLike_, _Pk_). +features: [Array.fromAsync] +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +---*/ + +asyncTest(async function () { + const arrayLike = Object.create(null); + arrayLike.length = 5; + arrayLike[0] = 0; + arrayLike[1] = 1; + arrayLike[2] = 2; + arrayLike[4] = 4; + + const array = await Array.fromAsync(arrayLike); + assert.compareArray(array, [0, 1, 2, undefined, 4], "holes in array-like treated as undefined"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-length-accessor-throws.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-length-accessor-throws.js new file mode 100644 index 0000000000..81932ec791 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-length-accessor-throws.js @@ -0,0 +1,26 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Rejects on array-like object whose length cannot be gotten +info: | + 3.k.iii. Let _len_ be ? LengthOfArrayLike(_arrayLike_). +features: [Array.fromAsync] +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + await assert.throwsAsync(Test262Error, () => Array.fromAsync({ + get length() { + throw new Test262Error('accessing length property fails'); + } + }), "Promise should be rejected if array-like length getter throws"); + + await assert.throwsAsync(TypeError, () => Array.fromAsync({ + length: 1n, + 0: 0 + }), "Promise should be rejected if array-like length can't be converted to a number"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-promise.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-promise.js new file mode 100644 index 0000000000..141ce7f08c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-promise.js @@ -0,0 +1,32 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync tries the various properties in order and awaits promises +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const actual = []; + const items = TemporalHelpers.propertyBagObserver(actual, { + length: 2, + 0: Promise.resolve(2), + 1: Promise.resolve(1), + }, "items"); + const result = await Array.fromAsync(items); + assert.compareArray(result, [2, 1]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + "get items[Symbol.iterator]", + "get items.length", + "get items.length.valueOf", + "call items.length.valueOf", + "get items[0]", + "get items[1]", + ]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-too-long.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-too-long.js new file mode 100644 index 0000000000..c634be42ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-too-long.js @@ -0,0 +1,32 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Promise is rejected if the length of the array-like to copy is out of range +info: | + j. If _iteratorRecord_ is not *undefined*, then + ... + k. Else, + ... + iv. If IsConstructor(_C_) is *true*, then + ... + v. Else, + 1. Let _A_ be ? ArrayCreate(_len_). + + ArrayCreate, step 1: + 1. If _length_ > 2³² - 1, throw a *RangeError* exception. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const notConstructor = {}; + + await assert.throwsAsync(RangeError, () => Array.fromAsync.call(notConstructor, { + length: 4294967296 // 2³² + }), "Array-like with excessive length"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-exists.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-exists.js new file mode 100644 index 0000000000..7f4511990d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-exists.js @@ -0,0 +1,33 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync tries the various properties in order +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + async function * asyncGen() { + for (let i = 0; i < 4; i++) { + yield Promise.resolve(i * 2); + } + } + + const actual = []; + const items = {}; + TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, asyncGen, "items"); + TemporalHelpers.observeProperty(actual, items, Symbol.iterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, "length", 2, "items"); + TemporalHelpers.observeProperty(actual, items, 0, 2, "items"); + TemporalHelpers.observeProperty(actual, items, 1, 1, "items"); + const result = await Array.fromAsync(items); + assert.compareArray(result, [0, 2, 4, 6]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + ]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-not-callable.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-not-callable.js new file mode 100644 index 0000000000..f9406f5a29 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-not-callable.js @@ -0,0 +1,20 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync rejects if the @@asyncIterator property is not callable +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + for (const v of [true, "", Symbol(), 1, 1n, {}]) { + await assert.throwsAsync(TypeError, + () => Array.fromAsync({ [Symbol.asyncIterator]: v }), + `@@asyncIterator = ${typeof v}`); + } +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-null.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-null.js new file mode 100644 index 0000000000..3375e3a1de --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-null.js @@ -0,0 +1,31 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync tries the various properties in order +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const actual = []; + const items = {}; + TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, null, "items"); + TemporalHelpers.observeProperty(actual, items, Symbol.iterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, "length", 2, "items"); + TemporalHelpers.observeProperty(actual, items, 0, 2, "items"); + TemporalHelpers.observeProperty(actual, items, 1, 1, "items"); + const result = await Array.fromAsync(items); + assert.compareArray(result, [2, 1]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + "get items[Symbol.iterator]", + "get items.length", + "get items[0]", + "get items[1]", + ]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-sync.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-sync.js new file mode 100644 index 0000000000..90fd4e607b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-sync.js @@ -0,0 +1,33 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync handles a sync iterator returned from @@asyncIterator +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + function * syncGen() { + for (let i = 0; i < 4; i++) { + yield i * 2; + } + } + + const actual = []; + const items = {}; + TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, syncGen, "items"); + TemporalHelpers.observeProperty(actual, items, Symbol.iterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, "length", 2, "items"); + TemporalHelpers.observeProperty(actual, items, 0, 2, "items"); + TemporalHelpers.observeProperty(actual, items, 1, 1, "items"); + const result = await Array.fromAsync(items); + assert.compareArray(result, [0, 2, 4, 6]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + ]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-throws.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-throws.js new file mode 100644 index 0000000000..22c78f236a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-asynciterator-throws.js @@ -0,0 +1,17 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync rejects if getting the @@asyncIterator property throws +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + await assert.throwsAsync(Test262Error, + () => Array.fromAsync({ get [Symbol.asyncIterator]() { throw new Test262Error() } })); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-bigint.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-bigint.js new file mode 100644 index 0000000000..307b8da877 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-bigint.js @@ -0,0 +1,21 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync treats a BigInt as an array-like +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + BigInt.prototype.length = 2; + BigInt.prototype[0] = 1; + BigInt.prototype[1] = 2; + + const result = await Array.fromAsync(1n); + assert.compareArray(result, [1, 2]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-boolean.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-boolean.js new file mode 100644 index 0000000000..62042774f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-boolean.js @@ -0,0 +1,21 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync treats a boolean as an array-like +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + Boolean.prototype.length = 2; + Boolean.prototype[0] = 1; + Boolean.prototype[1] = 2; + + const result = await Array.fromAsync(true); + assert.compareArray(result, [1, 2]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-function.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-function.js new file mode 100644 index 0000000000..80facef636 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-function.js @@ -0,0 +1,22 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync treats a function as an array-like, reading elements up to fn.length +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const fn = function(a, b) {}; + fn[0] = 1; + fn[1] = 2; + fn[2] = 3; + + const result = await Array.fromAsync(fn); + assert.compareArray(result, [1, 2]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-exists.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-exists.js new file mode 100644 index 0000000000..b964229285 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-exists.js @@ -0,0 +1,34 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync handles a sync iterator returned from @@iterator +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + function * syncGen() { + for (let i = 0; i < 4; i++) { + yield i * 2; + } + } + + const actual = []; + const items = {}; + TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, Symbol.iterator, syncGen, "items"); + TemporalHelpers.observeProperty(actual, items, "length", 2, "items"); + TemporalHelpers.observeProperty(actual, items, 0, 2, "items"); + TemporalHelpers.observeProperty(actual, items, 1, 1, "items"); + const result = await Array.fromAsync(items); + assert.compareArray(result, [0, 2, 4, 6]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + "get items[Symbol.iterator]", + ]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-not-callable.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-not-callable.js new file mode 100644 index 0000000000..d672bba1dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-not-callable.js @@ -0,0 +1,20 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync rejects if the @@iterator property is not callable +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + for (const v of [true, "", Symbol(), 1, 1n, {}]) { + await assert.throwsAsync(TypeError, + () => Array.fromAsync({ [Symbol.iterator]: v }), + `@@iterator = ${typeof v}`); + } +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-null.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-null.js new file mode 100644 index 0000000000..9a8b071d02 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-null.js @@ -0,0 +1,31 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync tries the various properties in order +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const actual = []; + const items = {}; + TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, Symbol.iterator, null, "items"); + TemporalHelpers.observeProperty(actual, items, "length", 2, "items"); + TemporalHelpers.observeProperty(actual, items, 0, 2, "items"); + TemporalHelpers.observeProperty(actual, items, 1, 1, "items"); + const result = await Array.fromAsync(items); + assert.compareArray(result, [2, 1]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + "get items[Symbol.iterator]", + "get items.length", + "get items[0]", + "get items[1]", + ]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-promise.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-promise.js new file mode 100644 index 0000000000..b99e5af4cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-promise.js @@ -0,0 +1,34 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync handles an async iterator returned from @@iterator +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + function * asyncGen() { + for (let i = 0; i < 4; i++) { + yield Promise.resolve(i * 2); + } + } + + const actual = []; + const items = {}; + TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, Symbol.iterator, asyncGen, "items"); + TemporalHelpers.observeProperty(actual, items, "length", 2, "items"); + TemporalHelpers.observeProperty(actual, items, 0, 2, "items"); + TemporalHelpers.observeProperty(actual, items, 1, 1, "items"); + const result = await Array.fromAsync(items); + assert.compareArray(result, [0, 2, 4, 6]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + "get items[Symbol.iterator]", + ]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-throws.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-throws.js new file mode 100644 index 0000000000..148c3d9dfe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-iterator-throws.js @@ -0,0 +1,17 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync rejects if getting the @@iterator property throws +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + await assert.throwsAsync(Test262Error, + () => Array.fromAsync({ get [Symbol.iterator]() { throw new Test262Error() } })); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-null-undefined.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-null-undefined.js new file mode 100644 index 0000000000..e78c18f199 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-null-undefined.js @@ -0,0 +1,19 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync rejects with a TypeError if the asyncItems argument is null or undefined +info: | + 3.c. Let usingAsyncIterator be ? GetMethod(asyncItems, @@asyncIterator). +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + await assert.throwsAsync(TypeError, () => Array.fromAsync(null), "null asyncItems"); + await assert.throwsAsync(TypeError, () => Array.fromAsync(undefined), "undefined asyncItems"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-number.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-number.js new file mode 100644 index 0000000000..2dd8ace8e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-number.js @@ -0,0 +1,21 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync treats a Number as an array-like +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + Number.prototype.length = 2; + Number.prototype[0] = 1; + Number.prototype[1] = 2; + + const result = await Array.fromAsync(1); + assert.compareArray(result, [1, 2]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-object-not-arraylike.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-object-not-arraylike.js new file mode 100644 index 0000000000..62f3dd27b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-object-not-arraylike.js @@ -0,0 +1,24 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Treats an asyncItems object that isn't an array-like as a 0-length array-like +info: | + 3.k.iii. Let _len_ be ? LengthOfArrayLike(_arrayLike_). +features: [Array.fromAsync] +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +---*/ + +asyncTest(async function () { + const notArrayLike = Object.create(null); + notArrayLike[0] = 0; + notArrayLike[1] = 1; + notArrayLike[2] = 2; + + const array = await Array.fromAsync(notArrayLike); + assert.compareArray(array, [], "non-array-like object is treated as 0-length array-like"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-operations.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-operations.js new file mode 100644 index 0000000000..89b854e164 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-operations.js @@ -0,0 +1,31 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync tries the various properties in order +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const actual = []; + const items = {}; + TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, Symbol.iterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, "length", 2, "items"); + TemporalHelpers.observeProperty(actual, items, 0, 2, "items"); + TemporalHelpers.observeProperty(actual, items, 1, 1, "items"); + const result = await Array.fromAsync(items); + assert.compareArray(result, [2, 1]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + "get items[Symbol.iterator]", + "get items.length", + "get items[0]", + "get items[1]", + ]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-string.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-string.js new file mode 100644 index 0000000000..d12cfb5453 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-string.js @@ -0,0 +1,17 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync iterates over a string +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const result = await Array.fromAsync("test"); + assert.compareArray(result, ["t", "e", "s", "t"]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-symbol.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-symbol.js new file mode 100644 index 0000000000..335a1d1325 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-symbol.js @@ -0,0 +1,21 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync treats a Symbol as an array-like +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + Symbol.prototype.length = 2; + Symbol.prototype[0] = 1; + Symbol.prototype[1] = 2; + + const result = await Array.fromAsync(Symbol()); + assert.compareArray(result, [1, 2]); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-uses-intrinsic-iterator-symbols.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-uses-intrinsic-iterator-symbols.js new file mode 100644 index 0000000000..f0e76c4ae0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-uses-intrinsic-iterator-symbols.js @@ -0,0 +1,41 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Use the intrinsic @@iterator and @@asyncIterator to check iterability +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + // Replace the user-reachable Symbol.iterator and Symbol.asyncIterator with + // fake symbol keys + const originalSymbol = globalThis.Symbol; + const fakeIteratorSymbol = Symbol("iterator"); + const fakeAsyncIteratorSymbol = Symbol("asyncIterator"); + globalThis.Symbol = { + iterator: fakeIteratorSymbol, + asyncIterator: fakeAsyncIteratorSymbol, + }; + + const input = { + length: 3, + 0: 0, + 1: 1, + 2: 2, + [fakeIteratorSymbol]() { + throw new Test262Error("The fake Symbol.iterator method should not be called"); + }, + [fakeAsyncIteratorSymbol]() { + throw new Test262Error("The fake Symbol.asyncIterator method should not be called"); + } + }; + const output = await Array.fromAsync(input); + assert.compareArray(output, [0, 1, 2]); + + globalThis.Symbol = originalSymbol; +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/browser.js b/js/src/tests/test262/built-ins/Array/fromAsync/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/builtin.js b/js/src/tests/test262/built-ins/Array/fromAsync/builtin.js new file mode 100644 index 0000000000..79af2825bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/builtin.js @@ -0,0 +1,38 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Array.fromAsync meets the requirements for built-in objects +info: | + Unless specified otherwise, a built-in object that is callable as a function + is a built-in function object with the characteristics described in 10.3. + Unless specified otherwise, the [[Extensible]] internal slot of a built-in + object initially has the value *true*. + + Unless otherwise specified every built-in function and every built-in + constructor has the Function prototype object, which is the initial value of + the expression Function.prototype (20.2.3), as the value of its [[Prototype]] + internal slot. + + Built-in functions that are not constructors do not have a "prototype" + property unless otherwise specified in the description of a particular + function. +features: [Array.fromAsync] +---*/ + +assert(Object.isExtensible(Array.fromAsync), "Array.fromAsync is extensible"); + +assert.sameValue( + Object.getPrototypeOf(Array.fromAsync), + Function.prototype, + "Prototype of Array.fromAsync is Function.prototype" +); + +assert.sameValue( + Object.getOwnPropertyDescriptor(Array.fromAsync, "prototype"), + undefined, + "Array.fromAsync has no own prototype property" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/length.js b/js/src/tests/test262/built-ins/Array/fromAsync/length.js new file mode 100644 index 0000000000..949b749304 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/length.js @@ -0,0 +1,28 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Value and property descriptor of Array.fromAsync.length +info: | + Every built-in function object, including constructors, has a *"length"* + property whose value is a non-negative integral Number. Unless otherwise + specified, this value is equal to the number of required parameters shown in + the subclause heading for the function description. Optional parameters and + rest parameters are not included in the parameter 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: [Array.fromAsync] +---*/ + +verifyProperty(Array.fromAsync, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-arraylike.js b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-arraylike.js new file mode 100644 index 0000000000..5b6ddf60b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-arraylike.js @@ -0,0 +1,36 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + An asynchronous mapping function is applied to each (awaited) item of an + arraylike. +info: | + 3.k.vii.4. If _mapping_ is *true*, then + a. Let _mappedValue_ be ? Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + b. Let _mappedValue_ be ? Await(_mappedValue_). + ... + 6. Perform ? CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +features: [Array.fromAsync] +---*/ + +const arrayLike = { + length: 4, + 0: 0, + 1: 2, + 2: Promise.resolve(4), + 3: 6, +}; + +async function asyncMap(val, ix) { + return Promise.resolve(val * ix); +} + +asyncTest(async () => { + const result = await Array.fromAsync(arrayLike, asyncMap); + assert.compareArray(result, [0, 2, 8, 18], "async mapfn should be applied to arraylike"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-iterable-async.js b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-iterable-async.js new file mode 100644 index 0000000000..c7b01e8aa5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-iterable-async.js @@ -0,0 +1,36 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + An asynchronous mapping function is applied to each item yielded by an + asynchronous iterable. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + ... + c. Set _mappedValue_ to Await(_mappedValue_). + ... + ... + 8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +features: [Array.fromAsync] +---*/ + +async function* asyncGen() { + for (let i = 0; i < 4; i++) { + yield Promise.resolve(i * 2); + } +} + +async function asyncMap(val, ix) { + return Promise.resolve(val * ix); +} + +asyncTest(async () => { + const result = await Array.fromAsync({ [Symbol.asyncIterator]: asyncGen }, asyncMap); + assert.compareArray(result, [0, 2, 8, 18], "async mapfn should be applied to async iterable"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-iterable-sync.js b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-iterable-sync.js new file mode 100644 index 0000000000..ded2dfd367 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-iterable-sync.js @@ -0,0 +1,36 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + An asynchronous mapping function is applied to each item yielded by a + synchronous iterable. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + ... + c. Set _mappedValue_ to Await(_mappedValue_). + ... + ... + 8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +features: [Array.fromAsync] +---*/ + +function* syncGen() { + for (let i = 0; i < 4; i++) { + yield i * 2; + } +} + +async function asyncMap(val, ix) { + return Promise.resolve(val * ix); +} + +asyncTest(async () => { + const result = await Array.fromAsync({ [Symbol.iterator]: syncGen }, asyncMap); + assert.compareArray(result, [0, 2, 8, 18], "async mapfn should be applied to sync iterable"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-throws-close-async-iterator.js b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-throws-close-async-iterator.js new file mode 100644 index 0000000000..e2072a1e39 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-throws-close-async-iterator.js @@ -0,0 +1,41 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + The iterator of an asynchronous iterable is closed when the asynchronous + mapping function throws. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + ... + c. Set _mappedValue_ to Await(_mappedValue_). + d. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_). +flags: [async] +includes: [asyncHelpers.js] +features: [Array.fromAsync] +---*/ + +let closed = false; +const iterator = { + next() { + return Promise.resolve({ value: 1, done: false }); + }, + return() { + closed = true; + return Promise.resolve({ done: true }); + }, + [Symbol.asyncIterator]() { + return this; + } +} + +asyncTest(async () => { + await assert.throwsAsync(Error, () => Array.fromAsync(iterator, async (val) => { + assert.sameValue(val, 1, "mapfn receives value from iterator"); + throw new Error("mapfn throws"); + }), "async mapfn rejecting should cause fromAsync to reject"); + assert(closed, "async mapfn rejecting should close iterator") +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-throws-close-sync-iterator.js b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-throws-close-sync-iterator.js new file mode 100644 index 0000000000..7a9480a698 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-throws-close-sync-iterator.js @@ -0,0 +1,41 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + The iterator of a synchronous iterable is closed when the asynchronous mapping + function throws. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + ... + c. Set _mappedValue_ to Await(_mappedValue_). + d. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_). +flags: [async] +includes: [asyncHelpers.js] +features: [Array.fromAsync] +---*/ + +let closed = false; +const iterator = { + next() { + return { value: 1, done: false }; + }, + return() { + closed = true; + return { done: true }; + }, + [Symbol.iterator]() { + return this; + } +} + +asyncTest(async () => { + await assert.throwsAsync(Error, () => Array.fromAsync(iterator, async (val) => { + assert.sameValue(val, 1, "mapfn receives value from iterator"); + throw new Error("mapfn throws"); + }), "async mapfn rejecting should cause fromAsync to reject"); + assert(closed, "async mapfn rejecting should close iterator") +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-throws.js b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-throws.js new file mode 100644 index 0000000000..663e2c9338 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-throws.js @@ -0,0 +1,24 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + The output promise rejects if the asynchronous mapping function rejects. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + ... + c. Set _mappedValue_ to Await(_mappedValue_). + d. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_). +flags: [async] +includes: [asyncHelpers.js] +features: [Array.fromAsync] +---*/ + +asyncTest(async () => { + await assert.throwsAsync(Test262Error, () => Array.fromAsync([1, 2, 3], async () => { + throw new Test262Error("mapfn throws"); + }), "async mapfn rejecting should cause fromAsync to reject"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-not-callable.js b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-not-callable.js new file mode 100644 index 0000000000..7f6e901f1c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-not-callable.js @@ -0,0 +1,26 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + A TypeError is thrown if the mapfn argument to Array.fromAsync is not callable +info: | + 3.a. If _mapfn_ is *undefined*, let _mapping_ be *false*. + b. Else, + i. If IsCallable(_mapfn_) is *false*, throw a *TypeError* exception. +flags: [async] +includes: [asyncHelpers.js] +features: [Array.fromAsync, BigInt, Symbol] +---*/ + +asyncTest(async () => { + await assert.throwsAsync(TypeError, () => Array.fromAsync([], null), "null mapfn"); + await assert.throwsAsync(TypeError, () => Array.fromAsync([], {}), "non-callable object mapfn"); + await assert.throwsAsync(TypeError, () => Array.fromAsync([], "String"), "string mapfn"); + await assert.throwsAsync(TypeError, () => Array.fromAsync([], true), "boolean mapfn"); + await assert.throwsAsync(TypeError, () => Array.fromAsync([], 3.1416), "number mapfn"); + await assert.throwsAsync(TypeError, () => Array.fromAsync([], 42n), "bigint mapfn"); + await assert.throwsAsync(TypeError, () => Array.fromAsync([], Symbol()), "symbol mapfn"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-result-awaited-once-per-iteration.js b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-result-awaited-once-per-iteration.js new file mode 100644 index 0000000000..c7d9a0a901 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-result-awaited-once-per-iteration.js @@ -0,0 +1,48 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + The returned value from each invocation of the asynchronous mapping function + is awaited exactly once. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + ... + c. Set _mappedValue_ to Await(_mappedValue_). +flags: [async] +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +features: [Array.fromAsync] +---*/ + +const calls = []; +const expected = [ + "call mapping", + "get thenable_0.then", + "call thenable_0.then", + "call mapping", + "get thenable_1.then", + "call thenable_1.then", + "call mapping", + "get thenable_2.then", + "call thenable_2.then", +]; + +function mapping(val, ix) { + calls.push("call mapping"); + const thenableName = `thenable_${ix}`; + return TemporalHelpers.propertyBagObserver(calls, { + then(resolve, reject) { + calls.push(`call ${thenableName}.then`); + resolve(val * 2); + } + }, thenableName) +} + +asyncTest(async () => { + const result = await Array.fromAsync([1, 2, 3], mapping); + assert.compareArray(result, [2, 4, 6], "mapping function applied"); + assert.compareArray(calls, expected, "observable operations"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-arraylike.js b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-arraylike.js new file mode 100644 index 0000000000..3d033f97f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-arraylike.js @@ -0,0 +1,36 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + A synchronous mapping function is applied to each (awaited) item of an + arraylike. +info: | + 3.k.vii.4. If _mapping_ is *true*, then + a. Let _mappedValue_ be ? Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + ... + ... + 6. Perform ? CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +features: [Array.fromAsync] +---*/ + +const arrayLike = { + length: 4, + 0: 0, + 1: 2, + 2: Promise.resolve(4), + 3: 6, +}; + +function syncMap(val, ix) { + return val * ix; +} + +asyncTest(async () => { + const result = await Array.fromAsync(arrayLike, syncMap); + assert.compareArray(result, [0, 2, 8, 18], "sync mapfn should be applied to arraylike"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-iterable-async.js b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-iterable-async.js new file mode 100644 index 0000000000..c790fedc82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-iterable-async.js @@ -0,0 +1,34 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + A synchronous mapping function is applied to each item yielded by an + asynchronous iterable. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + ... + ... + 8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +features: [Array.fromAsync] +---*/ + +async function* asyncGen() { + for (let i = 0; i < 4; i++) { + yield Promise.resolve(i * 2); + } +} + +function syncMap(val, ix) { + return val * ix; +} + +asyncTest(async () => { + const result = await Array.fromAsync({ [Symbol.asyncIterator]: asyncGen }, syncMap); + assert.compareArray(result, [0, 2, 8, 18], "sync mapfn should be applied to async iterable"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-iterable-sync.js b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-iterable-sync.js new file mode 100644 index 0000000000..97d7fe89c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-iterable-sync.js @@ -0,0 +1,34 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + A synchronous mapping function is applied to each item yielded by a + synchronous iterable. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + ... + ... + 8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +features: [Array.fromAsync] +---*/ + +function* syncGen() { + for (let i = 0; i < 4; i++) { + yield i * 2; + } +} + +function syncMap(val, ix) { + return val * ix; +} + +asyncTest(async () => { + const result = await Array.fromAsync({ [Symbol.iterator]: syncGen }, syncMap); + assert.compareArray(result, [0, 2, 8, 18], "sync mapfn should be applied to sync iterable"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-throws-close-async-iterator.js b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-throws-close-async-iterator.js new file mode 100644 index 0000000000..a351445f1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-throws-close-async-iterator.js @@ -0,0 +1,40 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + The iterator of an asynchronous iterable is closed when the synchronous + mapping function throws. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + b. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_). + ... +flags: [async] +includes: [asyncHelpers.js] +features: [Array.fromAsync] +---*/ + +let closed = false; +const iterator = { + next() { + return Promise.resolve({ value: 1, done: false }); + }, + return() { + closed = true; + return Promise.resolve({ done: true }); + }, + [Symbol.asyncIterator]() { + return this; + } +} + +asyncTest(async () => { + await assert.throwsAsync(Error, () => Array.fromAsync(iterator, (val) => { + assert.sameValue(val, 1, "mapfn receives value from iterator"); + throw new Error("mapfn throws"); + }), "sync mapfn throwing should cause fromAsync to reject"); + assert(closed, "sync mapfn throwing should close iterator") +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-throws-close-sync-iterator.js b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-throws-close-sync-iterator.js new file mode 100644 index 0000000000..3ea9e73e6d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-throws-close-sync-iterator.js @@ -0,0 +1,40 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + The iterator of a synchronous iterable is closed when the synchronous mapping + function throws. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + b. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_). + ... +flags: [async] +includes: [asyncHelpers.js] +features: [Array.fromAsync] +---*/ + +let closed = false; +const iterator = { + next() { + return { value: 1, done: false }; + }, + return() { + closed = true; + return { done: true }; + }, + [Symbol.iterator]() { + return this; + } +} + +asyncTest(async () => { + await assert.throwsAsync(Error, () => Array.fromAsync(iterator, (val) => { + assert.sameValue(val, 1, "mapfn receives value from iterator"); + throw new Error("mapfn throws"); + }), "sync mapfn throwing should cause fromAsync to reject"); + assert(closed, "sync mapfn throwing should close iterator") +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-throws.js b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-throws.js new file mode 100644 index 0000000000..cea2ff3a60 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-throws.js @@ -0,0 +1,23 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + The output promise rejects if the synchronous mapping function throws. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + b. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_). + ... +flags: [async] +includes: [asyncHelpers.js] +features: [Array.fromAsync] +---*/ + +asyncTest(async () => { + await assert.throwsAsync(Test262Error, () => Array.fromAsync([1, 2, 3], () => { + throw new Test262Error("mapfn throws"); + }), "sync mapfn throwing should cause fromAsync to reject"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/name.js b/js/src/tests/test262/built-ins/Array/fromAsync/name.js new file mode 100644 index 0000000000..e335122192 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Value and property descriptor of Array.fromAsync.name +info: | + Every built-in function object, including constructors, has a *"name"* + property whose value is a String. Unless otherwise specified, this value is + the name that is given to the function in this specification. [...] + For functions that are specified as properties of objects, the name value is + the property name string used to access the function. + + Unless otherwise specified, the *"name"* property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Array.fromAsync] +---*/ + +verifyProperty(Array.fromAsync, "name", { + value: "fromAsync", + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-does-not-use-array-prototype.js b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-does-not-use-array-prototype.js new file mode 100644 index 0000000000..ba639aae1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-does-not-use-array-prototype.js @@ -0,0 +1,47 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Non-iterable input does not use Array.prototype +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { +const arrayIterator = [].values(); +const IntrinsicArrayIteratorPrototype = +Object.getPrototypeOf(arrayIterator); +const intrinsicArrayIteratorPrototypeNext = +IntrinsicArrayIteratorPrototype.next; + +try { +// Temporarily mutate the array iterator prototype to have an invalid +// “next” method. Just like Array.from, the fromAsync function should +// still work on non-iterable arraylike arguments. +IntrinsicArrayIteratorPrototype.next = function fakeNext () { + throw new Test262Error( + 'This fake next function should not be called; ' + + 'instead, each element should have been directly accessed.', + ); +}; + +const expected = [ 0, 1, 2 ]; +const input = { + length: 3, + 0: 0, + 1: 1, + 2: 2, +}; +const output = await Array.fromAsync(input); +assert.compareArray(output, expected); +} + +finally { +// Reset the intrinsic array iterator +IntrinsicArrayIteratorPrototype.next = + intrinsicArrayIteratorPrototypeNext; +} +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-element-access-err.js b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-element-access-err.js new file mode 100644 index 0000000000..edbf4de710 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-element-access-err.js @@ -0,0 +1,22 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Result promise rejects if element access fails +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const input = { + length: 1, + get 0 () { + throw new Test262Error; + }, + }; + const outputPromise = Array.fromAsync(input); + assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-awaits-callback-result-once.js b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-awaits-callback-result-once.js new file mode 100644 index 0000000000..9bb78973a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-awaits-callback-result-once.js @@ -0,0 +1,33 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Non-iterable input with thenable result with async mapped awaits each callback result once. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + let awaitCounter = 0; + const input = { + length: 3, + 0: 0, + 1: Promise.resolve(1), + 2: Promise.resolve(2), + 3: Promise.resolve(3), // This is ignored because the length is 3. + }; + await Array.fromAsync(input, async v => { + return { + // This “then” method should occur three times: + // one for each value from the input. + then (resolve, reject) { + awaitCounter ++; + resolve(v); + }, + }; + }); + assert.sameValue(awaitCounter, 3); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-callback-err.js b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-callback-err.js new file mode 100644 index 0000000000..edc811b792 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-callback-err.js @@ -0,0 +1,28 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Non-iterable input with thenable result promise rejects if async map function callback throws. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + const inputThenable = { + then (resolve, reject) { + resolve(expectedValue); + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + const outputPromise = Array.fromAsync(input, async v => { + throw new Test262Error; + }); + assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-element-rejects.js b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-element-rejects.js new file mode 100644 index 0000000000..f7b63c219e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-element-rejects.js @@ -0,0 +1,27 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Non-iterable input with thenable result promise rejects if thenable element rejects. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + const expected = [ expectedValue ]; + const inputThenable = { + then (resolve, reject) { + reject(new Test262Error); + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + const output = Array.fromAsync(input); + await assert.throwsAsync(Test262Error, () => output); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-sync-mapped-callback-err.js b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-sync-mapped-callback-err.js new file mode 100644 index 0000000000..c1543fe582 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable-sync-mapped-callback-err.js @@ -0,0 +1,22 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Non iterable result promise rejects if sync map function callback throws. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const input = { + length: 1, + 0: 0, + }; + const outputPromise = Array.fromAsync(input, v => { + throw new Test262Error; + }); + assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable.js b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable.js new file mode 100644 index 0000000000..f37f8d01f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input-with-thenable.js @@ -0,0 +1,25 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Non iterable input with thenables is transferred to the output array. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expected = [ 0, 1, 2 ]; + const input = { + length: 3, + 0: 0, + 1: Promise.resolve(1), + 2: Promise.resolve(2), + 3: Promise.resolve(3), // This is ignored because the length is 3. + }; + const output = await Array.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input.js b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input.js new file mode 100644 index 0000000000..3e0fd5994f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-input.js @@ -0,0 +1,25 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Non iterable input without thenables is transferred to the output array. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expected = [ 0, 1, 2 ]; + const input = { + length: 3, + 0: 0, + 1: 1, + 2: 2, + 3: 3, // This is ignored because the length is 3. + }; + const output = await Array.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-sync-mapped-callback-err.js b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-sync-mapped-callback-err.js new file mode 100644 index 0000000000..72f48cce56 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-sync-mapped-callback-err.js @@ -0,0 +1,28 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Non iterable input with thenables awaits each input once without mapping callback +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + const inputThenable = { + then (resolve, reject) { + resolve(expectedValue); + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + const outputPromise = Array.fromAsync(input, v => { + throw new Test262Error; + }); + await assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-non-promise-thenable.js b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-non-promise-thenable.js new file mode 100644 index 0000000000..89388e2790 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-non-promise-thenable.js @@ -0,0 +1,27 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Non iterable input with non-promise thenables works. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + const expected = [ expectedValue ]; + const inputThenable = { + then (resolve, reject) { + resolve(expectedValue); + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + const output = await Array.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-async-mapped-awaits-once.js b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-async-mapped-awaits-once.js new file mode 100644 index 0000000000..080a9e6300 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-async-mapped-awaits-once.js @@ -0,0 +1,30 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Non-iterable input with thenables awaits each input once without mapping callback +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + const expected = [ expectedValue ]; + let awaitCounter = 0; + const inputThenable = { + then (resolve, reject) { + awaitCounter++; + resolve(expectedValue); + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + await Array.fromAsync(input, async v => v); + assert.sameValue(awaitCounter, 1); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-awaits-once.js b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-awaits-once.js new file mode 100644 index 0000000000..89dbdc5c86 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-awaits-once.js @@ -0,0 +1,28 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Non-iterable with thenables awaits each input value once without mapping callback. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + let awaitCounter = 0; + const inputThenable = { + then (resolve, reject) { + awaitCounter ++; + resolve(expectedValue); + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + await Array.fromAsync(input); + assert.sameValue(awaitCounter, 1); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-sync-mapped-awaits-once.js b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-sync-mapped-awaits-once.js new file mode 100644 index 0000000000..a410783234 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-sync-mapped-awaits-once.js @@ -0,0 +1,29 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Non-iterable input with thenables awaits each input once with mapping callback +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + let awaitCounter = 0; + const inputThenable = { + then (resolve, reject) { + awaitCounter++; + resolve(expectedValue); + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + await Array.fromAsync(input, v => v); + assert.sameValue(awaitCounter, 1); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-then-method-err.js b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-then-method-err.js new file mode 100644 index 0000000000..4175c353f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-then-method-err.js @@ -0,0 +1,25 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Non-iterable input with thenable result promise is rejected if element's then method throws. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const inputThenable = { + then (resolve, reject) { + throw new Test262Error; + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + const outputPromise = Array.fromAsync(input); + assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/fromAsync/not-a-constructor.js new file mode 100644 index 0000000000..428ea909e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/not-a-constructor.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Array.fromAsync is not a constructor +info: | + 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. +includes: [isConstructor.js] +features: [Array.fromAsync, Reflect.construct] +---*/ + +assert(!isConstructor(Array.fromAsync), "Array.fromAsync is not a constructor"); + +assert.throws(TypeError, () => new Array.fromAsync(), "Array.fromAsync throws when constructed"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/prop-desc.js b/js/src/tests/test262/built-ins/Array/fromAsync/prop-desc.js new file mode 100644 index 0000000000..803cc989dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Type and property descriptor of Array.fromAsync +info: | + Every other data property described in clauses 19 through 28 and in Annex B.2 + has the attributes { [[Writable]]: *true*, [[Enumerable]]: *false*, + [[Configurable]]: *true* } unless otherwise specified. +includes: [propertyHelper.js] +features: [Array.fromAsync] +---*/ + +assert.sameValue(typeof Array.fromAsync, "function", "Array.fromAsync is callable"); + +verifyProperty(Array, 'fromAsync', { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/returned-promise-resolves-to-array.js b/js/src/tests/test262/built-ins/Array/fromAsync/returned-promise-resolves-to-array.js new file mode 100644 index 0000000000..b6ccf790af --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/returned-promise-resolves-to-array.js @@ -0,0 +1,23 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync returns a Promise that resolves to an Array in the normal case +info: | + 1. Let _C_ be the *this* value. + ... + 3.e. If IsConstructor(_C_) is *true*, then + i. Let _A_ be ? Construct(_C_). +features: [Array.fromAsync] +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + const promise = Array.fromAsync([0, 1, 2]); + const array = await promise; + assert(Array.isArray(array), "Array.fromAsync returns a Promise that resolves to an Array"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/returns-promise.js b/js/src/tests/test262/built-ins/Array/fromAsync/returns-promise.js new file mode 100644 index 0000000000..a8b456d66e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/returns-promise.js @@ -0,0 +1,36 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Array.fromAsync returns a Promise +info: | + 5. Return _promiseCapability_.[[Promise]]. +flags: [async] +includes: [asyncHelpers.js] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + let p = Array.fromAsync([0, 1, 2]); + + assert(p instanceof Promise, "Array.fromAsync returns a Promise"); + assert.sameValue( + Object.getPrototypeOf(p), + Promise.prototype, + "Array.fromAsync returns an object with prototype Promise.prototype" + ); + + p = Array.fromAsync([0, 1, 2], () => { + throw new Test262Error("this will make the Promise reject"); + }) + assert(p instanceof Promise, "Array.fromAsync returns a Promise even on error"); + assert.sameValue( + Object.getPrototypeOf(p), + Promise.prototype, + "Array.fromAsync returns an object with prototype Promise.prototype even on error" + ); + + await assert.throwsAsync(Test262Error, () => p, "Prevent unhandled rejection"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/shell.js b/js/src/tests/test262/built-ins/Array/fromAsync/shell.js new file mode 100644 index 0000000000..3489e7ef68 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/shell.js @@ -0,0 +1,2271 @@ +// GENERATED, DO NOT EDIT +// file: asyncHelpers.js +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + A collection of assertion and wrapper functions for testing asynchronous built-ins. +defines: [asyncTest] +---*/ + +function asyncTest(testFunc) { + if (!Object.hasOwn(globalThis, "$DONE")) { + throw new Test262Error("asyncTest called without async flag"); + } + if (typeof testFunc !== "function") { + $DONE(new Test262Error("asyncTest called with non-function argument")); + return; + } + try { + testFunc().then( + function () { + $DONE(); + }, + function (error) { + $DONE(error); + } + ); + } catch (syncError) { + $DONE(syncError); + } +} + +assert.throwsAsync = async function (expectedErrorConstructor, func, message) { + var innerThenable; + if (message === undefined) { + message = ""; + } else { + message += " "; + } + if (typeof func === "function") { + try { + innerThenable = func(); + if ( + innerThenable === null || + typeof innerThenable !== "object" || + typeof innerThenable.then !== "function" + ) { + message += + "Expected to obtain an inner promise that would reject with a" + + expectedErrorConstructor.name + + " but result was not a thenable"; + throw new Test262Error(message); + } + } catch (thrown) { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but an exception was thrown synchronously while obtaining the inner promise"; + throw new Test262Error(message); + } + } else { + message += + "assert.throwsAsync called with an argument that is not a function"; + throw new Test262Error(message); + } + + try { + return innerThenable.then( + function () { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but no exception was thrown at all"; + throw new Test262Error(message); + }, + function (thrown) { + var expectedName, actualName; + if (typeof thrown !== "object" || thrown === null) { + message += "Thrown value was not an object!"; + throw new Test262Error(message); + } else if (thrown.constructor !== expectedErrorConstructor) { + expectedName = expectedErrorConstructor.name; + actualName = thrown.constructor.name; + if (expectedName === actualName) { + message += + "Expected a " + + expectedName + + " but got a different error constructor with the same name"; + } else { + message += + "Expected a " + expectedName + " but got a " + actualName; + } + throw new Test262Error(message); + } + } + ); + } catch (thrown) { + if (typeof thrown !== "object" || thrown === null) { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but innerThenable synchronously threw a value that was not an object "; + } else { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but a " + + thrown.constructor.name + + " was thrown synchronously"; + } + throw new Test262Error(message); + } +}; + +// file: temporalHelpers.js +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + This defines helper objects and functions for testing Temporal. +defines: [TemporalHelpers] +features: [Symbol.species, Symbol.iterator, Temporal] +---*/ + +const ASCII_IDENTIFIER = /^[$_a-zA-Z][$_a-zA-Z0-9]*$/u; + +function formatPropertyName(propertyKey, objectName = "") { + switch (typeof propertyKey) { + case "symbol": + if (Symbol.keyFor(propertyKey) !== undefined) { + return `${objectName}[Symbol.for('${Symbol.keyFor(propertyKey)}')]`; + } else if (propertyKey.description.startsWith('Symbol.')) { + return `${objectName}[${propertyKey.description}]`; + } else { + return `${objectName}[Symbol('${propertyKey.description}')]` + } + case "string": + if (propertyKey !== String(Number(propertyKey))) { + if (ASCII_IDENTIFIER.test(propertyKey)) { + return objectName ? `${objectName}.${propertyKey}` : propertyKey; + } + return `${objectName}['${propertyKey.replace(/'/g, "\\'")}']` + } + // fall through + default: + // integer or string integer-index + return `${objectName}[${propertyKey}]`; + } +} + +const SKIP_SYMBOL = Symbol("Skip"); + +var TemporalHelpers = { + /* + * Codes and maximum lengths of months in the ISO 8601 calendar. + */ + ISOMonths: [ + { month: 1, monthCode: "M01", daysInMonth: 31 }, + { month: 2, monthCode: "M02", daysInMonth: 29 }, + { month: 3, monthCode: "M03", daysInMonth: 31 }, + { month: 4, monthCode: "M04", daysInMonth: 30 }, + { month: 5, monthCode: "M05", daysInMonth: 31 }, + { month: 6, monthCode: "M06", daysInMonth: 30 }, + { month: 7, monthCode: "M07", daysInMonth: 31 }, + { month: 8, monthCode: "M08", daysInMonth: 31 }, + { month: 9, monthCode: "M09", daysInMonth: 30 }, + { month: 10, monthCode: "M10", daysInMonth: 31 }, + { month: 11, monthCode: "M11", daysInMonth: 30 }, + { month: 12, monthCode: "M12", daysInMonth: 31 } + ], + + /* + * assertDuration(duration, years, ..., nanoseconds[, description]): + * + * Shorthand for asserting that each field of a Temporal.Duration is equal to + * an expected value. + */ + assertDuration(duration, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, description = "") { + const prefix = description ? `${description}: ` : ""; + assert(duration instanceof Temporal.Duration, `${prefix}instanceof`); + assert.sameValue(duration.years, years, `${prefix}years result:`); + assert.sameValue(duration.months, months, `${prefix}months result:`); + assert.sameValue(duration.weeks, weeks, `${prefix}weeks result:`); + assert.sameValue(duration.days, days, `${prefix}days result:`); + assert.sameValue(duration.hours, hours, `${prefix}hours result:`); + assert.sameValue(duration.minutes, minutes, `${prefix}minutes result:`); + assert.sameValue(duration.seconds, seconds, `${prefix}seconds result:`); + assert.sameValue(duration.milliseconds, milliseconds, `${prefix}milliseconds result:`); + assert.sameValue(duration.microseconds, microseconds, `${prefix}microseconds result:`); + assert.sameValue(duration.nanoseconds, nanoseconds, `${prefix}nanoseconds result`); + }, + + /* + * assertDateDuration(duration, years, months, weeks, days, [, description]): + * + * Shorthand for asserting that each date field of a Temporal.Duration is + * equal to an expected value. + */ + assertDateDuration(duration, years, months, weeks, days, description = "") { + const prefix = description ? `${description}: ` : ""; + assert(duration instanceof Temporal.Duration, `${prefix}instanceof`); + assert.sameValue(duration.years, years, `${prefix}years result:`); + assert.sameValue(duration.months, months, `${prefix}months result:`); + assert.sameValue(duration.weeks, weeks, `${prefix}weeks result:`); + assert.sameValue(duration.days, days, `${prefix}days result:`); + assert.sameValue(duration.hours, 0, `${prefix}hours result should be zero:`); + assert.sameValue(duration.minutes, 0, `${prefix}minutes result should be zero:`); + assert.sameValue(duration.seconds, 0, `${prefix}seconds result should be zero:`); + assert.sameValue(duration.milliseconds, 0, `${prefix}milliseconds result should be zero:`); + assert.sameValue(duration.microseconds, 0, `${prefix}microseconds result should be zero:`); + assert.sameValue(duration.nanoseconds, 0, `${prefix}nanoseconds result should be zero:`); + }, + + /* + * assertDurationsEqual(actual, expected[, description]): + * + * Shorthand for asserting that each field of a Temporal.Duration is equal to + * the corresponding field in another Temporal.Duration. + */ + assertDurationsEqual(actual, expected, description = "") { + const prefix = description ? `${description}: ` : ""; + assert(expected instanceof Temporal.Duration, `${prefix}expected value should be a Temporal.Duration`); + TemporalHelpers.assertDuration(actual, expected.years, expected.months, expected.weeks, expected.days, expected.hours, expected.minutes, expected.seconds, expected.milliseconds, expected.microseconds, expected.nanoseconds, description); + }, + + /* + * assertInstantsEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.Instants are of the correct type + * and equal according to their equals() methods. + */ + assertInstantsEqual(actual, expected, description = "") { + const prefix = description ? `${description}: ` : ""; + assert(expected instanceof Temporal.Instant, `${prefix}expected value should be a Temporal.Instant`); + assert(actual instanceof Temporal.Instant, `${prefix}instanceof`); + assert(actual.equals(expected), `${prefix}equals method`); + }, + + /* + * assertPlainDate(date, year, ..., nanosecond[, description[, era, eraYear]]): + * + * Shorthand for asserting that each field of a Temporal.PlainDate is equal to + * an expected value. (Except the `calendar` property, since callers may want + * to assert either object equality with an object they put in there, or the + * value of date.calendarId.) + */ + assertPlainDate(date, year, month, monthCode, day, description = "", era = undefined, eraYear = undefined) { + const prefix = description ? `${description}: ` : ""; + assert(date instanceof Temporal.PlainDate, `${prefix}instanceof`); + assert.sameValue(date.era, era, `${prefix}era result:`); + assert.sameValue(date.eraYear, eraYear, `${prefix}eraYear result:`); + assert.sameValue(date.year, year, `${prefix}year result:`); + assert.sameValue(date.month, month, `${prefix}month result:`); + assert.sameValue(date.monthCode, monthCode, `${prefix}monthCode result:`); + assert.sameValue(date.day, day, `${prefix}day result:`); + }, + + /* + * assertPlainDateTime(datetime, year, ..., nanosecond[, description[, era, eraYear]]): + * + * Shorthand for asserting that each field of a Temporal.PlainDateTime is + * equal to an expected value. (Except the `calendar` property, since callers + * may want to assert either object equality with an object they put in there, + * or the value of datetime.calendarId.) + */ + assertPlainDateTime(datetime, year, month, monthCode, day, hour, minute, second, millisecond, microsecond, nanosecond, description = "", era = undefined, eraYear = undefined) { + const prefix = description ? `${description}: ` : ""; + assert(datetime instanceof Temporal.PlainDateTime, `${prefix}instanceof`); + assert.sameValue(datetime.era, era, `${prefix}era result:`); + assert.sameValue(datetime.eraYear, eraYear, `${prefix}eraYear result:`); + assert.sameValue(datetime.year, year, `${prefix}year result:`); + assert.sameValue(datetime.month, month, `${prefix}month result:`); + assert.sameValue(datetime.monthCode, monthCode, `${prefix}monthCode result:`); + assert.sameValue(datetime.day, day, `${prefix}day result:`); + assert.sameValue(datetime.hour, hour, `${prefix}hour result:`); + assert.sameValue(datetime.minute, minute, `${prefix}minute result:`); + assert.sameValue(datetime.second, second, `${prefix}second result:`); + assert.sameValue(datetime.millisecond, millisecond, `${prefix}millisecond result:`); + assert.sameValue(datetime.microsecond, microsecond, `${prefix}microsecond result:`); + assert.sameValue(datetime.nanosecond, nanosecond, `${prefix}nanosecond result:`); + }, + + /* + * assertPlainDateTimesEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.PlainDateTimes are of the correct + * type, equal according to their equals() methods, and additionally that + * their calendar internal slots are the same value. + */ + assertPlainDateTimesEqual(actual, expected, description = "") { + const prefix = description ? `${description}: ` : ""; + assert(expected instanceof Temporal.PlainDateTime, `${prefix}expected value should be a Temporal.PlainDateTime`); + assert(actual instanceof Temporal.PlainDateTime, `${prefix}instanceof`); + assert(actual.equals(expected), `${prefix}equals method`); + assert.sameValue( + actual.getISOFields().calendar, + expected.getISOFields().calendar, + `${prefix}calendar same value:` + ); + }, + + /* + * assertPlainMonthDay(monthDay, monthCode, day[, description [, referenceISOYear]]): + * + * Shorthand for asserting that each field of a Temporal.PlainMonthDay is + * equal to an expected value. (Except the `calendar` property, since callers + * may want to assert either object equality with an object they put in there, + * or the value of monthDay.calendarId().) + */ + assertPlainMonthDay(monthDay, monthCode, day, description = "", referenceISOYear = 1972) { + const prefix = description ? `${description}: ` : ""; + assert(monthDay instanceof Temporal.PlainMonthDay, `${prefix}instanceof`); + assert.sameValue(monthDay.monthCode, monthCode, `${prefix}monthCode result:`); + assert.sameValue(monthDay.day, day, `${prefix}day result:`); + assert.sameValue(monthDay.getISOFields().isoYear, referenceISOYear, `${prefix}referenceISOYear result:`); + }, + + /* + * assertPlainTime(time, hour, ..., nanosecond[, description]): + * + * Shorthand for asserting that each field of a Temporal.PlainTime is equal to + * an expected value. + */ + assertPlainTime(time, hour, minute, second, millisecond, microsecond, nanosecond, description = "") { + const prefix = description ? `${description}: ` : ""; + assert(time instanceof Temporal.PlainTime, `${prefix}instanceof`); + assert.sameValue(time.hour, hour, `${prefix}hour result:`); + assert.sameValue(time.minute, minute, `${prefix}minute result:`); + assert.sameValue(time.second, second, `${prefix}second result:`); + assert.sameValue(time.millisecond, millisecond, `${prefix}millisecond result:`); + assert.sameValue(time.microsecond, microsecond, `${prefix}microsecond result:`); + assert.sameValue(time.nanosecond, nanosecond, `${prefix}nanosecond result:`); + }, + + /* + * assertPlainTimesEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.PlainTimes are of the correct + * type and equal according to their equals() methods. + */ + assertPlainTimesEqual(actual, expected, description = "") { + const prefix = description ? `${description}: ` : ""; + assert(expected instanceof Temporal.PlainTime, `${prefix}expected value should be a Temporal.PlainTime`); + assert(actual instanceof Temporal.PlainTime, `${prefix}instanceof`); + assert(actual.equals(expected), `${prefix}equals method`); + }, + + /* + * assertPlainYearMonth(yearMonth, year, month, monthCode[, description[, era, eraYear, referenceISODay]]): + * + * Shorthand for asserting that each field of a Temporal.PlainYearMonth is + * equal to an expected value. (Except the `calendar` property, since callers + * may want to assert either object equality with an object they put in there, + * or the value of yearMonth.calendarId.) + */ + assertPlainYearMonth(yearMonth, year, month, monthCode, description = "", era = undefined, eraYear = undefined, referenceISODay = 1) { + const prefix = description ? `${description}: ` : ""; + assert(yearMonth instanceof Temporal.PlainYearMonth, `${prefix}instanceof`); + assert.sameValue(yearMonth.era, era, `${prefix}era result:`); + assert.sameValue(yearMonth.eraYear, eraYear, `${prefix}eraYear result:`); + assert.sameValue(yearMonth.year, year, `${prefix}year result:`); + assert.sameValue(yearMonth.month, month, `${prefix}month result:`); + assert.sameValue(yearMonth.monthCode, monthCode, `${prefix}monthCode result:`); + assert.sameValue(yearMonth.getISOFields().isoDay, referenceISODay, `${prefix}referenceISODay result:`); + }, + + /* + * assertZonedDateTimesEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.ZonedDateTimes are of the correct + * type, equal according to their equals() methods, and additionally that + * their time zones and calendar internal slots are the same value. + */ + assertZonedDateTimesEqual(actual, expected, description = "") { + const prefix = description ? `${description}: ` : ""; + assert(expected instanceof Temporal.ZonedDateTime, `${prefix}expected value should be a Temporal.ZonedDateTime`); + assert(actual instanceof Temporal.ZonedDateTime, `${prefix}instanceof`); + assert(actual.equals(expected), `${prefix}equals method`); + assert.sameValue(actual.timeZone, expected.timeZone, `${prefix}time zone same value:`); + assert.sameValue( + actual.getISOFields().calendar, + expected.getISOFields().calendar, + `${prefix}calendar same value:` + ); + }, + + /* + * assertUnreachable(description): + * + * Helper for asserting that code is not executed. This is useful for + * assertions that methods of user calendars and time zones are not called. + */ + assertUnreachable(description) { + let message = "This code should not be executed"; + if (description) { + message = `${message}: ${description}`; + } + throw new Test262Error(message); + }, + + /* + * checkCalendarDateUntilLargestUnitSingular(func, expectedLargestUnitCalls): + * + * When an options object with a largestUnit property is synthesized inside + * Temporal and passed to user code such as calendar.dateUntil(), the value of + * the largestUnit property should be in the singular form, even if the input + * was given in the plural form. + * (This doesn't apply when the options object is passed through verbatim.) + * + * func(calendar, largestUnit, index) is the operation under test. It's called + * with an instance of a calendar that keeps track of which largestUnit is + * passed to dateUntil(), each key of expectedLargestUnitCalls in turn, and + * the key's numerical index in case the function needs to generate test data + * based on the index. At the end, the actual values passed to dateUntil() are + * compared with the array values of expectedLargestUnitCalls. + */ + checkCalendarDateUntilLargestUnitSingular(func, expectedLargestUnitCalls) { + const actual = []; + + class DateUntilOptionsCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateUntil(earlier, later, options) { + actual.push(options.largestUnit); + return super.dateUntil(earlier, later, options); + } + + toString() { + return "date-until-options"; + } + } + + const calendar = new DateUntilOptionsCalendar(); + Object.entries(expectedLargestUnitCalls).forEach(([largestUnit, expected], index) => { + func(calendar, largestUnit, index); + assert.compareArray(actual, expected, `largestUnit passed to calendar.dateUntil() for largestUnit ${largestUnit}`); + actual.splice(0); // empty it for the next check + }); + }, + + /* + * checkPlainDateTimeConversionFastPath(func): + * + * ToTemporalDate and ToTemporalTime should both, if given a + * Temporal.PlainDateTime instance, convert to the desired type by reading the + * PlainDateTime's internal slots, rather than calling any getters. + * + * func(datetime, calendar) is the actual operation to test, that must + * internally call the abstract operation ToTemporalDate or ToTemporalTime. + * It is passed a Temporal.PlainDateTime instance, as well as the instance's + * calendar object (so that it doesn't have to call the calendar getter itself + * if it wants to make any assertions about the calendar.) + */ + checkPlainDateTimeConversionFastPath(func, message = "checkPlainDateTimeConversionFastPath") { + const actual = []; + const expected = []; + + const calendar = new Temporal.Calendar("iso8601"); + const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); + const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.PlainDateTime.prototype); + ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond"].forEach((property) => { + Object.defineProperty(datetime, property, { + get() { + actual.push(`get ${formatPropertyName(property)}`); + const value = prototypeDescrs[property].get.call(this); + return { + toString() { + actual.push(`toString ${formatPropertyName(property)}`); + return value.toString(); + }, + valueOf() { + actual.push(`valueOf ${formatPropertyName(property)}`); + return value; + }, + }; + }, + }); + }); + Object.defineProperty(datetime, "calendar", { + get() { + actual.push("get calendar"); + return calendar; + }, + }); + + func(datetime, calendar); + assert.compareArray(actual, expected, `${message}: property getters not called`); + }, + + /* + * Check that an options bag that accepts units written in the singular form, + * also accepts the same units written in the plural form. + * func(unit) should call the method with the appropriate options bag + * containing unit as a value. This will be called twice for each element of + * validSingularUnits, once with singular and once with plural, and the + * results of each pair should be the same (whether a Temporal object or a + * primitive value.) + */ + checkPluralUnitsAccepted(func, validSingularUnits) { + const plurals = { + year: 'years', + month: 'months', + week: 'weeks', + day: 'days', + hour: 'hours', + minute: 'minutes', + second: 'seconds', + millisecond: 'milliseconds', + microsecond: 'microseconds', + nanosecond: 'nanoseconds', + }; + + validSingularUnits.forEach((unit) => { + const singularValue = func(unit); + const pluralValue = func(plurals[unit]); + const desc = `Plural ${plurals[unit]} produces the same result as singular ${unit}`; + if (singularValue instanceof Temporal.Duration) { + TemporalHelpers.assertDurationsEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.Instant) { + TemporalHelpers.assertInstantsEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.PlainDateTime) { + TemporalHelpers.assertPlainDateTimesEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.PlainTime) { + TemporalHelpers.assertPlainTimesEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.ZonedDateTime) { + TemporalHelpers.assertZonedDateTimesEqual(pluralValue, singularValue, desc); + } else { + assert.sameValue(pluralValue, singularValue); + } + }); + }, + + /* + * checkRoundingIncrementOptionWrongType(checkFunc, assertTrueResultFunc, assertObjectResultFunc): + * + * Checks the type handling of the roundingIncrement option. + * checkFunc(roundingIncrement) is a function which takes the value of + * roundingIncrement to test, and calls the method under test with it, + * returning the result. assertTrueResultFunc(result, description) should + * assert that result is the expected result with roundingIncrement: true, and + * assertObjectResultFunc(result, description) should assert that result is + * the expected result with roundingIncrement being an object with a valueOf() + * method. + */ + checkRoundingIncrementOptionWrongType(checkFunc, assertTrueResultFunc, assertObjectResultFunc) { + // null converts to 0, which is out of range + assert.throws(RangeError, () => checkFunc(null), "null"); + // Booleans convert to either 0 or 1, and 1 is allowed + const trueResult = checkFunc(true); + assertTrueResultFunc(trueResult, "true"); + assert.throws(RangeError, () => checkFunc(false), "false"); + // Symbols and BigInts cannot convert to numbers + assert.throws(TypeError, () => checkFunc(Symbol()), "symbol"); + assert.throws(TypeError, () => checkFunc(2n), "bigint"); + + // Objects prefer their valueOf() methods when converting to a number + assert.throws(RangeError, () => checkFunc({}), "plain object"); + + const expected = [ + "get roundingIncrement.valueOf", + "call roundingIncrement.valueOf", + ]; + const actual = []; + const observer = TemporalHelpers.toPrimitiveObserver(actual, 2, "roundingIncrement"); + const objectResult = checkFunc(observer); + assertObjectResultFunc(objectResult, "object with valueOf"); + assert.compareArray(actual, expected, "order of operations"); + }, + + /* + * checkStringOptionWrongType(propertyName, value, checkFunc, assertFunc): + * + * Checks the type handling of a string option, of which there are several in + * Temporal. + * propertyName is the name of the option, and value is the value that + * assertFunc should expect it to have. + * checkFunc(value) is a function which takes the value of the option to test, + * and calls the method under test with it, returning the result. + * assertFunc(result, description) should assert that result is the expected + * result with the option value being an object with a toString() method + * which returns the given value. + */ + checkStringOptionWrongType(propertyName, value, checkFunc, assertFunc) { + // null converts to the string "null", which is an invalid string value + assert.throws(RangeError, () => checkFunc(null), "null"); + // Booleans convert to the strings "true" or "false", which are invalid + assert.throws(RangeError, () => checkFunc(true), "true"); + assert.throws(RangeError, () => checkFunc(false), "false"); + // Symbols cannot convert to strings + assert.throws(TypeError, () => checkFunc(Symbol()), "symbol"); + // Numbers convert to strings which are invalid + assert.throws(RangeError, () => checkFunc(2), "number"); + // BigInts convert to strings which are invalid + assert.throws(RangeError, () => checkFunc(2n), "bigint"); + + // Objects prefer their toString() methods when converting to a string + assert.throws(RangeError, () => checkFunc({}), "plain object"); + + const expected = [ + `get ${propertyName}.toString`, + `call ${propertyName}.toString`, + ]; + const actual = []; + const observer = TemporalHelpers.toPrimitiveObserver(actual, value, propertyName); + const result = checkFunc(observer); + assertFunc(result, "object with toString"); + assert.compareArray(actual, expected, "order of operations"); + }, + + /* + * checkSubclassingIgnored(construct, constructArgs, method, methodArgs, + * resultAssertions): + * + * Methods of Temporal classes that return a new instance of the same class, + * must not take the constructor of a subclass into account, nor the @@species + * property. This helper runs tests to ensure this. + * + * construct(...constructArgs) must yield a valid instance of the Temporal + * class. instance[method](...methodArgs) is the method call under test, which + * must also yield a valid instance of the same Temporal class, not a + * subclass. See below for the individual tests that this runs. + * resultAssertions() is a function that performs additional assertions on the + * instance returned by the method under test. + */ + checkSubclassingIgnored(...args) { + this.checkSubclassConstructorNotObject(...args); + this.checkSubclassConstructorUndefined(...args); + this.checkSubclassConstructorThrows(...args); + this.checkSubclassConstructorNotCalled(...args); + this.checkSubclassSpeciesInvalidResult(...args); + this.checkSubclassSpeciesNotAConstructor(...args); + this.checkSubclassSpeciesNull(...args); + this.checkSubclassSpeciesUndefined(...args); + this.checkSubclassSpeciesThrows(...args); + }, + + /* + * Checks that replacing the 'constructor' property of the instance with + * various primitive values does not affect the returned new instance. + */ + checkSubclassConstructorNotObject(construct, constructArgs, method, methodArgs, resultAssertions) { + function check(value, description) { + const instance = new construct(...constructArgs); + instance.constructor = value; + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype, description); + resultAssertions(result); + } + + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "Symbol"); + check(7, "number"); + check(7n, "bigint"); + }, + + /* + * Checks that replacing the 'constructor' property of the subclass with + * undefined does not affect the returned new instance. + */ + checkSubclassConstructorUndefined(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + MySubclass.prototype.constructor = undefined; + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Checks that making the 'constructor' property of the instance throw when + * called does not affect the returned new instance. + */ + checkSubclassConstructorThrows(construct, constructArgs, method, methodArgs, resultAssertions) { + function CustomError() {} + const instance = new construct(...constructArgs); + Object.defineProperty(instance, "constructor", { + get() { + throw new CustomError(); + } + }); + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Checks that when subclassing, the subclass constructor is not called by + * the method under test. + */ + checkSubclassConstructorNotCalled(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that the constructor's @@species property is ignored when it's a + * constructor that returns a non-object value. + */ + checkSubclassSpeciesInvalidResult(construct, constructArgs, method, methodArgs, resultAssertions) { + function check(value, description) { + const instance = new construct(...constructArgs); + instance.constructor = { + [Symbol.species]: function() { + return value; + }, + }; + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype, description); + resultAssertions(result); + } + + check(undefined, "undefined"); + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "Symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "plain object"); + }, + + /* + * Check that the constructor's @@species property is ignored when it's not a + * constructor. + */ + checkSubclassSpeciesNotAConstructor(construct, constructArgs, method, methodArgs, resultAssertions) { + function check(value, description) { + const instance = new construct(...constructArgs); + instance.constructor = { + [Symbol.species]: value, + }; + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype, description); + resultAssertions(result); + } + + check(true, "true"); + check("test", "string"); + check(Symbol(), "Symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "plain object"); + }, + + /* + * Check that the constructor's @@species property is ignored when it's null. + */ + checkSubclassSpeciesNull(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + MySubclass.prototype.constructor = { + [Symbol.species]: null, + }; + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that the constructor's @@species property is ignored when it's + * undefined. + */ + checkSubclassSpeciesUndefined(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + MySubclass.prototype.constructor = { + [Symbol.species]: undefined, + }; + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that the constructor's @@species property is ignored when it throws, + * i.e. it is not called at all. + */ + checkSubclassSpeciesThrows(construct, constructArgs, method, methodArgs, resultAssertions) { + function CustomError() {} + + const instance = new construct(...constructArgs); + instance.constructor = { + get [Symbol.species]() { + throw new CustomError(); + }, + }; + + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + }, + + /* + * checkSubclassingIgnoredStatic(construct, method, methodArgs, resultAssertions): + * + * Static methods of Temporal classes that return a new instance of the class, + * must not use the this-value as a constructor. This helper runs tests to + * ensure this. + * + * construct[method](...methodArgs) is the static method call under test, and + * must yield a valid instance of the Temporal class, not a subclass. See + * below for the individual tests that this runs. + * resultAssertions() is a function that performs additional assertions on the + * instance returned by the method under test. + */ + checkSubclassingIgnoredStatic(...args) { + this.checkStaticInvalidReceiver(...args); + this.checkStaticReceiverNotCalled(...args); + this.checkThisValueNotCalled(...args); + }, + + /* + * Check that calling the static method with a receiver that's not callable, + * still calls the intrinsic constructor. + */ + checkStaticInvalidReceiver(construct, method, methodArgs, resultAssertions) { + function check(value, description) { + const result = construct[method].apply(value, methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + } + + check(undefined, "undefined"); + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "Non-callable object"); + }, + + /* + * Check that calling the static method with a receiver that returns a value + * that's not callable, still calls the intrinsic constructor. + */ + checkStaticReceiverNotCalled(construct, method, methodArgs, resultAssertions) { + function check(value, description) { + const receiver = function () { + return value; + }; + const result = construct[method].apply(receiver, methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + } + + check(undefined, "undefined"); + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "Non-callable object"); + }, + + /* + * Check that the receiver isn't called. + */ + checkThisValueNotCalled(construct, method, methodArgs, resultAssertions) { + let called = false; + + class MySubclass extends construct { + constructor(...args) { + called = true; + super(...args); + } + } + + const result = MySubclass[method](...methodArgs); + assert.sameValue(called, false); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that any iterable returned from a custom time zone's + * getPossibleInstantsFor() method is exhausted. + * The custom time zone object is passed in to func(). + * expected is an array of strings representing the expected calls to the + * getPossibleInstantsFor() method. The PlainDateTimes that it is called with, + * are compared (using their toString() results) with the array. + */ + checkTimeZonePossibleInstantsIterable(func, expected) { + // A custom time zone that returns an iterable instead of an array from its + // getPossibleInstantsFor() method, and for testing purposes skips + // 00:00-01:00 UTC on January 1, 2030, and repeats 00:00-01:00 UTC+1 on + // January 3, 2030. Otherwise identical to the UTC time zone. + class TimeZonePossibleInstantsIterable extends Temporal.TimeZone { + constructor() { + super("UTC"); + this.getPossibleInstantsForCallCount = 0; + this.getPossibleInstantsForCalledWith = []; + this.getPossibleInstantsForReturns = []; + this.iteratorExhausted = []; + } + + toString() { + return "Custom/Iterable"; + } + + getOffsetNanosecondsFor(instant) { + if (Temporal.Instant.compare(instant, "2030-01-01T00:00Z") >= 0 && + Temporal.Instant.compare(instant, "2030-01-03T01:00Z") < 0) { + return 3600_000_000_000; + } else { + return 0; + } + } + + getPossibleInstantsFor(dateTime) { + this.getPossibleInstantsForCallCount++; + this.getPossibleInstantsForCalledWith.push(dateTime); + + // Fake DST transition + let retval = super.getPossibleInstantsFor(dateTime); + if (dateTime.toPlainDate().equals("2030-01-01") && dateTime.hour === 0) { + retval = []; + } else if (dateTime.toPlainDate().equals("2030-01-03") && dateTime.hour === 0) { + retval.push(retval[0].subtract({ hours: 1 })); + } else if (dateTime.year === 2030 && dateTime.month === 1 && dateTime.day >= 1 && dateTime.day <= 2) { + retval[0] = retval[0].subtract({ hours: 1 }); + } + + this.getPossibleInstantsForReturns.push(retval); + this.iteratorExhausted.push(false); + return { + callIndex: this.getPossibleInstantsForCallCount - 1, + timeZone: this, + *[Symbol.iterator]() { + yield* this.timeZone.getPossibleInstantsForReturns[this.callIndex]; + this.timeZone.iteratorExhausted[this.callIndex] = true; + }, + }; + } + } + + const timeZone = new TimeZonePossibleInstantsIterable(); + func(timeZone); + + assert.sameValue(timeZone.getPossibleInstantsForCallCount, expected.length, "getPossibleInstantsFor() method called correct number of times"); + + for (let index = 0; index < expected.length; index++) { + assert.sameValue(timeZone.getPossibleInstantsForCalledWith[index].toString(), expected[index], "getPossibleInstantsFor() called with expected PlainDateTime"); + assert(timeZone.iteratorExhausted[index], "iterated through the whole iterable"); + } + }, + + /* + * Check that any calendar-carrying Temporal object has its [[Calendar]] + * internal slot read by ToTemporalCalendar, and does not fetch the calendar + * by calling getters. + * The custom calendar object is passed in to func() so that it can do its + * own additional assertions involving the calendar if necessary. (Sometimes + * there is nothing to assert as the calendar isn't stored anywhere that can + * be asserted about.) + */ + checkToTemporalCalendarFastPath(func) { + class CalendarFastPathCheck extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateFromFields(...args) { + return super.dateFromFields(...args).withCalendar(this); + } + + monthDayFromFields(...args) { + const { isoYear, isoMonth, isoDay } = super.monthDayFromFields(...args).getISOFields(); + return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); + } + + yearMonthFromFields(...args) { + const { isoYear, isoMonth, isoDay } = super.yearMonthFromFields(...args).getISOFields(); + return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); + } + + toString() { + return "fast-path-check"; + } + } + const calendar = new CalendarFastPathCheck(); + + const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar); + const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); + const plainMonthDay = new Temporal.PlainMonthDay(5, 2, calendar); + const plainYearMonth = new Temporal.PlainYearMonth(2000, 5, calendar); + const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); + + [plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((temporalObject) => { + const actual = []; + const expected = []; + + Object.defineProperty(temporalObject, "calendar", { + get() { + actual.push("get calendar"); + return calendar; + }, + }); + + func(temporalObject, calendar); + assert.compareArray(actual, expected, "calendar getter not called"); + }); + }, + + checkToTemporalInstantFastPath(func) { + const actual = []; + const expected = []; + + const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); + Object.defineProperty(datetime, 'toString', { + get() { + actual.push("get toString"); + return function (options) { + actual.push("call toString"); + return Temporal.ZonedDateTime.prototype.toString.call(this, options); + }; + }, + }); + + func(datetime); + assert.compareArray(actual, expected, "toString not called"); + }, + + checkToTemporalPlainDateTimeFastPath(func) { + const actual = []; + const expected = []; + + const calendar = new Temporal.Calendar("iso8601"); + const date = new Temporal.PlainDate(2000, 5, 2, calendar); + const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.PlainDate.prototype); + ["year", "month", "monthCode", "day"].forEach((property) => { + Object.defineProperty(date, property, { + get() { + actual.push(`get ${formatPropertyName(property)}`); + const value = prototypeDescrs[property].get.call(this); + return TemporalHelpers.toPrimitiveObserver(actual, value, property); + }, + }); + }); + ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"].forEach((property) => { + Object.defineProperty(date, property, { + get() { + actual.push(`get ${formatPropertyName(property)}`); + return undefined; + }, + }); + }); + Object.defineProperty(date, "calendar", { + get() { + actual.push("get calendar"); + return calendar; + }, + }); + + func(date, calendar); + assert.compareArray(actual, expected, "property getters not called"); + }, + + /* + * A custom calendar used in prototype pollution checks. Verifies that the + * fromFields methods are always called with a null-prototype fields object. + */ + calendarCheckFieldsPrototypePollution() { + class CalendarCheckFieldsPrototypePollution extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateFromFieldsCallCount = 0; + this.yearMonthFromFieldsCallCount = 0; + this.monthDayFromFieldsCallCount = 0; + } + + // toString must remain "iso8601", so that some methods don't throw due to + // incompatible calendars + + dateFromFields(fields, options = {}) { + this.dateFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "dateFromFields should be called with null-prototype fields object"); + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options = {}) { + this.yearMonthFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "yearMonthFromFields should be called with null-prototype fields object"); + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options = {}) { + this.monthDayFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "monthDayFromFields should be called with null-prototype fields object"); + return super.monthDayFromFields(fields, options); + } + } + + return new CalendarCheckFieldsPrototypePollution(); + }, + + /* + * A custom calendar used in prototype pollution checks. Verifies that the + * mergeFields() method is always called with null-prototype fields objects. + */ + calendarCheckMergeFieldsPrototypePollution() { + class CalendarCheckMergeFieldsPrototypePollution extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.mergeFieldsCallCount = 0; + } + + toString() { + return "merge-fields-null-proto"; + } + + mergeFields(fields, additionalFields) { + this.mergeFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "mergeFields should be called with null-prototype fields object (first argument)"); + assert.sameValue(Object.getPrototypeOf(additionalFields), null, "mergeFields should be called with null-prototype fields object (second argument)"); + return super.mergeFields(fields, additionalFields); + } + } + + return new CalendarCheckMergeFieldsPrototypePollution(); + }, + + /* + * A custom calendar used in prototype pollution checks. Verifies that methods + * are always called with a null-prototype options object. + */ + calendarCheckOptionsPrototypePollution() { + class CalendarCheckOptionsPrototypePollution extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.yearMonthFromFieldsCallCount = 0; + this.dateUntilCallCount = 0; + } + + toString() { + return "options-null-proto"; + } + + yearMonthFromFields(fields, options) { + this.yearMonthFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(options), null, "yearMonthFromFields should be called with null-prototype options"); + return super.yearMonthFromFields(fields, options); + } + + dateUntil(one, two, options) { + this.dateUntilCallCount++; + assert.sameValue(Object.getPrototypeOf(options), null, "dateUntil should be called with null-prototype options"); + return super.dateUntil(one, two, options); + } + } + + return new CalendarCheckOptionsPrototypePollution(); + }, + + /* + * A custom calendar that asserts its dateAdd() method is called with the + * options parameter having the value undefined. + */ + calendarDateAddUndefinedOptions() { + class CalendarDateAddUndefinedOptions extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateAddCallCount = 0; + } + + toString() { + return "dateadd-undef-options"; + } + + dateAdd(date, duration, options) { + this.dateAddCallCount++; + assert.sameValue(options, undefined, "dateAdd shouldn't be called with options"); + return super.dateAdd(date, duration, options); + } + } + return new CalendarDateAddUndefinedOptions(); + }, + + /* + * A custom calendar that asserts its dateAdd() method is called with a + * PlainDate instance. Optionally, it also asserts that the PlainDate instance + * is the specific object `this.specificPlainDate`, if it is set by the + * calling code. + */ + calendarDateAddPlainDateInstance() { + class CalendarDateAddPlainDateInstance extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateAddCallCount = 0; + this.specificPlainDate = undefined; + } + + toString() { + return "dateadd-plain-date-instance"; + } + + dateFromFields(...args) { + return super.dateFromFields(...args).withCalendar(this); + } + + dateAdd(date, duration, options) { + this.dateAddCallCount++; + assert(date instanceof Temporal.PlainDate, "dateAdd() should be called with a PlainDate instance"); + if (this.dateAddCallCount === 1 && this.specificPlainDate) { + assert.sameValue(date, this.specificPlainDate, `dateAdd() should be called first with the specific PlainDate instance ${this.specificPlainDate}`); + } + return super.dateAdd(date, duration, options).withCalendar(this); + } + } + return new CalendarDateAddPlainDateInstance(); + }, + + /* + * A custom calendar that returns an iterable instead of an array from its + * fields() method, otherwise identical to the ISO calendar. + */ + calendarFieldsIterable() { + class CalendarFieldsIterable extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.fieldsCallCount = 0; + this.fieldsCalledWith = []; + this.iteratorExhausted = []; + } + + toString() { + return "fields-iterable"; + } + + fields(fieldNames) { + this.fieldsCallCount++; + this.fieldsCalledWith.push(fieldNames.slice()); + this.iteratorExhausted.push(false); + return { + callIndex: this.fieldsCallCount - 1, + calendar: this, + *[Symbol.iterator]() { + yield* this.calendar.fieldsCalledWith[this.callIndex]; + this.calendar.iteratorExhausted[this.callIndex] = true; + }, + }; + } + } + return new CalendarFieldsIterable(); + }, + + /* + * A custom calendar that asserts its ...FromFields() methods are called with + * the options parameter having the value undefined. + */ + calendarFromFieldsUndefinedOptions() { + class CalendarFromFieldsUndefinedOptions extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateFromFieldsCallCount = 0; + this.monthDayFromFieldsCallCount = 0; + this.yearMonthFromFieldsCallCount = 0; + } + + toString() { + return "from-fields-undef-options"; + } + + dateFromFields(fields, options) { + this.dateFromFieldsCallCount++; + assert.sameValue(options, undefined, "dateFromFields shouldn't be called with options"); + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options) { + this.yearMonthFromFieldsCallCount++; + assert.sameValue(options, undefined, "yearMonthFromFields shouldn't be called with options"); + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options) { + this.monthDayFromFieldsCallCount++; + assert.sameValue(options, undefined, "monthDayFromFields shouldn't be called with options"); + return super.monthDayFromFields(fields, options); + } + } + return new CalendarFromFieldsUndefinedOptions(); + }, + + /* + * A custom calendar that modifies the fields object passed in to + * dateFromFields, sabotaging its time properties. + */ + calendarMakeInfinityTime() { + class CalendarMakeInfinityTime extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateFromFields(fields, options) { + const retval = super.dateFromFields(fields, options); + fields.hour = Infinity; + fields.minute = Infinity; + fields.second = Infinity; + fields.millisecond = Infinity; + fields.microsecond = Infinity; + fields.nanosecond = Infinity; + return retval; + } + } + return new CalendarMakeInfinityTime(); + }, + + /* + * A custom calendar that defines getters on the fields object passed into + * dateFromFields that throw, sabotaging its time properties. + */ + calendarMakeInvalidGettersTime() { + class CalendarMakeInvalidGettersTime extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateFromFields(fields, options) { + const retval = super.dateFromFields(fields, options); + const throwingDescriptor = { + get() { + throw new Test262Error("reading a sabotaged time field"); + }, + }; + Object.defineProperties(fields, { + hour: throwingDescriptor, + minute: throwingDescriptor, + second: throwingDescriptor, + millisecond: throwingDescriptor, + microsecond: throwingDescriptor, + nanosecond: throwingDescriptor, + }); + return retval; + } + } + return new CalendarMakeInvalidGettersTime(); + }, + + /* + * A custom calendar whose mergeFields() method returns a proxy object with + * all of its Get and HasProperty operations observable, as well as adding a + * "shouldNotBeCopied": true property. + */ + calendarMergeFieldsGetters() { + class CalendarMergeFieldsGetters extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.mergeFieldsReturnOperations = []; + } + + toString() { + return "merge-fields-getters"; + } + + dateFromFields(fields, options) { + assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options) { + assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options) { + assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); + return super.monthDayFromFields(fields, options); + } + + mergeFields(fields, additionalFields) { + const retval = super.mergeFields(fields, additionalFields); + retval._calendar = this; + retval.shouldNotBeCopied = true; + return new Proxy(retval, { + get(target, key) { + target._calendar.mergeFieldsReturnOperations.push(`get ${key}`); + const result = target[key]; + if (result === undefined) { + return undefined; + } + return TemporalHelpers.toPrimitiveObserver(target._calendar.mergeFieldsReturnOperations, result, key); + }, + has(target, key) { + target._calendar.mergeFieldsReturnOperations.push(`has ${key}`); + return key in target; + }, + }); + } + } + return new CalendarMergeFieldsGetters(); + }, + + /* + * A custom calendar whose mergeFields() method returns a primitive value, + * given by @primitive, and which records the number of calls made to its + * dateFromFields(), yearMonthFromFields(), and monthDayFromFields() methods. + */ + calendarMergeFieldsReturnsPrimitive(primitive) { + class CalendarMergeFieldsPrimitive extends Temporal.Calendar { + constructor(mergeFieldsReturnValue) { + super("iso8601"); + this._mergeFieldsReturnValue = mergeFieldsReturnValue; + this.dateFromFieldsCallCount = 0; + this.monthDayFromFieldsCallCount = 0; + this.yearMonthFromFieldsCallCount = 0; + } + + toString() { + return "merge-fields-primitive"; + } + + dateFromFields(fields, options) { + this.dateFromFieldsCallCount++; + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options) { + this.yearMonthFromFieldsCallCount++; + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options) { + this.monthDayFromFieldsCallCount++; + return super.monthDayFromFields(fields, options); + } + + mergeFields() { + return this._mergeFieldsReturnValue; + } + } + return new CalendarMergeFieldsPrimitive(primitive); + }, + + /* + * A custom calendar whose fields() method returns the same value as the + * iso8601 calendar, with the addition of extraFields provided as parameter. + */ + calendarWithExtraFields(fields) { + class CalendarWithExtraFields extends Temporal.Calendar { + constructor(extraFields) { + super("iso8601"); + this._extraFields = extraFields; + } + + fields(fieldNames) { + return super.fields(fieldNames).concat(this._extraFields); + } + } + + return new CalendarWithExtraFields(fields); + }, + + /* + * crossDateLineTimeZone(): + * + * This returns an instance of a custom time zone class that implements one + * single transition where the time zone moves from one side of the + * International Date Line to the other, for the purpose of testing time zone + * calculations without depending on system time zone data. + * + * The transition occurs at epoch second 1325239200 and goes from offset + * -10:00 to +14:00. In other words, the time zone skips the whole calendar + * day of 2011-12-30. This is the same as the real-life transition in the + * Pacific/Apia time zone. + */ + crossDateLineTimeZone() { + const { compare } = Temporal.PlainDate; + const skippedDay = new Temporal.PlainDate(2011, 12, 30); + const transitionEpoch = 1325239200_000_000_000n; + const beforeOffset = new Temporal.TimeZone("-10:00"); + const afterOffset = new Temporal.TimeZone("+14:00"); + + class CrossDateLineTimeZone extends Temporal.TimeZone { + constructor() { + super("+14:00"); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < transitionEpoch) { + return beforeOffset.getOffsetNanosecondsFor(instant); + } + return afterOffset.getOffsetNanosecondsFor(instant); + } + + getPossibleInstantsFor(datetime) { + const comparison = compare(datetime.toPlainDate(), skippedDay); + if (comparison === 0) { + return []; + } + if (comparison < 0) { + return [beforeOffset.getInstantFor(datetime)]; + } + return [afterOffset.getInstantFor(datetime)]; + } + + getPreviousTransition(instant) { + if (instant.epochNanoseconds > transitionEpoch) return new Temporal.Instant(transitionEpoch); + return null; + } + + getNextTransition(instant) { + if (instant.epochNanoseconds < transitionEpoch) return new Temporal.Instant(transitionEpoch); + return null; + } + + toString() { + return "Custom/Date_Line"; + } + } + return new CrossDateLineTimeZone(); + }, + + /* + * observeProperty(calls, object, propertyName, value): + * + * Defines an own property @object.@propertyName with value @value, that + * will log any calls to its accessors to the array @calls. + */ + observeProperty(calls, object, propertyName, value, objectName = "") { + Object.defineProperty(object, propertyName, { + get() { + calls.push(`get ${formatPropertyName(propertyName, objectName)}`); + return value; + }, + set(v) { + calls.push(`set ${formatPropertyName(propertyName, objectName)}`); + } + }); + }, + + /* + * observeMethod(calls, object, propertyName, value): + * + * Defines an own property @object.@propertyName with value @value, that + * will log any calls of @value to the array @calls. + */ + observeMethod(calls, object, propertyName, objectName = "") { + const method = object[propertyName]; + object[propertyName] = function () { + calls.push(`call ${formatPropertyName(propertyName, objectName)}`); + return method.apply(object, arguments); + }; + }, + + /* + * Used for substituteMethod to indicate default behavior instead of a + * substituted value + */ + SUBSTITUTE_SKIP: SKIP_SYMBOL, + + /* + * substituteMethod(object, propertyName, values): + * + * Defines an own property @object.@propertyName that will, for each + * subsequent call to the method previously defined as + * @object.@propertyName: + * - Call the method, if no more values remain + * - Call the method, if the value in @values for the corresponding call + * is SUBSTITUTE_SKIP + * - Otherwise, return the corresponding value in @value + */ + substituteMethod(object, propertyName, values) { + let calls = 0; + const method = object[propertyName]; + object[propertyName] = function () { + if (calls >= values.length) { + return method.apply(object, arguments); + } else if (values[calls] === SKIP_SYMBOL) { + calls++; + return method.apply(object, arguments); + } else { + return values[calls++]; + } + }; + }, + + /* + * calendarObserver: + * A custom calendar that behaves exactly like the ISO 8601 calendar but + * tracks calls to any of its methods, and Get/Has operations on its + * properties, by appending messages to an array. This is for the purpose of + * testing order of operations that are observable from user code. + * objectName is used in the log. + */ + calendarObserver(calls, objectName, methodOverrides = {}) { + function removeExtraHasPropertyChecks(objectName, calls) { + // Inserting the tracking calendar into the return values of methods + // that we chain up into the ISO calendar for, causes extra HasProperty + // checks, which we observe. This removes them so that we don't leak + // implementation details of the helper into the test code. + assert.sameValue(calls.pop(), `has ${objectName}.yearOfWeek`); + assert.sameValue(calls.pop(), `has ${objectName}.yearMonthFromFields`); + assert.sameValue(calls.pop(), `has ${objectName}.year`); + assert.sameValue(calls.pop(), `has ${objectName}.weekOfYear`); + assert.sameValue(calls.pop(), `has ${objectName}.monthsInYear`); + assert.sameValue(calls.pop(), `has ${objectName}.monthDayFromFields`); + assert.sameValue(calls.pop(), `has ${objectName}.monthCode`); + assert.sameValue(calls.pop(), `has ${objectName}.month`); + assert.sameValue(calls.pop(), `has ${objectName}.mergeFields`); + assert.sameValue(calls.pop(), `has ${objectName}.inLeapYear`); + assert.sameValue(calls.pop(), `has ${objectName}.id`); + assert.sameValue(calls.pop(), `has ${objectName}.fields`); + assert.sameValue(calls.pop(), `has ${objectName}.daysInYear`); + assert.sameValue(calls.pop(), `has ${objectName}.daysInWeek`); + assert.sameValue(calls.pop(), `has ${objectName}.daysInMonth`); + assert.sameValue(calls.pop(), `has ${objectName}.dayOfYear`); + assert.sameValue(calls.pop(), `has ${objectName}.dayOfWeek`); + assert.sameValue(calls.pop(), `has ${objectName}.day`); + assert.sameValue(calls.pop(), `has ${objectName}.dateUntil`); + assert.sameValue(calls.pop(), `has ${objectName}.dateFromFields`); + assert.sameValue(calls.pop(), `has ${objectName}.dateAdd`); + } + + const iso8601 = new Temporal.Calendar("iso8601"); + const trackingMethods = { + dateFromFields(...args) { + calls.push(`call ${objectName}.dateFromFields`); + if ('dateFromFields' in methodOverrides) { + const value = methodOverrides.dateFromFields; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.dateFromFields(...args); + // Replace the calendar in the result with the call-tracking calendar + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + yearMonthFromFields(...args) { + calls.push(`call ${objectName}.yearMonthFromFields`); + if ('yearMonthFromFields' in methodOverrides) { + const value = methodOverrides.yearMonthFromFields; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.yearMonthFromFields(...args); + // Replace the calendar in the result with the call-tracking calendar + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + monthDayFromFields(...args) { + calls.push(`call ${objectName}.monthDayFromFields`); + if ('monthDayFromFields' in methodOverrides) { + const value = methodOverrides.monthDayFromFields; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.monthDayFromFields(...args); + // Replace the calendar in the result with the call-tracking calendar + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + dateAdd(...args) { + calls.push(`call ${objectName}.dateAdd`); + if ('dateAdd' in methodOverrides) { + const value = methodOverrides.dateAdd; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.dateAdd(...args); + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + id: "iso8601", + }; + // Automatically generate the other methods that don't need any custom code + [ + "dateUntil", + "day", + "dayOfWeek", + "dayOfYear", + "daysInMonth", + "daysInWeek", + "daysInYear", + "era", + "eraYear", + "fields", + "inLeapYear", + "mergeFields", + "month", + "monthCode", + "monthsInYear", + "toString", + "weekOfYear", + "year", + "yearOfWeek", + ].forEach((methodName) => { + trackingMethods[methodName] = function (...args) { + calls.push(`call ${formatPropertyName(methodName, objectName)}`); + if (methodName in methodOverrides) { + const value = methodOverrides[methodName]; + return typeof value === "function" ? value(...args) : value; + } + return iso8601[methodName](...args); + }; + }); + return new Proxy(trackingMethods, { + get(target, key, receiver) { + const result = Reflect.get(target, key, receiver); + calls.push(`get ${formatPropertyName(key, objectName)}`); + return result; + }, + has(target, key) { + calls.push(`has ${formatPropertyName(key, objectName)}`); + return Reflect.has(target, key); + }, + }); + }, + + /* + * A custom calendar that does not allow any of its methods to be called, for + * the purpose of asserting that a particular operation does not call into + * user code. + */ + calendarThrowEverything() { + class CalendarThrowEverything extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + toString() { + TemporalHelpers.assertUnreachable("toString should not be called"); + } + dateFromFields() { + TemporalHelpers.assertUnreachable("dateFromFields should not be called"); + } + yearMonthFromFields() { + TemporalHelpers.assertUnreachable("yearMonthFromFields should not be called"); + } + monthDayFromFields() { + TemporalHelpers.assertUnreachable("monthDayFromFields should not be called"); + } + dateAdd() { + TemporalHelpers.assertUnreachable("dateAdd should not be called"); + } + dateUntil() { + TemporalHelpers.assertUnreachable("dateUntil should not be called"); + } + era() { + TemporalHelpers.assertUnreachable("era should not be called"); + } + eraYear() { + TemporalHelpers.assertUnreachable("eraYear should not be called"); + } + year() { + TemporalHelpers.assertUnreachable("year should not be called"); + } + month() { + TemporalHelpers.assertUnreachable("month should not be called"); + } + monthCode() { + TemporalHelpers.assertUnreachable("monthCode should not be called"); + } + day() { + TemporalHelpers.assertUnreachable("day should not be called"); + } + fields() { + TemporalHelpers.assertUnreachable("fields should not be called"); + } + mergeFields() { + TemporalHelpers.assertUnreachable("mergeFields should not be called"); + } + } + + return new CalendarThrowEverything(); + }, + + /* + * oneShiftTimeZone(shiftInstant, shiftNanoseconds): + * + * In the case of a spring-forward time zone offset transition (skipped time), + * and disambiguation === 'earlier', BuiltinTimeZoneGetInstantFor subtracts a + * negative number of nanoseconds from a PlainDateTime, which should balance + * with the microseconds field. + * + * This returns an instance of a custom time zone class which skips a length + * of time equal to shiftNanoseconds (a number), at the Temporal.Instant + * shiftInstant. Before shiftInstant, it's identical to UTC, and after + * shiftInstant it's a constant-offset time zone. + * + * It provides a getPossibleInstantsForCalledWith member which is an array + * with the result of calling toString() on any PlainDateTimes passed to + * getPossibleInstantsFor(). + */ + oneShiftTimeZone(shiftInstant, shiftNanoseconds) { + class OneShiftTimeZone extends Temporal.TimeZone { + constructor(shiftInstant, shiftNanoseconds) { + super("+00:00"); + this._shiftInstant = shiftInstant; + this._epoch1 = shiftInstant.epochNanoseconds; + this._epoch2 = this._epoch1 + BigInt(shiftNanoseconds); + this._shiftNanoseconds = shiftNanoseconds; + this._shift = new Temporal.Duration(0, 0, 0, 0, 0, 0, 0, 0, 0, this._shiftNanoseconds); + this.getPossibleInstantsForCalledWith = []; + } + + _isBeforeShift(instant) { + return instant.epochNanoseconds < this._epoch1; + } + + getOffsetNanosecondsFor(instant) { + return this._isBeforeShift(instant) ? 0 : this._shiftNanoseconds; + } + + getPossibleInstantsFor(plainDateTime) { + this.getPossibleInstantsForCalledWith.push(plainDateTime.toString({ calendarName: "never" })); + const [instant] = super.getPossibleInstantsFor(plainDateTime); + if (this._shiftNanoseconds > 0) { + if (this._isBeforeShift(instant)) return [instant]; + if (instant.epochNanoseconds < this._epoch2) return []; + return [instant.subtract(this._shift)]; + } + if (instant.epochNanoseconds < this._epoch2) return [instant]; + const shifted = instant.subtract(this._shift); + if (this._isBeforeShift(instant)) return [instant, shifted]; + return [shifted]; + } + + getNextTransition(instant) { + return this._isBeforeShift(instant) ? this._shiftInstant : null; + } + + getPreviousTransition(instant) { + return this._isBeforeShift(instant) ? null : this._shiftInstant; + } + + toString() { + return "Custom/One_Shift"; + } + } + return new OneShiftTimeZone(shiftInstant, shiftNanoseconds); + }, + + /* + * propertyBagObserver(): + * Returns an object that behaves like the given propertyBag but tracks Get + * and Has operations on any of its properties, by appending messages to an + * array. If the value of a property in propertyBag is a primitive, the value + * of the returned object's property will additionally be a + * TemporalHelpers.toPrimitiveObserver that will track calls to its toString + * and valueOf methods in the same array. This is for the purpose of testing + * order of operations that are observable from user code. objectName is used + * in the log. + */ + propertyBagObserver(calls, propertyBag, objectName) { + return new Proxy(propertyBag, { + ownKeys(target) { + calls.push(`ownKeys ${objectName}`); + return Reflect.ownKeys(target); + }, + getOwnPropertyDescriptor(target, key) { + calls.push(`getOwnPropertyDescriptor ${formatPropertyName(key, objectName)}`); + return Reflect.getOwnPropertyDescriptor(target, key); + }, + get(target, key, receiver) { + calls.push(`get ${formatPropertyName(key, objectName)}`); + const result = Reflect.get(target, key, receiver); + if (result === undefined) { + return undefined; + } + if ((result !== null && typeof result === "object") || typeof result === "function") { + return result; + } + return TemporalHelpers.toPrimitiveObserver(calls, result, `${formatPropertyName(key, objectName)}`); + }, + has(target, key) { + calls.push(`has ${formatPropertyName(key, objectName)}`); + return Reflect.has(target, key); + }, + }); + }, + + /* + * specificOffsetTimeZone(): + * + * This returns an instance of a custom time zone class, which returns a + * specific custom value from its getOffsetNanosecondsFrom() method. This is + * for the purpose of testing the validation of what this method returns. + * + * It also returns an empty array from getPossibleInstantsFor(), so as to + * trigger calls to getOffsetNanosecondsFor() when used from the + * BuiltinTimeZoneGetInstantFor operation. + */ + specificOffsetTimeZone(offsetValue) { + class SpecificOffsetTimeZone extends Temporal.TimeZone { + constructor(offsetValue) { + super("UTC"); + this._offsetValue = offsetValue; + } + + getOffsetNanosecondsFor() { + return this._offsetValue; + } + + getPossibleInstantsFor(dt) { + if (typeof this._offsetValue !== 'number' || Math.abs(this._offsetValue) >= 86400e9 || isNaN(this._offsetValue)) return []; + const zdt = dt.toZonedDateTime("UTC").add({ nanoseconds: -this._offsetValue }); + return [zdt.toInstant()]; + } + + get id() { + return this.getOffsetStringFor(new Temporal.Instant(0n)); + } + } + return new SpecificOffsetTimeZone(offsetValue); + }, + + /* + * springForwardFallBackTimeZone(): + * + * This returns an instance of a custom time zone class that implements one + * single spring-forward/fall-back transition, for the purpose of testing the + * disambiguation option, without depending on system time zone data. + * + * The spring-forward occurs at epoch second 954669600 (2000-04-02T02:00 + * local) and goes from offset -08:00 to -07:00. + * + * The fall-back occurs at epoch second 972810000 (2000-10-29T02:00 local) and + * goes from offset -07:00 to -08:00. + */ + springForwardFallBackTimeZone() { + const { compare } = Temporal.PlainDateTime; + const springForwardLocal = new Temporal.PlainDateTime(2000, 4, 2, 2); + const springForwardEpoch = 954669600_000_000_000n; + const fallBackLocal = new Temporal.PlainDateTime(2000, 10, 29, 1); + const fallBackEpoch = 972810000_000_000_000n; + const winterOffset = new Temporal.TimeZone('-08:00'); + const summerOffset = new Temporal.TimeZone('-07:00'); + + class SpringForwardFallBackTimeZone extends Temporal.TimeZone { + constructor() { + super("-08:00"); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < springForwardEpoch || + instant.epochNanoseconds >= fallBackEpoch) { + return winterOffset.getOffsetNanosecondsFor(instant); + } + return summerOffset.getOffsetNanosecondsFor(instant); + } + + getPossibleInstantsFor(datetime) { + if (compare(datetime, springForwardLocal) >= 0 && compare(datetime, springForwardLocal.add({ hours: 1 })) < 0) { + return []; + } + if (compare(datetime, fallBackLocal) >= 0 && compare(datetime, fallBackLocal.add({ hours: 1 })) < 0) { + return [summerOffset.getInstantFor(datetime), winterOffset.getInstantFor(datetime)]; + } + if (compare(datetime, springForwardLocal) < 0 || compare(datetime, fallBackLocal) >= 0) { + return [winterOffset.getInstantFor(datetime)]; + } + return [summerOffset.getInstantFor(datetime)]; + } + + getPreviousTransition(instant) { + if (instant.epochNanoseconds > fallBackEpoch) return new Temporal.Instant(fallBackEpoch); + if (instant.epochNanoseconds > springForwardEpoch) return new Temporal.Instant(springForwardEpoch); + return null; + } + + getNextTransition(instant) { + if (instant.epochNanoseconds < springForwardEpoch) return new Temporal.Instant(springForwardEpoch); + if (instant.epochNanoseconds < fallBackEpoch) return new Temporal.Instant(fallBackEpoch); + return null; + } + + get id() { + return "Custom/Spring_Fall"; + } + + toString() { + return "Custom/Spring_Fall"; + } + } + return new SpringForwardFallBackTimeZone(); + }, + + /* + * timeZoneObserver: + * A custom calendar that behaves exactly like the UTC time zone but tracks + * calls to any of its methods, and Get/Has operations on its properties, by + * appending messages to an array. This is for the purpose of testing order of + * operations that are observable from user code. objectName is used in the + * log. methodOverrides is an optional object containing properties with the + * same name as Temporal.TimeZone methods. If the property value is a function + * it will be called with the proper arguments instead of the UTC method. + * Otherwise, the property value will be returned directly. + */ + timeZoneObserver(calls, objectName, methodOverrides = {}) { + const utc = new Temporal.TimeZone("UTC"); + const trackingMethods = { + id: "UTC", + }; + // Automatically generate the methods + ["getOffsetNanosecondsFor", "getPossibleInstantsFor", "toString"].forEach((methodName) => { + trackingMethods[methodName] = function (...args) { + calls.push(`call ${formatPropertyName(methodName, objectName)}`); + if (methodName in methodOverrides) { + const value = methodOverrides[methodName]; + return typeof value === "function" ? value(...args) : value; + } + return utc[methodName](...args); + }; + }); + return new Proxy(trackingMethods, { + get(target, key, receiver) { + const result = Reflect.get(target, key, receiver); + calls.push(`get ${formatPropertyName(key, objectName)}`); + return result; + }, + has(target, key) { + calls.push(`has ${formatPropertyName(key, objectName)}`); + return Reflect.has(target, key); + }, + }); + }, + + /* + * A custom time zone that does not allow any of its methods to be called, for + * the purpose of asserting that a particular operation does not call into + * user code. + */ + timeZoneThrowEverything() { + class TimeZoneThrowEverything extends Temporal.TimeZone { + constructor() { + super("UTC"); + } + getOffsetNanosecondsFor() { + TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be called"); + } + getPossibleInstantsFor() { + TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be called"); + } + toString() { + TemporalHelpers.assertUnreachable("toString should not be called"); + } + } + + return new TimeZoneThrowEverything(); + }, + + /* + * Returns an object that will append logs of any Gets or Calls of its valueOf + * or toString properties to the array calls. Both valueOf and toString will + * return the actual primitiveValue. propertyName is used in the log. + */ + toPrimitiveObserver(calls, primitiveValue, propertyName) { + return { + get valueOf() { + calls.push(`get ${propertyName}.valueOf`); + return function () { + calls.push(`call ${propertyName}.valueOf`); + return primitiveValue; + }; + }, + get toString() { + calls.push(`get ${propertyName}.toString`); + return function () { + calls.push(`call ${propertyName}.toString`); + if (primitiveValue === undefined) return undefined; + return primitiveValue.toString(); + }; + }, + }; + }, + + /* + * An object containing further methods that return arrays of ISO strings, for + * testing parsers. + */ + ISO: { + /* + * PlainMonthDay strings that are not valid. + */ + plainMonthDayStringsInvalid() { + return [ + "11-18junk", + "11-18[u-ca=gregory]", + "11-18[u-ca=hebrew]", + ]; + }, + + /* + * PlainMonthDay strings that are valid and that should produce October 1st. + */ + plainMonthDayStringsValid() { + return [ + "10-01", + "1001", + "1965-10-01", + "1976-10-01T152330.1+00:00", + "19761001T15:23:30.1+00:00", + "1976-10-01T15:23:30.1+0000", + "1976-10-01T152330.1+0000", + "19761001T15:23:30.1+0000", + "19761001T152330.1+00:00", + "19761001T152330.1+0000", + "+001976-10-01T152330.1+00:00", + "+0019761001T15:23:30.1+00:00", + "+001976-10-01T15:23:30.1+0000", + "+001976-10-01T152330.1+0000", + "+0019761001T15:23:30.1+0000", + "+0019761001T152330.1+00:00", + "+0019761001T152330.1+0000", + "1976-10-01T15:23:00", + "1976-10-01T15:23", + "1976-10-01T15", + "1976-10-01", + "--10-01", + "--1001", + ]; + }, + + /* + * PlainTime strings that may be mistaken for PlainMonthDay or + * PlainYearMonth strings, and so require a time designator. + */ + plainTimeStringsAmbiguous() { + const ambiguousStrings = [ + "2021-12", // ambiguity between YYYY-MM and HHMM-UU + "2021-12[-12:00]", // ditto, TZ does not disambiguate + "1214", // ambiguity between MMDD and HHMM + "0229", // ditto, including MMDD that doesn't occur every year + "1130", // ditto, including DD that doesn't occur in every month + "12-14", // ambiguity between MM-DD and HH-UU + "12-14[-14:00]", // ditto, TZ does not disambiguate + "202112", // ambiguity between YYYYMM and HHMMSS + "202112[UTC]", // ditto, TZ does not disambiguate + ]; + // Adding a calendar annotation to one of these strings must not cause + // disambiguation in favour of time. + const stringsWithCalendar = ambiguousStrings.map((s) => s + '[u-ca=iso8601]'); + return ambiguousStrings.concat(stringsWithCalendar); + }, + + /* + * PlainTime strings that are of similar form to PlainMonthDay and + * PlainYearMonth strings, but are not ambiguous due to components that + * aren't valid as months or days. + */ + plainTimeStringsUnambiguous() { + return [ + "2021-13", // 13 is not a month + "202113", // ditto + "2021-13[-13:00]", // ditto + "202113[-13:00]", // ditto + "0000-00", // 0 is not a month + "000000", // ditto + "0000-00[UTC]", // ditto + "000000[UTC]", // ditto + "1314", // 13 is not a month + "13-14", // ditto + "1232", // 32 is not a day + "0230", // 30 is not a day in February + "0631", // 31 is not a day in June + "0000", // 0 is neither a month nor a day + "00-00", // ditto + ]; + }, + + /* + * PlainYearMonth-like strings that are not valid. + */ + plainYearMonthStringsInvalid() { + return [ + "2020-13", + ]; + }, + + /* + * PlainYearMonth-like strings that are valid and should produce November + * 1976 in the ISO 8601 calendar. + */ + plainYearMonthStringsValid() { + return [ + "1976-11", + "1976-11-10", + "1976-11-01T09:00:00+00:00", + "1976-11-01T00:00:00+05:00", + "197611", + "+00197611", + "1976-11-18T15:23:30.1\u221202:00", + "1976-11-18T152330.1+00:00", + "19761118T15:23:30.1+00:00", + "1976-11-18T15:23:30.1+0000", + "1976-11-18T152330.1+0000", + "19761118T15:23:30.1+0000", + "19761118T152330.1+00:00", + "19761118T152330.1+0000", + "+001976-11-18T152330.1+00:00", + "+0019761118T15:23:30.1+00:00", + "+001976-11-18T15:23:30.1+0000", + "+001976-11-18T152330.1+0000", + "+0019761118T15:23:30.1+0000", + "+0019761118T152330.1+00:00", + "+0019761118T152330.1+0000", + "1976-11-18T15:23", + "1976-11-18T15", + "1976-11-18", + ]; + }, + + /* + * PlainYearMonth-like strings that are valid and should produce November of + * the ISO year -9999. + */ + plainYearMonthStringsValidNegativeYear() { + return [ + "\u2212009999-11", + ]; + }, + } +}; diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-input-with-non-promise-thenable.js b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-input-with-non-promise-thenable.js new file mode 100644 index 0000000000..7bdaf5942a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-input-with-non-promise-thenable.js @@ -0,0 +1,24 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Sync-iterable input with non-promise thenables works. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + const expected = [ expectedValue ]; + const inputThenable = { + then (resolve, reject) { + resolve(expectedValue); + }, + }; + const input = [ inputThenable ].values(); + const output = await Array.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-input-with-thenable.js b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-input-with-thenable.js new file mode 100644 index 0000000000..59b7f5392c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-input-with-thenable.js @@ -0,0 +1,18 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Sync-iterable input with thenables is transferred to the output array. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expected = [ 0, 1, 2 ]; + const input = [ 0, Promise.resolve(1), Promise.resolve(2) ].values(); + const output = await Array.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-input.js b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-input.js new file mode 100644 index 0000000000..283f12d8ab --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-input.js @@ -0,0 +1,18 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Sync-iterable input with no promises is transferred to the output array. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expected = [ 0, 1, 2 ]; + const input = [ 0, 1, 2 ].values(); + const output = await Array.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-iteration-err.js b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-iteration-err.js new file mode 100644 index 0000000000..91b110e4ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-iteration-err.js @@ -0,0 +1,20 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Sync iterable result promise rejects if iteration of input fails. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + function *generateInput () { + throw new Test262Error; + } + const input = generateInput(); + const outputPromise = Array.fromAsync(input); + await assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-awaits-once.js b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-awaits-once.js new file mode 100644 index 0000000000..1b3bdbf2e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-awaits-once.js @@ -0,0 +1,26 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Sync-iterable input with thenables awaits each input once with async mapping callback. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + let awaitCounter = 0; + const inputThenable = { + then (resolve, reject) { + awaitCounter++; + resolve(expectedValue); + }, + }; + const input = [ inputThenable ].values(); + await Array.fromAsync(input, async v => v); + assert.sameValue(awaitCounter, 1); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-callback-err.js b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-callback-err.js new file mode 100644 index 0000000000..d77da6aa10 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-callback-err.js @@ -0,0 +1,19 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Sync-iterable input with thenable result promise rejects if async map function callback throws. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const input = [ Promise.resolve(0) ].values(); + const outputPromise = Array.fromAsync(input, async v => { + throw new Test262Error; + }); + await assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-awaits-once.js b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-awaits-once.js new file mode 100644 index 0000000000..00dd71407c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-awaits-once.js @@ -0,0 +1,26 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Sync-iterable input with thenables awaits each input once without mapping callback +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + let awaitCounter = 0; + const inputThenable = { + then (resolve, reject) { + awaitCounter++; + resolve(expectedValue); + }, + }; + const input = [ inputThenable ].values(); + await Array.fromAsync(input); + assert.sameValue(awaitCounter, 1); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-element-rejects.js b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-element-rejects.js new file mode 100644 index 0000000000..b5b0a6c3e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-element-rejects.js @@ -0,0 +1,22 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Result promise rejects if then method of input fails. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const inputThenable = { + then (resolve, reject) { + reject(new Test262Error); + }, + }; + const input = [ inputThenable ].values(); + const output = Array.fromAsync(input); + await assert.throwsAsync(Test262Error, () => output); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-awaits-once.js b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-awaits-once.js new file mode 100644 index 0000000000..324a7b1701 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-awaits-once.js @@ -0,0 +1,26 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Sync-iterable input with mapfn awaits each input once with sync mapping callback +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + let awaitCounter = 0; + const inputThenable = { + then (resolve, reject) { + awaitCounter++; + resolve(expectedValue); + }, + }; + const input = [ inputThenable ].values(); + await Array.fromAsync(input, v => v); + assert.sameValue(awaitCounter, 1); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-callback-err.js b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-callback-err.js new file mode 100644 index 0000000000..d502ec0209 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-callback-err.js @@ -0,0 +1,19 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Sync-iterable input with thenable result promise rejects if sync map function callback throws. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const input = [ Promise.resolve(0) ].values(); + const outputPromise = Array.fromAsync(input, v => { + throw new Test262Error; + }); + await assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-then-method-err.js b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-then-method-err.js new file mode 100644 index 0000000000..30bd54dac6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-thenable-then-method-err.js @@ -0,0 +1,24 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: Result promise rejects if then method of input fails. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + const expected = [ expectedValue ]; + const inputThenable = { + then (resolve, reject) { + throw new Test262Error(); + }, + }; + const input = [ inputThenable ].values(); + const output = Array.fromAsync(input); + await assert.throwsAsync(Test262Error, () => output); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-operations.js b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-operations.js new file mode 100644 index 0000000000..ee96890677 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-operations.js @@ -0,0 +1,74 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Order of user-observable operations on a custom this-value and its instances +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +function formatPropertyName(propertyKey, objectName = "") { + switch (typeof propertyKey) { + case "symbol": + if (Symbol.keyFor(propertyKey) !== undefined) { + return `${objectName}[Symbol.for('${Symbol.keyFor(propertyKey)}')]`; + } else if (propertyKey.description.startsWith('Symbol.')) { + return `${objectName}[${propertyKey.description}]`; + } else { + return `${objectName}[Symbol('${propertyKey.description}')]` + } + case "string": + if (propertyKey !== String(Number(propertyKey))) + return objectName ? `${objectName}.${propertyKey}` : propertyKey; + // fall through + default: + // integer or string integer-index + return `${objectName}[${propertyKey}]`; + } +} + +asyncTest(async function () { + const expectedCalls = [ + "construct MyArray", + "defineProperty A[0]", + "defineProperty A[1]", + "set A.length" + ]; + const actualCalls = []; + + function MyArray(...args) { + actualCalls.push("construct MyArray"); + return new Proxy(Object.create(null), { + set(target, key, value) { + actualCalls.push(`set ${formatPropertyName(key, "A")}`); + return Reflect.set(target, key, value); + }, + defineProperty(target, key, descriptor) { + actualCalls.push(`defineProperty ${formatPropertyName(key, "A")}`); + return Reflect.defineProperty(target, key, descriptor); + } + }); + } + + let result = await Array.fromAsync.call(MyArray, [1, 2]); + assert.compareArray(expectedCalls, actualCalls, "order of operations for array argument"); + + actualCalls.splice(0); // reset + + const expectedCallsForArrayLike = [ + "construct MyArray", + "defineProperty A[0]", + "defineProperty A[1]", + "set A.length" + ]; + result = await Array.fromAsync.call(MyArray, { + length: 2, + 0: 1, + 1: 2 + }); + assert.compareArray(expectedCallsForArrayLike, actualCalls, "order of operations for array-like argument"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-bad-length-setter.js b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-bad-length-setter.js new file mode 100644 index 0000000000..b3cf982af7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-bad-length-setter.js @@ -0,0 +1,34 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Rejects the promise if setting the length fails on an instance of a custom + this-value +info: | + 3.j.ii.4.a. Perform ? Set(_A_, *"length"*, 𝔽(_k_), *true*). + ... + 3.k.viii. Perform ? Set(_A_, *"length"*, 𝔽(_len_), *true*) +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + class MyArray { + set length(v) { + throw new Test262Error("setter of length property throws") + } + } + + await assert.throwsAsync(Test262Error, () => Array.fromAsync.call(MyArray, [0, 1, 2]), "Promise rejected if setting length fails"); + + await assert.throwsAsync(Test262Error, () => Array.fromAsync.call(MyArray, { + length: 3, + 0: 0, + 1: 1, + 2: 2 + }), "Promise rejected if setting length from array-like fails"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-readonly-elements.js b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-readonly-elements.js new file mode 100644 index 0000000000..112824f6e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-readonly-elements.js @@ -0,0 +1,51 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Overwrites non-writable element properties on an instance of a custom + this-value +info: | + 3.j.ii.8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). + ... + 3.k.vii.6. Perform ? CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + function MyArray() { + this.length = 4; + for (let ix = 0; ix < this.length; ix++) { + Object.defineProperty(this, ix, { + enumerable: true, + writable: false, + configurable: true, + value: 99 + }); + } + } + + let result = await Array.fromAsync.call(MyArray, [0, 1, 2]); + assert.sameValue(result.length, 3, "Length property is overwritten"); + assert.sameValue(result[0], 0, "Read-only element 0 is overwritten"); + assert.sameValue(result[1], 1, "Read-only element 1 is overwritten"); + assert.sameValue(result[2], 2, "Read-only element 2 is overwritten"); + assert.sameValue(result[3], 99, "Element 3 is not overwritten"); + + result = await Array.fromAsync.call(MyArray, { + length: 3, + 0: 0, + 1: 1, + 2: 2, + 3: 3 // ignored + }); + assert.sameValue(result.length, 3, "Length property is overwritten"); + assert.sameValue(result[0], 0, "Read-only element 0 is overwritten"); + assert.sameValue(result[1], 1, "Read-only element 1 is overwritten"); + assert.sameValue(result[2], 2, "Read-only element 2 is overwritten"); + assert.sameValue(result[3], 99, "Element 3 is not overwritten"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-readonly-length.js b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-readonly-length.js new file mode 100644 index 0000000000..f5f9495004 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-readonly-length.js @@ -0,0 +1,39 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Promise is rejected if length property on an instance of a custom this-value + is non-writable +info: | + 3.j.ii.4.a. Perform ? Set(_A_, *"length"*, 𝔽(_k_), *true*). + ... + 3.k.viii. Perform ? Set(_A_, *"length"*, 𝔽(_len_), *true*). + + Note that there is no difference between strict mode and sloppy mode, because + we are not following runtime evaluation semantics. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + function MyArray() { + Object.defineProperty(this, "length", { + enumerable: true, + writable: false, + configurable: true, + value: 99 + }); + } + + await assert.throwsAsync(TypeError, () => Array.fromAsync.call(MyArray, [0, 1, 2]), "Setting read-only length fails"); + await assert.throwsAsync(TypeError, () => Array.fromAsync.call(MyArray, { + length: 3, + 0: 0, + 1: 1, + 2: 2 + }), "Setting read-only length fails in array-like case"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-unsettable-element-closes-async-iterator.js b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-unsettable-element-closes-async-iterator.js new file mode 100644 index 0000000000..4986847991 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-unsettable-element-closes-async-iterator.js @@ -0,0 +1,44 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Closes an async iterator if setting an element fails on an instance of a + custom this-value +info: | + 3.j.ii.8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). + 9. If _defineStatus_ is an abrupt completion, return ? AsyncIteratorClose(_iteratorRecord_, _defineStatus_). +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + function MyArray() { + Object.defineProperty(this, 0, { + enumerable: true, + writable: true, + configurable: false, + value: 0 + }); + } + + let closed = false; + const iterator = { + next() { + return Promise.resolve({ value: 1, done: false }); + }, + return() { + closed = true; + return Promise.resolve({ done: true }); + }, + [Symbol.asyncIterator]() { + return this; + } + } + + await assert.throwsAsync(TypeError, () => Array.fromAsync.call(MyArray, iterator), "Promise rejected if defining element fails"); + assert(closed, "element define failure should close iterator"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-unsettable-element-closes-sync-iterator.js b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-unsettable-element-closes-sync-iterator.js new file mode 100644 index 0000000000..8138532547 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-unsettable-element-closes-sync-iterator.js @@ -0,0 +1,44 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Closes a sync iterator if setting an element fails on an instance of a custom + this-value +info: | + 3.j.ii.8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). + 9. If _defineStatus_ is an abrupt completion, return ? AsyncIteratorClose(_iteratorRecord_, _defineStatus_). +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + function MyArray() { + Object.defineProperty(this, 0, { + enumerable: true, + writable: true, + configurable: false, + value: 0 + }); + } + + let closed = false; + const iterator = { + next() { + return { value: 1, done: false }; + }, + return() { + closed = true; + return { done: true }; + }, + [Symbol.iterator]() { + return this; + } + } + + await assert.throwsAsync(TypeError, () => Array.fromAsync.call(MyArray, iterator), "Promise rejected if defining element fails"); + assert(closed, "element define failure should close iterator"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-unsettable-element.js b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-unsettable-element.js new file mode 100644 index 0000000000..de283488f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor-with-unsettable-element.js @@ -0,0 +1,29 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Rejects the promise if setting an element fails on an instance of a custom + this-value +info: | + 3.j.ii.8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). + 9. If _defineStatus_ is an abrupt completion, return ? AsyncIteratorClose(_iteratorRecord_, _defineStatus_). +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + function MyArray() { + Object.defineProperty(this, 0, { + enumerable: true, + writable: true, + configurable: false, + value: 0 + }); + } + + await assert.throwsAsync(TypeError, () => Array.fromAsync.call(MyArray, [0, 1, 2]), "Promise rejected if defining element fails"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor.js b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor.js new file mode 100644 index 0000000000..e8c2c1948f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/this-constructor.js @@ -0,0 +1,53 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Constructs the this-value once if asyncItems is iterable, twice if not, and + length and element properties are set correctly on the result +info: | + 3.e. If IsConstructor(_C_) is *true*, then + i. Let _A_ be ? Construct(_C_). + ... + j. If _iteratorRecord_ is not *undefined*, then + ... + k. Else, + ... + iv. If IsConstructor(_C_) is *true*, then + 1. Let _A_ be ? Construct(_C_, « 𝔽(_len_) »). +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const constructorCalls = []; + + function MyArray(...args) { + constructorCalls.push(args); + } + + let result = await Array.fromAsync.call(MyArray, [1, 2]); + assert(result instanceof MyArray, "result is an instance of the constructor this-value"); + assert.sameValue(result.length, 2, "length is set on result"); + assert.sameValue(result[0], 1, "element 0 is set on result"); + assert.sameValue(result[1], 2, "element 1 is set on result"); + assert.sameValue(constructorCalls.length, 1, "constructor is called once"); + assert.compareArray(constructorCalls[0], [], "constructor is called with no arguments"); + + constructorCalls.splice(0); // reset + + result = await Array.fromAsync.call(MyArray, { + length: 2, + 0: 1, + 1: 2 + }); + assert(result instanceof MyArray, "result is an instance of the constructor this-value"); + assert.sameValue(result.length, 2, "length is set on result"); + assert.sameValue(result[0], 1, "element 0 is set on result"); + assert.sameValue(result[1], 2, "element 1 is set on result"); + assert.sameValue(constructorCalls.length, 1, "constructor is called once"); + assert.compareArray(constructorCalls[0], [2], "constructor is called with a length argument"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/this-non-constructor.js b/js/src/tests/test262/built-ins/Array/fromAsync/this-non-constructor.js new file mode 100644 index 0000000000..10934a855a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/this-non-constructor.js @@ -0,0 +1,49 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Constructs an intrinsic Array if this-value is not a constructor, and length + and element properties are set accordingly. +info: | + 3.e. If IsConstructor(_C_) is *true*, then + ... + f. Else, + i. Let _A_ be ! ArrayCreate(0). + + ... + j. If _iteratorRecord_ is not *undefined*, then + ... + k. Else, + ... + iv. If IsConstructor(_C_) is *true*, then + ... + v. Else, + 1. Let _A_ be ? ArrayCreate(_len_). +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const thisValue = { + length: 4000, + 0: 32, + 1: 64, + 2: 128 + }; + + let result = await Array.fromAsync.call(thisValue, [1, 2]); + assert(Array.isArray(result), "result is an intrinsic Array"); + assert.compareArray(result, [1, 2], "result is not disrupted by properties of this-value"); + + result = await Array.fromAsync.call(thisValue, { + length: 2, + 0: 1, + 1: 2 + }); + assert(Array.isArray(result), "result is an intrinsic Array"); + assert.compareArray(result, [1, 2], "result is not disrupted by properties of this-value"); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-object.js b/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-object.js new file mode 100644 index 0000000000..5d2c9cdc53 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-object.js @@ -0,0 +1,22 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: If thisArg is an object, it's bound to mapfn as the this-value +info: | + 6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). +flags: [async] +includes: [asyncHelpers.js] +features: [Array.fromAsync] +---*/ + +asyncTest(async () => { + const myThisValue = {}; + + await Array.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, myThisValue, "thisArg should be bound as the this-value of mapfn"); + }, myThisValue); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-omitted-sloppy.js b/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-omitted-sloppy.js new file mode 100644 index 0000000000..c3440dd99c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-omitted-sloppy.js @@ -0,0 +1,34 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + If thisArg is omitted, mapfn is called with the global object as the + this-value in sloppy mode +info: | + 6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + + OrdinaryCallBindThis, when _F_.[[ThisMode]] is ~global~, where _F_ is the + function object: + 6. Else, + a. If _thisArgument_ is *undefined* or *null*, then + i. Let _globalEnv_ be _calleeRealm_.[[GlobalEnv]]. + ii. Assert: _globalEnv_ is a Global Environment Record. + iii. Let _thisValue_ be _globalEnv_.[[GlobalThisValue]]. +flags: [async, noStrict] +includes: [asyncHelpers.js] +features: [Array.fromAsync] +---*/ + +asyncTest(async () => { + await Array.fromAsync([1, 2, 3], async function () { + assert.sameValue( + this, + globalThis, + "the global should be bound as the this-value of mapfn when thisArg is omitted" + ); + }); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-omitted-strict-strict.js b/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-omitted-strict-strict.js new file mode 100644 index 0000000000..1f78261466 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-omitted-strict-strict.js @@ -0,0 +1,30 @@ +// |reftest| async +'use strict'; +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + If thisArg is omitted, mapfn is called with undefined as the this-value in + strict mode +info: | + 6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + + In OrdinaryCallBindThis, _thisArgument_ is always bound as the this-value in + strict mode (_F_.[[ThisMode]] is ~strict~, where _F_ is the function object.) +flags: [async, onlyStrict] +includes: [asyncHelpers.js] +features: [Array.fromAsync] +---*/ + +asyncTest(async () => { + await Array.fromAsync([1, 2, 3], async function () { + assert.sameValue( + this, + undefined, + "undefined should be bound as the this-value of mapfn when thisArg is omitted" + ); + }); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-primitive-sloppy.js b/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-primitive-sloppy.js new file mode 100644 index 0000000000..244be840a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-primitive-sloppy.js @@ -0,0 +1,76 @@ +// |reftest| async +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + If thisArg is a primitive, mapfn is called with a wrapper this-value or the + global, according to the usual rules of sloppy mode +info: | + 6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + + OrdinaryCallBindThis, when _F_.[[ThisMode]] is ~global~, where _F_ is the + function object: + 6. Else, + a. If _thisArgument_ is *undefined* or *null*, then + i. Let _globalEnv_ be _calleeRealm_.[[GlobalEnv]]. + ii. Assert: _globalEnv_ is a Global Environment Record. + iii. Let _thisValue_ be _globalEnv_.[[GlobalThisValue]]. + b. Else, + i. Let _thisValue_ be ! ToObject(_thisArgument_). + ii. NOTE: ToObject produces wrapper objects using _calleeRealm_. +flags: [async, noStrict] +includes: [asyncHelpers.js] +features: [Array.fromAsync] +---*/ + +asyncTest(async () => { + await Array.fromAsync([1, 2, 3], async function () { + assert.sameValue( + this, + globalThis, + "the global should be bound as the this-value of mapfn when thisArg is undefined" + ); + }, undefined); + + await Array.fromAsync([1, 2, 3], async function () { + assert.sameValue( + this, + globalThis, + "the global should be bound as the this-value of mapfn when thisArg is null" + ); + }, null); + + await Array.fromAsync([1, 2, 3], async function () { + assert.notSameValue(this, "string", "string thisArg should not be bound as the this-value of mapfn"); + assert.sameValue(typeof this, "object", "a String wrapper object should be bound as the this-value of mapfn when thisArg is a string") + assert.sameValue(this.valueOf(), "string", "String wrapper object should have the same primitive value as thisArg"); + }, "string"); + + await Array.fromAsync([1, 2, 3], async function () { + assert.notSameValue(this, 3.1416, "number thisArg should be not bound as the this-value of mapfn"); + assert.sameValue(typeof this, "object", "a Number wrapper object should be bound as the this-value of mapfn when thisArg is a number") + assert.sameValue(this.valueOf(), 3.1416, "Number wrapper object should have the same primitive value as thisArg"); + }, 3.1416); + + await Array.fromAsync([1, 2, 3], async function () { + assert.notSameValue(this, 42n, "bigint thisArg should not be bound as the this-value of mapfn"); + assert.sameValue(typeof this, "object", "a BigInt wrapper object should be bound as the this-value of mapfn when thisArg is a bigint") + assert.sameValue(this.valueOf(), 42n, "BigInt wrapper object should have the same primitive value as thisArg"); + }, 42n); + + await Array.fromAsync([1, 2, 3], async function () { + assert.notSameValue(this, true, "boolean thisArg should not be bound as the this-value of mapfn"); + assert.sameValue(typeof this, "object", "a Boolean wrapper object should be bound as the this-value of mapfn when thisArg is a boolean") + assert.sameValue(this.valueOf(), true, "Boolean wrapper object should have the same primitive value as thisArg"); + }, true); + + const symbolThis = Symbol("symbol"); + await Array.fromAsync([1, 2, 3], async function () { + assert.notSameValue(this, symbolThis, "symbol thisArg should not be bound as the this-value of mapfn"); + assert.sameValue(typeof this, "object", "a Symbol wrapper object should be bound as the this-value of mapfn when thisArg is a symbol") + assert.sameValue(this.valueOf(), symbolThis, "Symbol wrapper object should have the same primitive value as thisArg"); + }, symbolThis); +}); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-primitive-strict-strict.js b/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-primitive-strict-strict.js new file mode 100644 index 0000000000..c66582ebde --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/thisarg-primitive-strict-strict.js @@ -0,0 +1,51 @@ +// |reftest| async +'use strict'; +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + If thisArg is a primitive, mapfn is called with it as the this-value in strict + mode +info: | + 6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + + In OrdinaryCallBindThis, _thisArgument_ is always bound as the this-value in + strict mode (_F_.[[ThisMode]] is ~strict~, where _F_ is the function object.) +flags: [async, onlyStrict] +includes: [asyncHelpers.js] +features: [Array.fromAsync] +---*/ + +asyncTest(async () => { + await Array.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, undefined, "undefined thisArg should be bound as the this-value of mapfn"); + }, undefined); + + await Array.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, null, "null thisArg should be bound as the this-value of mapfn"); + }, null); + + await Array.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, "string", "string thisArg should be bound as the this-value of mapfn"); + }, "string"); + + await Array.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, 3.1416, "number thisArg should be bound as the this-value of mapfn"); + }, 3.1416); + + await Array.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, 42n, "bigint thisArg should be bound as the this-value of mapfn"); + }, 42n); + + await Array.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, true, "boolean thisArg should be bound as the this-value of mapfn"); + }, true); + + const symbolThis = Symbol("symbol"); + await Array.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, symbolThis, "symbol thisArg should be bound as the this-value of mapfn"); + }, symbolThis); +}); diff --git a/js/src/tests/test262/built-ins/Array/is-a-constructor.js b/js/src/tests/test262/built-ins/Array/is-a-constructor.js new file mode 100644 index 0000000000..477b9c5aaa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/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: > + Array 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] +---*/ + +assert.sameValue(isConstructor(Array), true, 'isConstructor(Array) must return true'); +new Array(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-1.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-1.js new file mode 100644 index 0000000000..57a95072e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-0-1 +description: Array.isArray must exist as a function +---*/ + +var f = Array.isArray; + +assert.sameValue(typeof f, "function", 'The value of `typeof f` is expected to be "function"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-2.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-2.js new file mode 100644 index 0000000000..5de00e3075 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-2.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-0-2 +description: Array.isArray must exist as a function taking 1 parameter +---*/ + +assert.sameValue(Array.isArray.length, 1, 'The value of Array.isArray.length is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-3.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-3.js new file mode 100644 index 0000000000..a662307ad0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-3.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-0-3 +description: Array.isArray return true if its argument is an Array +---*/ + +assert.sameValue(Array.isArray([]), true, 'Array.isArray([]) must return true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-4.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-4.js new file mode 100644 index 0000000000..7d9c550665 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-4.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +description: Array.isArray return false if its argument is not an Array +---*/ + +assert.sameValue(Array.isArray(42), false, 'Array.isArray(42) must return false'); +assert.sameValue(Array.isArray(undefined), false, 'Array.isArray(undefined) must return false'); +assert.sameValue(Array.isArray(true), false, 'Array.isArray(true) must return false'); +assert.sameValue(Array.isArray("abc"), false, 'Array.isArray("abc") must return false'); +assert.sameValue(Array.isArray({}), false, 'Array.isArray({}) must return false'); +assert.sameValue(Array.isArray(null), false, 'Array.isArray(null) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-5.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-5.js new file mode 100644 index 0000000000..6af24845a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-5.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-0-5 +description: > + Array.isArray return true if its argument is an Array + (Array.prototype) +---*/ + +assert.sameValue(Array.isArray(Array.prototype), true, 'Array.isArray(Array.prototype) must return true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-6.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-6.js new file mode 100644 index 0000000000..3af98c17bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-6.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-0-6 +description: Array.isArray return true if its argument is an Array (new Array()) +---*/ + +assert.sameValue(Array.isArray(new Array(10)), true, 'Array.isArray(new Array(10)) must return true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-7.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-7.js new file mode 100644 index 0000000000..93c0e27bab --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-7.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-0-7 +description: Array.isArray returns false if its argument is not an Array +---*/ + +assert.sameValue(Array.isArray({}), false, 'Array.isArray({}) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-1.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-1.js new file mode 100644 index 0000000000..d39c16f00f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-1.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-1-1 +description: Array.isArray applied to boolean primitive +---*/ + +assert.sameValue(Array.isArray(true), false, 'Array.isArray(true) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-10.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-10.js new file mode 100644 index 0000000000..d70ca88894 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-10.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-1-10 +description: Array.isArray applied to RegExp object +---*/ + +assert.sameValue(Array.isArray(new RegExp()), false, 'Array.isArray(new RegExp()) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-11.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-11.js new file mode 100644 index 0000000000..83083bb9a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-11.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-1-11 +description: Array.isArray applied to the JSON object +---*/ + +assert.sameValue(Array.isArray(JSON), false, 'Array.isArray(JSON) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-12.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-12.js new file mode 100644 index 0000000000..b3ce684eba --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-12.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-1-12 +description: Array.isArray applied to Error object +---*/ + +assert.sameValue(Array.isArray(new SyntaxError()), false, 'Array.isArray(new SyntaxError()) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-13.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-13.js new file mode 100644 index 0000000000..5cb31026cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-13.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-1-13 +description: Array.isArray applied to Arguments object +---*/ + +var arg; + +(function fun() { + arg = arguments; +}(1, 2, 3)); + +assert.sameValue(Array.isArray(arg), false, 'Array.isArray(arguments) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-15.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-15.js new file mode 100644 index 0000000000..6564340b3f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-15.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-1-15 +description: Array.isArray applied to the global object +---*/ + +assert.sameValue(Array.isArray(this), false, 'Array.isArray(this) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-2.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-2.js new file mode 100644 index 0000000000..dc13b782a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-2.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-1-2 +description: Array.isArray applied to Boolean Object +---*/ + +assert.sameValue(Array.isArray(new Boolean(false)), false, 'Array.isArray(new Boolean(false)) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-3.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-3.js new file mode 100644 index 0000000000..cbf26a5599 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-3.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-1-3 +description: Array.isArray applied to number primitive +---*/ + +assert.sameValue(Array.isArray(5), false, 'Array.isArray(5) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-4.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-4.js new file mode 100644 index 0000000000..2df256a118 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-4.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-1-4 +description: Array.isArray applied to Number object +---*/ + +assert.sameValue(Array.isArray(new Number(-3)), false, 'Array.isArray(new Number(-3)) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-5.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-5.js new file mode 100644 index 0000000000..05d7303288 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-5.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-1-5 +description: Array.isArray applied to string primitive +---*/ + +assert.sameValue(Array.isArray("abc"), false, 'Array.isArray("abc") must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-6.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-6.js new file mode 100644 index 0000000000..1c2e9d3e18 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-6.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-1-6 +description: Array.isArray applied to String object +---*/ + +assert.sameValue(Array.isArray(new String("hello\nworld\\!")), false, 'Array.isArray(new String("hello\\nworld\\\\!")) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-7.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-7.js new file mode 100644 index 0000000000..18708528e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-7.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-1-7 +description: Array.isArray applied to Function object +---*/ + +assert.sameValue(Array.isArray(function() {}), false, 'Array.isArray(function() {}) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-8.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-8.js new file mode 100644 index 0000000000..24b0c41a58 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-8.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-1-8 +description: Array.isArray applied to the Math object +---*/ + +assert.sameValue(Array.isArray(Math), false, 'Array.isArray(Math) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-9.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-9.js new file mode 100644 index 0000000000..869f611895 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-1-9.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-1-9 +description: Array.isArray applied to Date object +---*/ + +assert.sameValue(Array.isArray(new Date()), false, 'Array.isArray(new Date()) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-2-1.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-2-1.js new file mode 100644 index 0000000000..1592f1a734 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-2-1.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-2-1 +description: Array.isArray applied to an object with an array as the prototype +---*/ + +var proto = []; +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +assert.sameValue(Array.isArray(child), false, 'Array.isArray(new Con()) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-2-2.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-2-2.js new file mode 100644 index 0000000000..8bf0e08d26 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-2-2.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-2-2 +description: > + Array.isArray applied to an object with Array.prototype as the + prototype +---*/ + +var proto = Array.prototype; +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +assert.sameValue(Array.isArray(child), false, 'Array.isArray(new Con()) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-2-3.js b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-2-3.js new file mode 100644 index 0000000000..b61e821676 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-2-3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es5id: 15.4.3.2-2-3 +description: > + Array.isArray applied to an Array-like object with length and some + indexed properties +---*/ + +assert.sameValue(Array.isArray({ + 0: 12, + 1: 9, + length: 2 +}), false, 'Array.isArray({0: 12, 1: 9, length: 2}) must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/browser.js b/js/src/tests/test262/built-ins/Array/isArray/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/isArray/descriptor.js b/js/src/tests/test262/built-ins/Array/isArray/descriptor.js new file mode 100644 index 0000000000..1c5c6ef73b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/descriptor.js @@ -0,0 +1,14 @@ +// Copyright 2017 Lyza Danger Gardner. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Testing descriptor property of Array.isArray +includes: [propertyHelper.js] +esid: sec-array.isarray +---*/ + +verifyWritable(Array, "isArray"); +verifyNotEnumerable(Array, "isArray"); +verifyConfigurable(Array, "isArray"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/name.js b/js/src/tests/test262/built-ins/Array/isArray/name.js new file mode 100644 index 0000000000..1b2ebb5e42 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.isarray +es6id: 22.1.2.2 +description: > + Array.isArray.name is "isArray". +info: | + Array.isArray ( arg ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.isArray.name, "isArray", 'The value of Array.isArray.name is expected to be "isArray"'); + +verifyNotEnumerable(Array.isArray, "name"); +verifyNotWritable(Array.isArray, "name"); +verifyConfigurable(Array.isArray, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/isArray/not-a-constructor.js new file mode 100644 index 0000000000..a72b1eb23e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/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: > + Array.isArray 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, arrow-function] +---*/ + +assert.sameValue(isConstructor(Array.isArray), false, 'isConstructor(Array.isArray) must return false'); + +assert.throws(TypeError, () => { + new Array.isArray([]); +}, 'new Array.isArray([]) throws a TypeError exception'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/proxy-revoked.js b/js/src/tests/test262/built-ins/Array/isArray/proxy-revoked.js new file mode 100644 index 0000000000..5808591738 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/proxy-revoked.js @@ -0,0 +1,30 @@ +// 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-array.isarray +es6id: 22.1.2.2 +description: Revoked proxy value produces a TypeError +info: | + 1. Return IsArray(arg). + + 7.2.2 IsArray + + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is null, + throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy] +---*/ + +var handle = Proxy.revocable([], {}); + +handle.revoke(); + +assert.throws(TypeError, function() { + Array.isArray(handle.proxy); +}, 'Array.isArray(handle.proxy) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/proxy.js b/js/src/tests/test262/built-ins/Array/isArray/proxy.js new file mode 100644 index 0000000000..fd369e07d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/proxy.js @@ -0,0 +1,32 @@ +// 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-array.isarray +es6id: 22.1.2.2 +description: Proxy of an array is treated as an array +info: | + 1. Return IsArray(arg). + + 7.2.2 IsArray + + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is null, + throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy] +---*/ + +var objectProxy = new Proxy({}, {}); +var arrayProxy = new Proxy([], {}); +var arrayProxyProxy = new Proxy(arrayProxy, {}); + +assert.sameValue(Array.isArray(objectProxy), false, 'Array.isArray(new Proxy({}, {})) must return false'); +assert.sameValue(Array.isArray(arrayProxy), true, 'Array.isArray(new Proxy([], {})) must return true'); +assert.sameValue( + Array.isArray(arrayProxyProxy), true, 'Array.isArray(new Proxy(arrayProxy, {})) must return true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/isArray/shell.js b/js/src/tests/test262/built-ins/Array/isArray/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/length.js b/js/src/tests/test262/built-ins/Array/length.js new file mode 100644 index 0000000000..16e8c44ec3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length.js @@ -0,0 +1,26 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-constructor +description: > + Array has a "length" property whose value is 1. +info: | + 22.1.1 The Array Constructor + + The length property of the Array constructor function is 1. + ... + + ES7 section 17: Unless otherwise specified, the length property of a built-in + Function object has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.length, 1, 'The value of Array.length is expected to be 1'); + +verifyNotEnumerable(Array, 'length'); +verifyNotWritable(Array, 'length'); +verifyConfigurable(Array, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-1.js b/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-1.js new file mode 100644 index 0000000000..4cb377f025 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-1.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-array-instances-length +es5id: 15.4.5.1-3.d-1 +description: > + Throw RangeError if attempt to set array length property to + 4294967296 (2**32) +---*/ + + +assert.throws(RangeError, function() { + [].length = 4294967296; +}, '[].length = 4294967296 throws a RangeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-2.js b/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-2.js new file mode 100644 index 0000000000..f899eb15b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-2.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-array-instances-length +es5id: 15.4.5.1-3.d-2 +description: > + Throw RangeError if attempt to set array length property to + 4294967297 (1+2**32) +---*/ + + +assert.throws(RangeError, function() { + [].length = 4294967297; +}, '[].length = 4294967297 throws a RangeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-3.js b/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-3.js new file mode 100644 index 0000000000..478e4560a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-3.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-array-instances-length +es5id: 15.4.5.1-3.d-3 +description: Set array length property to max value 4294967295 (2**32-1,) +---*/ + +var a = []; +a.length = 4294967295; + +assert.sameValue(a.length, 4294967295, 'The value of a.length is expected to be 4294967295'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T1.js new file mode 100644 index 0000000000..c8c9391b08 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-len +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.2.2_A1.1_T1 +description: > + Create new property of Array.prototype. When new Array object has + this property +---*/ + +Array.prototype.myproperty = 1; +var x = new Array(0); +assert.sameValue(x.myproperty, 1, 'The value of x.myproperty is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T2.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T2.js new file mode 100644 index 0000000000..b0f1321367 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-len +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.2.2_A1.1_T2 +description: Array.prototype.toString = Object.prototype.toString +---*/ + +Array.prototype.toString = Object.prototype.toString; +var x = new Array(0); +assert.sameValue(x.toString(), "[object Array]", 'x.toString() must return "[object Array]"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T3.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T3.js new file mode 100644 index 0000000000..4fcb4cfc76 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-len +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.2.2_A1.1_T3 +description: Checking use isPrototypeOf +---*/ + +assert.sameValue( + Array.prototype.isPrototypeOf(new Array(0)), + true, + 'Array.prototype.isPrototypeOf(new Array(0)) must return true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.2_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.2_T1.js new file mode 100644 index 0000000000..1e6c52e8cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.2_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-len +info: The [[Class]] property of the newly constructed object is set to "Array" +es5id: 15.4.2.2_A1.2_T1 +description: Checking use Object.prototype.toString +---*/ + +var x = new Array(0); +assert.sameValue(Object.prototype.toString.call(x), "[object Array]", 'Object.prototype.toString.call(new Array(0)) must return "[object Array]"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.1_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.1_T1.js new file mode 100644 index 0000000000..da22b03edc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-len +info: | + If the argument len is a Number and ToUint32(len) is equal to len, + then the length property of the newly constructed object is set to ToUint32(len) +es5id: 15.4.2.2_A2.1_T1 +description: Array constructor is given one argument +---*/ + +var x = new Array(0); +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); + +var x = new Array(1); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); + +var x = new Array(4294967295); +assert.sameValue(x.length, 4294967295, 'The value of x.length is expected to be 4294967295'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T1.js new file mode 100644 index 0000000000..87243a739e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T1.js @@ -0,0 +1,46 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-len +info: | + If the argument len is a Number and ToUint32(len) is not equal to len, + a RangeError exception is thrown +es5id: 15.4.2.2_A2.2_T1 +description: Use try statement. len = -1, 4294967296, 4294967297 +---*/ + +try { + new Array(-1); + throw new Test262Error('#1.1: new Array(-1) throw RangeError. Actual: ' + (new Array(-1))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +try { + new Array(4294967296); + throw new Test262Error('#2.1: new Array(4294967296) throw RangeError. Actual: ' + (new Array(4294967296))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +try { + new Array(4294967297); + throw new Test262Error('#3.1: new Array(4294967297) throw RangeError. Actual: ' + (new Array(4294967297))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T2.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T2.js new file mode 100644 index 0000000000..9785dccba0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T2.js @@ -0,0 +1,46 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-len +info: | + If the argument len is a Number and ToUint32(len) is not equal to len, + a RangeError exception is thrown +es5id: 15.4.2.2_A2.2_T2 +description: Use try statement. len = NaN, +/-Infinity +---*/ + +try { + new Array(NaN); + throw new Test262Error('#1.1: new Array(NaN) throw RangeError. Actual: ' + (new Array(NaN))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +try { + new Array(Number.POSITIVE_INFINITY); + throw new Test262Error('#2.1: new Array(Number.POSITIVE_INFINITY) throw RangeError. Actual: ' + (new Array(Number.POSITIVE_INFINITY))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +try { + new Array(Number.NEGATIVE_INFINITY); + throw new Test262Error('#3.1: new Array(Number.NEGATIVE_INFINITY) throw RangeError. Actual: ' + (new Array(Number.NEGATIVE_INFINITY))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T3.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T3.js new file mode 100644 index 0000000000..4acedfcaa0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T3.js @@ -0,0 +1,46 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-len +info: | + If the argument len is a Number and ToUint32(len) is not equal to len, + a RangeError exception is thrown +es5id: 15.4.2.2_A2.2_T3 +description: Use try statement. len = 1.5, Number.MAX_VALUE, Number.MIN_VALUE +---*/ + +try { + new Array(1.5); + throw new Test262Error('#1.1: new Array(1.5) throw RangeError. Actual: ' + (new Array(1.5))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +try { + new Array(Number.MAX_VALUE); + throw new Test262Error('#2.1: new Array(Number.MAX_VALUE) throw RangeError. Actual: ' + (new Array(Number.MAX_VALUE))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +try { + new Array(Number.MIN_VALUE); + throw new Test262Error('#3.1: new Array(Number.MIN_VALUE) throw RangeError. Actual: ' + (new Array(Number.MIN_VALUE))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T1.js new file mode 100644 index 0000000000..739b4b7537 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T1.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-len +info: | + If the argument len is not a Number, then the length property of + the newly constructed object is set to 1 and the 0 property of + the newly constructed object is set to len +es5id: 15.4.2.2_A2.3_T1 +description: Checking for null and undefined +---*/ + +var x = new Array(null); + +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], null, 'The value of x[0] is expected to be null'); + +var x = new Array(undefined); + +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T2.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T2.js new file mode 100644 index 0000000000..7f264fcd04 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T2.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-len +info: | + If the argument len is not a Number, then the length property of + the newly constructed object is set to 1 and the 0 property of + the newly constructed object is set to len +es5id: 15.4.2.2_A2.3_T2 +description: Checking for boolean primitive and Boolean object +---*/ + +var x = new Array(true); + +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], true, 'The value of x[0] is expected to be true'); + +var obj = new Boolean(false); +var x = new Array(obj); + +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T3.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T3.js new file mode 100644 index 0000000000..4e9b4ebcdc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T3.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-len +info: | + If the argument len is not a Number, then the length property of + the newly constructed object is set to 1 and the 0 property of + the newly constructed object is set to len +es5id: 15.4.2.2_A2.3_T3 +description: Checking for boolean primitive and Boolean object +---*/ + +var x = new Array("1"); + +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], "1", 'The value of x[0] is expected to be "1"'); + +var obj = new String("0"); +var x = new Array(obj); + +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T4.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T4.js new file mode 100644 index 0000000000..9bc3350428 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T4.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-len +info: | + If the argument len is not a Number, then the length property of + the newly constructed object is set to 1 and the 0 property of + the newly constructed object is set to len +es5id: 15.4.2.2_A2.3_T4 +description: Checking for Number object +---*/ + +var obj = new Number(0); +var x = new Array(obj); + +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); + +var obj = new Number(1); +var x = new Array(obj); + +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); + +var obj = new Number(4294967295); +var x = new Array(obj); + +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T5.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T5.js new file mode 100644 index 0000000000..fa903f1b4c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T5.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-len +info: | + If the argument len is not a Number, then the length property of + the newly constructed object is set to 1 and the 0 property of + the newly constructed object is set to len +es5id: 15.4.2.2_A2.3_T5 +description: Checking for Number object +---*/ + +var obj = new Number(-1); +var x = new Array(obj); + +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); + +var obj = new Number(4294967296); +var x = new Array(obj); + +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); + +var obj = new Number(4294967297); +var x = new Array(obj); + +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.4_A1.3_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.4_A1.3_T1.js new file mode 100644 index 0000000000..69898b7381 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.4_A1.3_T1.js @@ -0,0 +1,13 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-the-array-prototype-object +info: Array prototype object has a length property +es5id: 15.4.4_A1.3_T1 +description: Array.prototype.length === 0 +---*/ + +assert.sameValue(Array.prototype.length, 0, 'The value of Array.prototype.length is expected to be 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T1.js new file mode 100644 index 0000000000..771311678c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T1.js @@ -0,0 +1,47 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-exotic-objects-defineownproperty-p-desc +info: If ToUint32(length) !== ToNumber(length), throw RangeError +es5id: 15.4.5.1_A1.1_T1 +description: length in [4294967296, -1, 1.5] +---*/ + +try { + var x = []; + x.length = 4294967296; + throw new Test262Error('#1.1: x = []; x.length = 4294967296 throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +try { + x = []; + x.length = -1; + throw new Test262Error('#2.1: x = []; x.length = -1 throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +try { + x = []; + x.length = 1.5; + throw new Test262Error('#3.1: x = []; x.length = 1.5 throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T2.js b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T2.js new file mode 100644 index 0000000000..283049dbe4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T2.js @@ -0,0 +1,59 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-exotic-objects-defineownproperty-p-desc +info: If ToUint32(length) !== ToNumber(length), throw RangeError +es5id: 15.4.5.1_A1.1_T2 +description: length in [NaN, Infinity, -Infinity, undefined] +---*/ + +try { + var x = []; + x.length = NaN; + throw new Test262Error('#1.1: x = []; x.length = NaN throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +try { + x = []; + x.length = Number.POSITIVE_INFINITY; + throw new Test262Error('#2.1: x = []; x.length = Number.POSITIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +try { + x = []; + x.length = Number.NEGATIVE_INFINITY; + throw new Test262Error('#3.1: x = []; x.length = Number.NEGATIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +try { + x = []; + x.length = undefined; + throw new Test262Error('#4.1: x = []; x.length = undefined throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T1.js new file mode 100644 index 0000000000..9084747cae --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T1.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-exotic-objects-defineownproperty-p-desc +info: | + For every integer k that is less than the value of + the length property of A but not less than ToUint32(length), + if A itself has a property (not an inherited property) named ToString(k), + then delete that property +es5id: 15.4.5.1_A1.2_T1 +description: Change length of array +---*/ + +var x = [0, , 2, , 4]; +x.length = 4; +assert.sameValue(x[4], undefined, 'The value of x[4] is expected to equal undefined'); + +x.length = 3; +assert.sameValue(x[3], undefined, 'The value of x[3] is expected to equal undefined'); +assert.sameValue(x[2], 2, 'The value of x[2] is expected to be 2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T3.js b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T3.js new file mode 100644 index 0000000000..1d3d0b9911 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T3.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-exotic-objects-defineownproperty-p-desc +info: | + For every integer k that is less than the value of + the length property of A but not less than ToUint32(length), + if A itself has a property (not an inherited property) named ToString(k), + then delete that property +es5id: 15.4.5.1_A1.2_T3 +description: Checking an inherited property +---*/ + +Array.prototype[2] = 2; +var x = [0, 1]; +x.length = 3; +assert.sameValue(x.hasOwnProperty('2'), false, 'x.hasOwnProperty("2") must return false'); + +x.length = 2; +assert.sameValue(x[2], 2, 'The value of x[2] is expected to be 2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T1.js new file mode 100644 index 0000000000..711cd65564 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T1.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-exotic-objects-defineownproperty-p-desc +info: Set the value of property length of A to Uint32(length) +es5id: 15.4.5.1_A1.3_T1 +description: length is object or primitve +---*/ + +var x = []; +x.length = true; +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); + +x = [0]; +x.length = null; +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); + +x = [0]; +x.length = new Boolean(false); +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); + +x = []; +x.length = new Number(1); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); + +x = []; +x.length = "1"; +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); + +x = []; +x.length = new String("1"); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T2.js b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T2.js new file mode 100644 index 0000000000..c1b163c560 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T2.js @@ -0,0 +1,114 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-exotic-objects-defineownproperty-p-desc +info: Set the value of property length of A to Uint32(length) +es5id: 15.4.5.1_A1.3_T2 +description: Uint32 use ToNumber and ToPrimitve +---*/ + +var x = []; +x.length = { + valueOf: function() { + return 2 + } +}; +assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); + +x = []; +x.length = { + valueOf: function() { + return 2 + }, + toString: function() { + return 1 + } +}; +assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); + +x = []; +x.length = { + valueOf: function() { + return 2 + }, + toString: function() { + return {} + } +}; +assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); + +try { + x = []; + x.length = { + valueOf: function() { + return 2 + }, + toString: function() { + throw "error" + } + }; + assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} + +x = []; +x.length = { + toString: function() { + return 1 + } +}; +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); + +x = []; +x.length = { + valueOf: function() { + return {} + }, + toString: function() { + return 1 + } +} +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); + +try { + x = []; + x.length = { + valueOf: function() { + throw "error" + }, + toString: function() { + return 1 + } + }; + x.length; + throw new Test262Error('#7.1: x = []; x.length = {valueOf: function() {throw "error"}, toString: function() {return 1}}; x.length throw "error". Actual: ' + (x.length)); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} + +try { + x = []; + x.length = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + x.length; + throw new Test262Error('#8.1: x = []; x.length = {valueOf: function() {return {}}, toString: function() {return {}}} x.length throw TypeError. Actual: ' + (x.length)); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.5.2_A3_T4.js b/js/src/tests/test262/built-ins/Array/length/S15.4.5.2_A3_T4.js new file mode 100644 index 0000000000..a073a7a0ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.2_A3_T4.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-array-instances-length +info: | + If the length property is changed, every property whose name + is an array index whose value is not smaller than the new length is automatically deleted +es5id: 15.4.5.2_A3_T4 +description: > + If new length greater than the name of every property whose name + is an array index +---*/ + +var x = [0, 1, 2]; +x[4294967294] = 4294967294; +x.length = 2; + +assert.sameValue(x[0], 0, 'The value of x[0] is expected to be 0'); +assert.sameValue(x[1], 1, 'The value of x[1] is expected to be 1'); +assert.sameValue(x[2], undefined, 'The value of x[2] is expected to equal undefined'); +assert.sameValue(x[4294967294], undefined, 'The value of x[4294967294] is expected to equal undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/browser.js b/js/src/tests/test262/built-ins/Array/length/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order-set.js b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order-set.js new file mode 100644 index 0000000000..bb3acea2e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order-set.js @@ -0,0 +1,48 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: André Bargull +esid: sec-arraysetlength +description: > + [[Value]] is coerced to number before current descriptor's [[Writable]] check. +info: | + ArraySetLength ( A, Desc ) + + [...] + 3. Let newLen be ? ToUint32(Desc.[[Value]]). + 4. Let numberLen be ? ToNumber(Desc.[[Value]]). + [...] + 7. Let oldLenDesc be OrdinaryGetOwnProperty(A, "length"). + [...] + 12. If oldLenDesc.[[Writable]] is false, return false. +features: [Symbol, Symbol.toPrimitive, Reflect, Reflect.set] +includes: [compareArray.js] +---*/ + +var array = [1, 2, 3]; +var hints = []; +var length = {}; +length[Symbol.toPrimitive] = function(hint) { + hints.push(hint); + Object.defineProperty(array, "length", {writable: false}); + return 0; +}; + +assert.throws(TypeError, function() { + "use strict"; + array.length = length; +}, '`"use strict"; array.length = length` throws a TypeError exception'); +assert.compareArray(hints, ["number", "number"], 'The value of hints is expected to be ["number", "number"]'); + + +array = [1, 2, 3]; +hints = []; + +assert( + !Reflect.set(array, "length", length), + 'The value of !Reflect.set(array, "length", length) is expected to be true' +); +assert.compareArray(hints, ["number", "number"], 'The value of hints is expected to be ["number", "number"]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order.js b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order.js new file mode 100644 index 0000000000..8c0f7a97a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order.js @@ -0,0 +1,63 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: André Bargull +esid: sec-arraysetlength +description: > + [[Value]] is coerced to number before descriptor validation. +info: | + ArraySetLength ( A, Desc ) + + [...] + 3. Let newLen be ? ToUint32(Desc.[[Value]]). + 4. Let numberLen be ? ToNumber(Desc.[[Value]]). + [...] + 7. Let oldLenDesc be OrdinaryGetOwnProperty(A, "length"). + [...] + 11. If newLen ≥ oldLen, then + a. Return OrdinaryDefineOwnProperty(A, "length", newLenDesc). + + OrdinaryDefineOwnProperty ( O, P, Desc ) + + [...] + 3. Return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current). + + ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current ) + + [...] + 7. Else if IsDataDescriptor(current) and IsDataDescriptor(Desc) are both true, then + a. If current.[[Configurable]] is false and current.[[Writable]] is false, then + i. If Desc.[[Writable]] is present and Desc.[[Writable]] is true, return false. +features: [Reflect] +---*/ + +var array = [1, 2]; +var valueOfCalls = 0; +var length = { + valueOf: function() { + valueOfCalls += 1; + if (valueOfCalls !== 1) { + // skip first coercion at step 3 + Object.defineProperty(array, "length", {writable: false}); + } + return array.length; + }, +}; + +assert.throws(TypeError, function() { + Object.defineProperty(array, "length", {value: length, writable: true}); +}, 'Object.defineProperty(array, "length", {value: length, writable: true}) throws a TypeError exception'); +assert.sameValue(valueOfCalls, 2, 'The value of valueOfCalls is expected to be 2'); + + +array = [1, 2]; +valueOfCalls = 0; + +assert( + !Reflect.defineProperty(array, "length", {value: length, writable: true}), + 'The value of !Reflect.defineProperty(array, "length", {value: length, writable: true}) is expected to be true' +); +assert.sameValue(valueOfCalls, 2, 'The value of valueOfCalls is expected to be 2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-error.js b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-error.js new file mode 100644 index 0000000000..a3122b43c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-error.js @@ -0,0 +1,26 @@ +// Copyright (C) 2023 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Jordan Harband +esid: sec-arraysetlength +description: > + Setting an invalid array length throws a RangeError +info: | + ArraySetLength ( A, Desc ) + + [...] + 5. If SameValueZero(newLen, numberLen) is false, throw a RangeError exception. + [...] +---*/ + +assert.throws(RangeError, function () { + Object.defineProperty([], 'length', { value: -1, configurable: true }); +}); + +assert.throws(RangeError, function () { + // the string is intentionally "computed" here to ensure there are no optimization bugs + Object.defineProperty([], 'len' + 'gth', { value: -1, configurable: true }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-no-value-order.js b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-no-value-order.js new file mode 100644 index 0000000000..790a2705fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-no-value-order.js @@ -0,0 +1,64 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraysetlength +description: > + Ordinary descriptor validation if [[Value]] is absent. +info: | + ArraySetLength ( A, Desc ) + + 1. If Desc.[[Value]] is absent, then + a. Return OrdinaryDefineOwnProperty(A, "length", Desc). + + OrdinaryDefineOwnProperty ( O, P, Desc ) + + [...] + 3. Return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current). + + ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current ) + + [...] + 4. If current.[[Configurable]] is false, then + a. If Desc.[[Configurable]] is present and its value is true, return false. + b. If Desc.[[Enumerable]] is present and + ! SameValue(Desc.[[Enumerable]], current.[[Enumerable]]) is false, return false. + [...] + 6. Else if ! SameValue(! IsDataDescriptor(current), ! IsDataDescriptor(Desc)) is false, then + a. If current.[[Configurable]] is false, return false. + [...] + 7. Else if IsDataDescriptor(current) and IsDataDescriptor(Desc) are both true, then + a. If current.[[Configurable]] is false and current.[[Writable]] is false, then + i. If Desc.[[Writable]] is present and Desc.[[Writable]] is true, return false. +features: [Reflect] +---*/ + +assert.throws(TypeError, function() { + Object.defineProperty([], "length", {configurable: true}); +}, 'Object.defineProperty([], "length", {configurable: true}) throws a TypeError exception'); + +assert( + !Reflect.defineProperty([], "length", {enumerable: true}), + 'The value of !Reflect.defineProperty([], "length", {enumerable: true}) is expected to be true' +); + +assert.throws(TypeError, function() { + Object.defineProperty([], "length", { + get: function() { + throw new Test262Error("[[Get]] shouldn't be called"); + }, + }); +}, 'Object.defineProperty([], "length", {get: function() {throw new Test262Error("[[Get]] shouldn"t be called");},}) throws a TypeError exception'); + +assert( + !Reflect.defineProperty([], "length", {set: function(_value) {}}), + 'The value of !Reflect.defineProperty([], "length", {set: function(_value) {}}) is expected to be true' +); + +var array = []; +Object.defineProperty(array, "length", {writable: false}); +assert.throws(TypeError, function() { + Object.defineProperty(array, "length", {writable: true}); +}, 'Object.defineProperty(array, "length", {writable: true}) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-order.js b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-order.js new file mode 100644 index 0000000000..9cdb0d3860 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-order.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraysetlength +description: > + [[Value]] is checked for overflow before descriptor validation. +info: | + ArraySetLength ( A, Desc ) + + [...] + 3. Let newLen be ? ToUint32(Desc.[[Value]]). + 4. Let numberLen be ? ToNumber(Desc.[[Value]]). + 5. If newLen ≠ numberLen, throw a RangeError exception. +---*/ + +assert.throws(RangeError, function() { + Object.defineProperty([], "length", {value: -1, configurable: true}); +}, 'Object.defineProperty([], "length", {value: -1, configurable: true}) throws a RangeError exception'); + +assert.throws(RangeError, function() { + Object.defineProperty([], "length", {value: NaN, enumerable: true}); +}, 'Object.defineProperty([], "length", {value: NaN, enumerable: true}) throws a RangeError exception'); + +var array = []; +Object.defineProperty(array, "length", {writable: false}); +assert.throws(RangeError, function() { + Object.defineProperty(array, "length", {value: Number.MAX_SAFE_INTEGER, writable: true}); +}, 'Object.defineProperty(array, "length", {value: Number.MAX_SAFE_INTEGER, writable: true}) throws a RangeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-realm.js b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-realm.js new file mode 100644 index 0000000000..67656c5f30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-realm.js @@ -0,0 +1,23 @@ +// 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-array-exotic-objects-defineownproperty-p-desc +es6id: 9.4.2.1 +description: > + Error when setting a length larger than 2**32 (honoring the Realm of the + current execution context) +info: | + [...] + 2. If P is "length", then + a. Return ? ArraySetLength(A, Desc). +features: [cross-realm] +---*/ + +var OArray = $262.createRealm().global.Array; +var array = new OArray(); + +assert.throws(RangeError, function() { + array.length = 4294967296; +}, 'array.length = 4294967296 throws a RangeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length/shell.js b/js/src/tests/test262/built-ins/Array/length/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/name.js b/js/src/tests/test262/built-ins/Array/name.js new file mode 100644 index 0000000000..621154b510 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/name.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-constructor +description: > + The "name" property of Array +info: | + 17 ECMAScript Standard Built-in Objects + + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value is a + String. Unless otherwise specified, this value is the name that is given to + the function in this specification. + + [...] + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.name, 'Array', 'The value of Array.name is expected to be "Array"'); + +verifyNotEnumerable(Array, 'name'); +verifyNotWritable(Array, 'name'); +verifyConfigurable(Array, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/browser.js b/js/src/tests/test262/built-ins/Array/of/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/of/construct-this-with-the-number-of-arguments.js b/js/src/tests/test262/built-ins/Array/of/construct-this-with-the-number-of-arguments.js new file mode 100644 index 0000000000..546cb95348 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/construct-this-with-the-number-of-arguments.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-array.of +es6id: 22.1.2.3 +description: Passes the number of arguments to the constructor it calls. +info: | + Array.of ( ...items ) + + 1. Let len be the actual number of arguments passed to this function. + 2. Let items be the List of arguments passed to this function. + 3. Let C be the this value. + 4. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + ... +---*/ + +var len; +var hits = 0; + +function C(length) { + len = length; + hits++; +} + +Array.of.call(C); +assert.sameValue(len, 0, 'The value of len is expected to be 0'); +assert.sameValue(hits, 1, 'The value of hits is expected to be 1'); + +Array.of.call(C, 'a', 'b') +assert.sameValue(len, 2, 'The value of len is expected to be 2'); +assert.sameValue(hits, 2, 'The value of hits is expected to be 2'); + +Array.of.call(C, false, null, undefined); +assert.sameValue( + len, 3, + 'The value of len is expected to be 3' +); +assert.sameValue(hits, 3, 'The value of hits is expected to be 3'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/creates-a-new-array-from-arguments.js b/js/src/tests/test262/built-ins/Array/of/creates-a-new-array-from-arguments.js new file mode 100644 index 0000000000..09ef45b6da --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/creates-a-new-array-from-arguments.js @@ -0,0 +1,47 @@ +// Copyright (c) 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +/*--- +esid: sec-array.of +es6id: 22.1.2.3 +description: > + Array.of method creates a new Array with a variable number of arguments. +info: | + 22.1.2.3 Array.of ( ...items ) + + ... + 7. Let k be 0. + 8. Repeat, while k < len + a. Let kValue be items[k]. + b. Let Pk be ToString(k). + c. Let defineStatus be CreateDataPropertyOrThrow(A,Pk, kValue). + d. ReturnIfAbrupt(defineStatus). + e. Increase k by 1. + 9. Let setStatus be Set(A, "length", len, true). + 10. ReturnIfAbrupt(setStatus). + 11. Return A. +---*/ + +var a1 = Array.of('Mike', 'Rick', 'Leo'); +assert.sameValue( + a1.length, 3, + 'The value of a1.length is expected to be 3' +); +assert.sameValue(a1[0], 'Mike', 'The value of a1[0] is expected to be "Mike"'); +assert.sameValue(a1[1], 'Rick', 'The value of a1[1] is expected to be "Rick"'); +assert.sameValue(a1[2], 'Leo', 'The value of a1[2] is expected to be "Leo"'); + +var a2 = Array.of(undefined, false, null, undefined); +assert.sameValue( + a2.length, 4, + 'The value of a2.length is expected to be 4' +); +assert.sameValue(a2[0], undefined, 'The value of a2[0] is expected to equal undefined'); +assert.sameValue(a2[1], false, 'The value of a2[1] is expected to be false'); +assert.sameValue(a2[2], null, 'The value of a2[2] is expected to be null'); +assert.sameValue(a2[3], undefined, 'The value of a2[3] is expected to equal undefined'); + +var a3 = Array.of(); +assert.sameValue(a3.length, 0, 'The value of a3.length is expected to be 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/does-not-use-prototype-properties.js b/js/src/tests/test262/built-ins/Array/of/does-not-use-prototype-properties.js new file mode 100644 index 0000000000..6f08da1f92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/does-not-use-prototype-properties.js @@ -0,0 +1,32 @@ +// Copyright (c) 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +/*--- +esid: sec-array.of +es6id: 22.1.2.3 +description: Array.of does not use prototype properties for arguments. +info: | + It defines elements rather than assigning to them. +---*/ + +Object.defineProperty(Array.prototype, "0", { + set: function(v) { + throw new Test262Error('Should define own properties'); + } +}); + +var arr = Array.of(true); +assert.sameValue(arr[0], true, 'The value of arr[0] is expected to be true'); + +function Custom() {} + +Object.defineProperty(Custom.prototype, "0", { + set: function(v) { + throw new Test262Error('Should define own properties'); + } +}); + +var custom = Array.of.call(Custom, true); +assert.sameValue(custom[0], true, 'The value of custom[0] is expected to be true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/does-not-use-set-for-indices.js b/js/src/tests/test262/built-ins/Array/of/does-not-use-set-for-indices.js new file mode 100644 index 0000000000..7461aef192 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/does-not-use-set-for-indices.js @@ -0,0 +1,38 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.of +description: > + Non-writable properties are overwritten by CreateDataProperty. + (result object's "0" is non-writable) +info: | + Array.of ( ...items ) + + [...] + 7. Repeat, while k < len + [...] + c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue). + [...] +includes: [propertyHelper.js] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + value: 1, + writable: false, + enumerable: false, + configurable: true, + }); +}; + +var res = Array.of.call(A, 2); + +verifyProperty(res, "0", { + value: 2, + writable: true, + enumerable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/length.js b/js/src/tests/test262/built-ins/Array/of/length.js new file mode 100644 index 0000000000..f77c48b768 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/length.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-array.of +description: > + Array.of.length value and property descriptor +info: | + Array.of ( ...items ) + + The length property of the of function is 0. +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.of.length, 0, + 'The value of Array.of.length is expected to be 0' +); + +verifyNotEnumerable(Array.of, 'length'); +verifyNotWritable(Array.of, 'length'); +verifyConfigurable(Array.of, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/name.js b/js/src/tests/test262/built-ins/Array/of/name.js new file mode 100644 index 0000000000..842dd1ad11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/name.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-array.of +description: > + Array.of.name value and property descriptor +info: | + Array.of ( ...items ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.of.name, 'of', + 'The value of Array.of.name is expected to be "of"' +); + +verifyNotEnumerable(Array.of, 'name'); +verifyNotWritable(Array.of, 'name'); +verifyConfigurable(Array.of, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/of/not-a-constructor.js new file mode 100644 index 0000000000..a9f9221010 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/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: > + Array.of 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, arrow-function] +---*/ + +assert.sameValue(isConstructor(Array.of), false, 'isConstructor(Array.of) must return false'); + +assert.throws(TypeError, () => { + new Array.of(1); +}, '`new Array.of(1)` throws a TypeError exception'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/of.js b/js/src/tests/test262/built-ins/Array/of/of.js new file mode 100644 index 0000000000..8dee2737ce --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/of.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-array.of +description: > + Array.of property descriptor +info: | + Array.of ( ...items ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Array, 'of'); +verifyWritable(Array, 'of'); +verifyConfigurable(Array, 'of'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/Array/of/proto-from-ctor-realm.js new file mode 100644 index 0000000000..e2bdcca1e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/proto-from-ctor-realm.js @@ -0,0 +1,35 @@ +// 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-array.of +description: Default [[Prototype]] value derived from realm of the constructor +info: | + [...] + 4. If IsConstructor(C) is true, then + a. Let A be ? Construct(C, « len »). + [...] + + 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] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var a = Array.of.call(C, 1, 2, 3); + +assert.sameValue( + Object.getPrototypeOf(a), + other.Object.prototype, + 'Object.getPrototypeOf(Array.of.call(C, 1, 2, 3)) returns other.Object.prototype' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/return-a-custom-instance.js b/js/src/tests/test262/built-ins/Array/of/return-a-custom-instance.js new file mode 100644 index 0000000000..88510b9c7d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/return-a-custom-instance.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-array.of +description: > + Returns an instance from a custom constructor. +info: | + Array.of ( ...items ) + + ... + 4. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + ... + 11. Return A. +---*/ + +function Coop() {} + +var coop = Array.of.call(Coop, 'Mike', 'Rick', 'Leo'); + +assert.sameValue( + coop.length, 3, + 'The value of coop.length is expected to be 3' +); +assert.sameValue( + coop[0], 'Mike', + 'The value of coop[0] is expected to be "Mike"' +); +assert.sameValue( + coop[1], 'Rick', + 'The value of coop[1] is expected to be "Rick"' +); +assert.sameValue( + coop[2], 'Leo', + 'The value of coop[2] is expected to be "Leo"' +); +assert(coop instanceof Coop, 'The result of evaluating (coop instanceof Coop) is expected to be true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/return-a-new-array-object.js b/js/src/tests/test262/built-ins/Array/of/return-a-new-array-object.js new file mode 100644 index 0000000000..a344f7aa34 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/return-a-new-array-object.js @@ -0,0 +1,42 @@ +// 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-array.of +description: > + Returns a new Array. +info: | + Array.of ( ...items ) + + 1. Let len be the actual number of arguments passed to this function. + 2. Let items be the List of arguments passed to this function. + 3. Let C be the this value. + 4. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 5. Else, + b. Let A be ArrayCreate(len). + ... + 11. Return A. +---*/ + +var result = Array.of(); +assert(result instanceof Array, 'The result of evaluating (result instanceof Array) is expected to be true'); + +result = Array.of.call(undefined); +assert( + result instanceof Array, + 'The result of evaluating (result instanceof Array) is expected to be true' +); + +result = Array.of.call(Math.cos); +assert( + result instanceof Array, + 'The result of evaluating (result instanceof Array) is expected to be true' +); + +result = Array.of.call(Math.cos.bind(Math)); +assert( + result instanceof Array, + 'The result of evaluating (result instanceof Array) is expected to be true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/return-abrupt-from-contructor.js b/js/src/tests/test262/built-ins/Array/of/return-abrupt-from-contructor.js new file mode 100644 index 0000000000..3eee722071 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/return-abrupt-from-contructor.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-array.of +description: > + Return abrupt from this' constructor +info: | + Array.of ( ...items ) + + 1. Let len be the actual number of arguments passed to this function. + 2. Let items be the List of arguments passed to this function. + 3. Let C be the this value. + 4. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 5. Else, + b. Let A be ArrayCreate(len). + 6. ReturnIfAbrupt(A). + ... +---*/ + +function T() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + Array.of.call(T); +}, 'Array.of.call(T) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/return-abrupt-from-data-property-using-proxy.js b/js/src/tests/test262/built-ins/Array/of/return-abrupt-from-data-property-using-proxy.js new file mode 100644 index 0000000000..de60c318dc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/return-abrupt-from-data-property-using-proxy.js @@ -0,0 +1,40 @@ +// 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-array.of +description: > + Return abrupt from Data Property creation +info: | + Array.of ( ...items ) + + ... + 7. Let k be 0. + 8. Repeat, while k < len + a. Let kValue be items[k]. + b. Let Pk be ToString(k). + c. Let defineStatus be CreateDataPropertyOrThrow(A,Pk, kValue). + d. ReturnIfAbrupt(defineStatus). + ... + + 7.3.6 CreateDataPropertyOrThrow (O, P, V) + + ... + 3. Let success be CreateDataProperty(O, P, V). + 4. ReturnIfAbrupt(success). + ... +features: [Proxy] +---*/ + +function T() { + return new Proxy({}, { + defineProperty: function() { + throw new Test262Error(); + } + }); +} + +assert.throws(Test262Error, function() { + Array.of.call(T, 'Bob'); +}, 'Array.of.call(T, "Bob") throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/return-abrupt-from-data-property.js b/js/src/tests/test262/built-ins/Array/of/return-abrupt-from-data-property.js new file mode 100644 index 0000000000..de7f8acc75 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/return-abrupt-from-data-property.js @@ -0,0 +1,48 @@ +// 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-array.of +description: > + Return abrupt from Data Property creation +info: | + Array.of ( ...items ) + + ... + 7. Let k be 0. + 8. Repeat, while k < len + a. Let kValue be items[k]. + b. Let Pk be ToString(k). + c. Let defineStatus be CreateDataPropertyOrThrow(A,Pk, kValue). + d. ReturnIfAbrupt(defineStatus). + ... + + 7.3.6 CreateDataPropertyOrThrow (O, P, V) + + ... + 3. Let success be CreateDataProperty(O, P, V). + 4. ReturnIfAbrupt(success). + 5. If success is false, throw a TypeError exception. + ... +---*/ + +function T1() { + Object.preventExtensions(this); +} + +assert.throws(TypeError, function() { + Array.of.call(T1, 'Bob'); +}, 'Array.of.call(T1, "Bob") throws a TypeError exception'); + +function T2() { + Object.defineProperty(this, 0, { + configurable: false, + writable: true, + enumerable: true + }); +} + +assert.throws(TypeError, function() { + Array.of.call(T2, 'Bob'); +}, 'Array.of.call(T2, "Bob") throws a TypeError exception') + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/return-abrupt-from-setting-length.js b/js/src/tests/test262/built-ins/Array/of/return-abrupt-from-setting-length.js new file mode 100644 index 0000000000..f4dd67769f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/return-abrupt-from-setting-length.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-array.of +description: > + Return abrupt from setting the length property. +info: | + Array.of ( ...items ) + + ... + 9. Let setStatus be Set(A, "length", len, true). + 10. ReturnIfAbrupt(setStatus). + ... +---*/ + +function T() { + Object.defineProperty(this, 'length', { + set: function() { + throw new Test262Error(); + } + }); +} + +assert.throws(Test262Error, function() { + Array.of.call(T); +}, 'Array.of.call(T) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/sets-length.js b/js/src/tests/test262/built-ins/Array/of/sets-length.js new file mode 100644 index 0000000000..2b651a4068 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/sets-length.js @@ -0,0 +1,38 @@ +// 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-array.of +description: > + Calls the length setter if available +info: | + Array.of ( ...items ) + + ... + 9. Let setStatus be Set(A, "length", len, true). + ... +---*/ + +var hits = 0; +var value; +var _this_; + +function Pack() { + Object.defineProperty(this, "length", { + set: function(len) { + hits++; + value = len; + _this_ = this; + } + }); +} + +var result = Array.of.call(Pack, 'wolves', 'cards', 'cigarettes', 'lies'); + +assert.sameValue(hits, 1, 'The value of hits is expected to be 1'); +assert.sameValue( + value, 4, + 'The value of value is expected to be 4' +); +assert.sameValue(_this_, result, 'The value of _this_ is expected to equal the value of result'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/shell.js b/js/src/tests/test262/built-ins/Array/of/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prop-desc.js b/js/src/tests/test262/built-ins/Array/prop-desc.js new file mode 100644 index 0000000000..8a219660fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prop-desc.js @@ -0,0 +1,27 @@ +// Copyright (C) 2019 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array-constructor +description: > + Property descriptor of Array +info: | + 22.1.1 The Array Constructor + + * is the initial value of the Array property of the global object. + + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyProperty(this, 'Array', { + value: Array, + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/property-cast-boolean-primitive.js b/js/src/tests/test262/built-ins/Array/property-cast-boolean-primitive.js new file mode 100644 index 0000000000..9be0514491 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/property-cast-boolean-primitive.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T1 +description: Checking for boolean primitive +---*/ + +var x = []; + +x[true] = 1; +assert.sameValue(x[1], undefined, 'The value of x[1] is expected to equal undefined'); +assert.sameValue(x["true"], 1, 'The value of x["true"] is expected to be 1'); + +x[false] = 0; +assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined'); +assert.sameValue(x["false"], 0, 'The value of x["false"] is expected to be 0') + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/property-cast-nan-infinity.js b/js/src/tests/test262/built-ins/Array/property-cast-nan-infinity.js new file mode 100644 index 0000000000..00333c25f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/property-cast-nan-infinity.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T2 +description: Checking for number primitive +---*/ + +var x = []; + +x[NaN] = 1; +assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined'); +assert.sameValue(x["NaN"], 1, 'The value of x["NaN"] is expected to be 1'); + +var y = []; +y[Number.POSITIVE_INFINITY] = 1; +assert.sameValue(y[0], undefined, 'The value of y[0] is expected to equal undefined'); +assert.sameValue(y["Infinity"], 1, 'The value of y["Infinity"] is expected to be 1'); + +var z = []; +z[Number.NEGATIVE_INFINITY] = 1; +assert.sameValue(z[0], undefined, 'The value of z[0] is expected to equal undefined'); +assert.sameValue(z["-Infinity"], 1, 'The value of z["-Infinity"] is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/property-cast-number.js b/js/src/tests/test262/built-ins/Array/property-cast-number.js new file mode 100644 index 0000000000..3e49e4c49a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/property-cast-number.js @@ -0,0 +1,40 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T3 +description: Checking for number primitive +---*/ + +var x = []; +x[4294967296] = 1; +assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined'); +assert.sameValue(x["4294967296"], 1, 'The value of x["4294967296"] is expected to be 1'); + +var y = []; +y[4294967297] = 1; +if (y[1] !== undefined) { + throw new Test262Error('#3: y = []; y[4294967297] = 1; y[1] === undefined. Actual: ' + (y[1])); +} + +//CHECK#4 +if (y["4294967297"] !== 1) { + throw new Test262Error('#4: y = []; y[4294967297] = 1; y["4294967297"] === 1. Actual: ' + (y["4294967297"])); +} + +//CHECK#5 +var z = []; +z[1.1] = 1; +if (z[1] !== undefined) { + throw new Test262Error('#5: z = []; z[1.1] = 1; z[1] === undefined. Actual: ' + (z[1])); +} + +//CHECK#6 +if (z["1.1"] !== 1) { + throw new Test262Error('#6: z = []; z[1.1] = 1; z["1.1"] === 1. Actual: ' + (z["1.1"])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/proto-from-ctor-realm-one.js b/js/src/tests/test262/built-ins/Array/proto-from-ctor-realm-one.js new file mode 100644 index 0000000000..4ebc31467c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/proto-from-ctor-realm-one.js @@ -0,0 +1,56 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-len +description: Default [[Prototype]] value derived from realm of the NewTarget. +info: | + Array ( len ) + + ... + 3. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. + 4. Let proto be ? GetPrototypeFromConstructor(newTarget, "%Array.prototype%"). + 5. Let array be ! ArrayCreate(0, proto). + ... + 9. Return array. + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +features: [cross-realm, Reflect, Symbol] +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var arr; + +newTarget.prototype = undefined; +arr = Reflect.construct(Array, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, [1], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = null; +arr = Reflect.construct(Array, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, [1], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = true; +arr = Reflect.construct(Array, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, [1], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = ''; +arr = Reflect.construct(Array, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, [1], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = Symbol(); +arr = Reflect.construct(Array, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, [1], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = 0; +arr = Reflect.construct(Array, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, [1], newTarget)) returns other.Array.prototype'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/proto-from-ctor-realm-two.js b/js/src/tests/test262/built-ins/Array/proto-from-ctor-realm-two.js new file mode 100644 index 0000000000..692709d5b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/proto-from-ctor-realm-two.js @@ -0,0 +1,56 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-items +description: Default [[Prototype]] value derived from realm of the NewTarget. +info: | + Array ( ...items ) + + ... + 3. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. + 4. Let proto be ? GetPrototypeFromConstructor(newTarget, "%Array.prototype%"). + 5. Let array be ? ArrayCreate(numberOfArgs, proto). + ... + 10. Return array. + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +features: [cross-realm, Reflect, Symbol] +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var arr; + +newTarget.prototype = undefined; +arr = Reflect.construct(Array, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, ["a", "b"], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = null; +arr = Reflect.construct(Array, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, ["a", "b"], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = false; +arr = Reflect.construct(Array, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, ["a", "b"], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = ''; +arr = Reflect.construct(Array, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, ["a", "b"], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = Symbol(); +arr = Reflect.construct(Array, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, ["a", "b"], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = -1; +arr = Reflect.construct(Array, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, ["a", "b"], newTarget)) returns other.Array.prototype'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/proto-from-ctor-realm-zero.js b/js/src/tests/test262/built-ins/Array/proto-from-ctor-realm-zero.js new file mode 100644 index 0000000000..09c458336c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/proto-from-ctor-realm-zero.js @@ -0,0 +1,54 @@ +// 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-array-constructor-array +description: Default [[Prototype]] value derived from realm of the NewTarget. +info: | + Array ( ) + + ... + 3. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. + 4. Let proto be ? GetPrototypeFromConstructor(newTarget, "%Array.prototype%"). + 5. Return ! ArrayCreate(0, proto). + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +features: [cross-realm, Reflect, Symbol] +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var arr; + +newTarget.prototype = undefined; +arr = Reflect.construct(Array, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, [], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = null; +arr = Reflect.construct(Array, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, [], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = true; +arr = Reflect.construct(Array, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, [], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = 'str'; +arr = Reflect.construct(Array, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, [], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = Symbol(); +arr = Reflect.construct(Array, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, [], newTarget)) returns other.Array.prototype'); + +newTarget.prototype = 1; +arr = Reflect.construct(Array, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'Object.getPrototypeOf(Reflect.construct(Array, [], newTarget)) returns other.Array.prototype'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/proto.js b/js/src/tests/test262/built-ins/Array/proto.js new file mode 100644 index 0000000000..1d26d846c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/proto.js @@ -0,0 +1,21 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-the-array-constructor +description: > + The prototype of the Array constructor is the intrinsic object %FunctionPrototype%. +info: | + 22.1.2 Properties of the Array Constructor + + The value of the [[Prototype]] internal slot of the Array constructor is the + intrinsic object %FunctionPrototype%. +---*/ + +assert.sameValue( + Object.getPrototypeOf(Array), + Function.prototype, + 'Object.getPrototypeOf(Array) returns Function.prototype' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator.js b/js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator.js new file mode 100644 index 0000000000..a8335adc13 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator.js @@ -0,0 +1,22 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +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 Array.prototype.values property. + + Per ES6 section 17, the method should exist on the Array prototype, and it + should be writable and configurable, but not enumerable. +includes: [propertyHelper.js] +features: [Symbol.iterator] +esid: sec-array.prototype-@@iterator +---*/ + +assert.sameValue(Array.prototype[Symbol.iterator], Array.prototype.values); +verifyNotEnumerable(Array.prototype, Symbol.iterator); +verifyWritable(Array.prototype, Symbol.iterator); +verifyConfigurable(Array.prototype, Symbol.iterator); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator/browser.js b/js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator/not-a-constructor.js new file mode 100644 index 0000000000..5d7c96289e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/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: > + Array.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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype[Symbol.iterator]), + false, + 'isConstructor(Array.prototype[Symbol.iterator]) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype[Symbol.iterator](); +}, '`new Array.prototype[Symbol.iterator]()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator/shell.js b/js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/array-find-from-last.js b/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/array-find-from-last.js new file mode 100644 index 0000000000..fae0d595c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/array-find-from-last.js @@ -0,0 +1,33 @@ +// Copyright (C) 2022 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype-@@unscopables +description: > + Initial value of `Symbol.unscopables` property +info: | + 22.1.3.32 Array.prototype [ @@unscopables ] + + ... + 7. Perform CreateDataProperty(unscopableList, "findLast", true). + 8. Perform CreateDataProperty(unscopableList, "findLastIndex", true). + ... + +includes: [propertyHelper.js] +features: [Symbol.unscopables, array-find-from-last] +---*/ + +var unscopables = Array.prototype[Symbol.unscopables]; + +assert.sameValue(Object.getPrototypeOf(unscopables), null); + +assert.sameValue(unscopables.findLast, true, '`findLast` property value'); +verifyEnumerable(unscopables, 'findLast'); +verifyWritable(unscopables, 'findLast'); +verifyConfigurable(unscopables, 'findLast'); + +assert.sameValue(unscopables.findLastIndex, true, '`findLastIndex` property value'); +verifyEnumerable(unscopables, 'findLastIndex'); +verifyWritable(unscopables, 'findLastIndex'); +verifyConfigurable(unscopables, 'findLastIndex'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/browser.js b/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js b/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js new file mode 100644 index 0000000000..f7dfc87b02 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype-@@unscopables +description: > + Initial value of `Symbol.unscopables` property +info: | + 22.1.3.32 Array.prototype [ @@unscopables ] + + ... + 12. Perform ! CreateDataPropertyOrThrow(unscopableList, "toReversed", true). + 13. Perform ! CreateDataPropertyOrThrow(unscopableList, "toSorted", true). + 14. Perform ! CreateDataPropertyOrThrow(unscopableList, "toSpliced", true). + ... +includes: [propertyHelper.js] +features: [Symbol.unscopables, change-array-by-copy] +---*/ + +var unscopables = Array.prototype[Symbol.unscopables]; + +for (const unscopable of ["toReversed", "toSorted", "toSpliced"]) { + verifyProperty(unscopables, unscopable, { + value: true, + writable: true, + configurable: true + }) +}; + +assert(!Object.prototype.hasOwnProperty.call(unscopables, "with"), "does not have `with`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/prop-desc.js new file mode 100644 index 0000000000..0d554345ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 Mike Pennisi. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype-@@unscopables +description: > + Property descriptor for initial value of `Symbol.unscopables` property +info: | + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.unscopables] +---*/ + +verifyNotEnumerable(Array.prototype, Symbol.unscopables); +verifyNotWritable(Array.prototype, Symbol.unscopables); +verifyConfigurable(Array.prototype, Symbol.unscopables); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/shell.js b/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/value.js b/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/value.js new file mode 100644 index 0000000000..3bd5e4fad8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/value.js @@ -0,0 +1,82 @@ +// Copyright (C) 2015 Mike Pennisi. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype-@@unscopables +description: > + Initial value of `Symbol.unscopables` property +info: | + 22.1.3.32 Array.prototype [ @@unscopables ] + + 1. Let unscopableList be ObjectCreate(null). + 2. Perform CreateDataProperty(unscopableList, "copyWithin", true). + 3. Perform CreateDataProperty(unscopableList, "entries", true). + 4. Perform CreateDataProperty(unscopableList, "fill", true). + 5. Perform CreateDataProperty(unscopableList, "find", true). + 6. Perform CreateDataProperty(unscopableList, "findIndex", true). + 7. Perform CreateDataProperty(unscopableList, "flat", true). + 8. Perform CreateDataProperty(unscopableList, "flatMap", true). + 9. Perform CreateDataProperty(unscopableList, "includes", true). + 10. Perform CreateDataProperty(unscopableList, "keys", true). + 11. Perform CreateDataProperty(unscopableList, "values", true). + 12. Assert: Each of the above calls returns true. + 13. Return unscopableList. + +includes: [propertyHelper.js] +features: [Symbol.unscopables] +---*/ + +var unscopables = Array.prototype[Symbol.unscopables]; + +assert.sameValue(Object.getPrototypeOf(unscopables), null); + +assert.sameValue(unscopables.copyWithin, true, '`copyWithin` property value'); +verifyEnumerable(unscopables, 'copyWithin'); +verifyWritable(unscopables, 'copyWithin'); +verifyConfigurable(unscopables, 'copyWithin'); + +assert.sameValue(unscopables.entries, true, '`entries` property value'); +verifyEnumerable(unscopables, 'entries'); +verifyWritable(unscopables, 'entries'); +verifyConfigurable(unscopables, 'entries'); + +assert.sameValue(unscopables.fill, true, '`fill` property value'); +verifyEnumerable(unscopables, 'fill'); +verifyWritable(unscopables, 'fill'); +verifyConfigurable(unscopables, 'fill'); + +assert.sameValue(unscopables.find, true, '`find` property value'); +verifyEnumerable(unscopables, 'find'); +verifyWritable(unscopables, 'find'); +verifyConfigurable(unscopables, 'find'); + +assert.sameValue(unscopables.findIndex, true, '`findIndex` property value'); +verifyEnumerable(unscopables, 'findIndex'); +verifyWritable(unscopables, 'findIndex'); +verifyConfigurable(unscopables, 'findIndex'); + +assert.sameValue(unscopables.flat, true, '`flat` property value'); +verifyEnumerable(unscopables, 'flat'); +verifyWritable(unscopables, 'flat'); +verifyConfigurable(unscopables, 'flat'); + +assert.sameValue(unscopables.flatMap, true, '`flatMap` property value'); +verifyEnumerable(unscopables, 'flatMap'); +verifyWritable(unscopables, 'flatMap'); +verifyConfigurable(unscopables, 'flatMap'); + +assert.sameValue(unscopables.includes, true, '`includes` property value'); +verifyEnumerable(unscopables, 'includes'); +verifyWritable(unscopables, 'includes'); +verifyConfigurable(unscopables, 'includes'); + +assert.sameValue(unscopables.keys, true, '`keys` property value'); +verifyEnumerable(unscopables, 'keys'); +verifyWritable(unscopables, 'keys'); +verifyConfigurable(unscopables, 'keys'); + +assert.sameValue(unscopables.values, true, '`values` property value'); +verifyEnumerable(unscopables, 'values'); +verifyWritable(unscopables, 'values'); +verifyConfigurable(unscopables, 'values'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/at/browser.js b/js/src/tests/test262/built-ins/Array/prototype/at/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/at/index-argument-tointeger.js b/js/src/tests/test262/built-ins/Array/prototype/at/index-argument-tointeger.js new file mode 100644 index 0000000000..3d5e2e9392 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/index-argument-tointeger.js @@ -0,0 +1,33 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.at +description: > + Property type and descriptor. +info: | + Array.prototype.at( index ) + + Let relativeIndex be ? ToInteger(index). + +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof Array.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); + +let valueOfCallCount = 0; +let index = { + valueOf() { + valueOfCallCount++; + return 1; + } +}; + +let a = [0,1,2,3]; + +assert.sameValue(a.at(index), 1, 'a.at({valueOf() {valueOfCallCount++; return 1;}}) must return 1'); +assert.sameValue(valueOfCallCount, 1, 'The value of valueOfCallCount is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js b/js/src/tests/test262/built-ins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js new file mode 100644 index 0000000000..224f4a2cfb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.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-array.prototype.at +description: > + Property type and descriptor. +info: | + Array.prototype.at( index ) + + Let relativeIndex be ? ToInteger(index). + +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof Array.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); + +let a = [0,1,2,3]; + +assert.throws(TypeError, () => { + a.at(Symbol()); +}, 'a.at(Symbol()) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/at/index-non-numeric-argument-tointeger.js b/js/src/tests/test262/built-ins/Array/prototype/at/index-non-numeric-argument-tointeger.js new file mode 100644 index 0000000000..c312b67904 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/index-non-numeric-argument-tointeger.js @@ -0,0 +1,32 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.at +description: > + Property type and descriptor. +info: | + Array.prototype.at( index ) + + Let relativeIndex be ? ToInteger(index). + +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof Array.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); + +let a = [0,1,2,3]; + +assert.sameValue(a.at(false), 0, 'a.at(false) must return 0'); +assert.sameValue(a.at(null), 0, 'a.at(null) must return 0'); +assert.sameValue(a.at(undefined), 0, 'a.at(undefined) must return 0'); +assert.sameValue(a.at(""), 0, 'a.at("") must return 0'); +assert.sameValue(a.at(function() {}), 0, 'a.at(function() {}) must return 0'); +assert.sameValue(a.at([]), 0, 'a.at([]) must return 0'); + +assert.sameValue(a.at(true), 1, 'a.at(true) must return 1'); +assert.sameValue(a.at("1"), 1, 'a.at("1") must return 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/at/length.js b/js/src/tests/test262/built-ins/Array/prototype/at/length.js new file mode 100644 index 0000000000..219f329eb4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.at +description: > + Array.prototype.at.length value and descriptor. +info: | + Array.prototype.at( index ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof Array.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); + +assert.sameValue( + Array.prototype.at.length, 1, + 'The value of Array.prototype.at.length is expected to be 1' +); + +verifyNotEnumerable(Array.prototype.at, 'length'); +verifyNotWritable(Array.prototype.at, 'length'); +verifyConfigurable(Array.prototype.at, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/at/name.js b/js/src/tests/test262/built-ins/Array/prototype/at/name.js new file mode 100644 index 0000000000..1f19e92eae --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/name.js @@ -0,0 +1,32 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.at +description: > + Array.prototype.at.name value and descriptor. +info: | + Array.prototype.at( index ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof Array.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); + +assert.sameValue( + Array.prototype.at.name, 'at', + 'The value of Array.prototype.at.name is expected to be "at"' +); + +verifyProperty(Array.prototype.at, 'name', { + enumerable: false, + writable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/at/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/at/prop-desc.js new file mode 100644 index 0000000000..1f79f75d3a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/prop-desc.js @@ -0,0 +1,32 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.at +description: > + Property type and descriptor. +info: | + Array.prototype.at( index ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof Array.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); + +assert.sameValue( + typeof Array.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); + +verifyProperty(Array.prototype, 'at', { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/at/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/Array/prototype/at/return-abrupt-from-this.js new file mode 100644 index 0000000000..ce99ebaed0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/return-abrupt-from-this.js @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.at +description: > + Return abrupt from ToObject(this value). +info: | + Array.prototype.at( index ) + + Let O be ? ToObject(this value). + +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof Array.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); + +assert.throws(TypeError, () => { + Array.prototype.at.call(undefined); +}, 'Array.prototype.at.call(undefined) throws a TypeError exception'); + +assert.throws(TypeError, () => { + Array.prototype.at.call(null); +}, 'Array.prototype.at.call(null) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/at/returns-item-relative-index.js b/js/src/tests/test262/built-ins/Array/prototype/at/returns-item-relative-index.js new file mode 100644 index 0000000000..e131ef40fb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/returns-item-relative-index.js @@ -0,0 +1,36 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.at +description: > + Returns the item value at the specified relative index +info: | + Array.prototype.at ( ) + + Let O be ? ToObject(this value). + Let len be ? LengthOfArrayLike(O). + Let relativeIndex be ? ToInteger(index). + If relativeIndex ≥ 0, then + Let k be relativeIndex. + Else, + Let k be len + relativeIndex. + If k < 0 or k ≥ len, then return undefined. + Return ? Get(O, ! ToString(k)). + +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof Array.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); + +let a = [1, 2, 3, 4, ,5]; + +assert.sameValue(a.at(0), 1, 'a.at(0) must return 1'); +assert.sameValue(a.at(-1), 5, 'a.at(-1) must return 5'); +assert.sameValue(a.at(-2), undefined, 'a.at(-2) returns undefined'); +assert.sameValue(a.at(-3), 4, 'a.at(-3) must return 4'); +assert.sameValue(a.at(-4), 3, 'a.at(-4) must return 3'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/at/returns-item.js b/js/src/tests/test262/built-ins/Array/prototype/at/returns-item.js new file mode 100644 index 0000000000..be25e281f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/returns-item.js @@ -0,0 +1,37 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.at +description: > + Returns the item value at the specified index +info: | + Array.prototype.at ( ) + + Let O be ? ToObject(this value). + Let len be ? LengthOfArrayLike(O). + Let relativeIndex be ? ToInteger(index). + If relativeIndex ≥ 0, then + Let k be relativeIndex. + Else, + Let k be len + relativeIndex. + If k < 0 or k ≥ len, then return undefined. + Return ? Get(O, ! ToString(k)). + +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof Array.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); + +let a = [1, 2, 3, 4,,5]; + +assert.sameValue(a.at(0), 1, 'a.at(0) must return 1'); +assert.sameValue(a.at(1), 2, 'a.at(1) must return 2'); +assert.sameValue(a.at(2), 3, 'a.at(2) must return 3'); +assert.sameValue(a.at(3), 4, 'a.at(3) must return 4'); +assert.sameValue(a.at(4), undefined, 'a.at(4) returns undefined'); +assert.sameValue(a.at(5), 5, 'a.at(5) must return 5'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js b/js/src/tests/test262/built-ins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js new file mode 100644 index 0000000000..4c9a573b53 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js @@ -0,0 +1,45 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.at +description: > + Returns the item value at the specified index, respecting holes in sparse arrays. +info: | + Array.prototype.at ( ) + + Let O be ? ToObject(this value). + Let len be ? LengthOfArrayLike(O). + Let relativeIndex be ? ToInteger(index). + If relativeIndex ≥ 0, then + Let k be relativeIndex. + Else, + Let k be len + relativeIndex. + If k < 0 or k ≥ len, then return undefined. + Return ? Get(O, ! ToString(k)). + +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof Array.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); + +let a = [0, 1, , 3, 4, , 6]; + +assert.sameValue(a.at(0), 0, 'a.at(0) must return 0'); +assert.sameValue(a.at(1), 1, 'a.at(1) must return 1'); +assert.sameValue(a.at(2), undefined, 'a.at(2) returns undefined'); +assert.sameValue(a.at(3), 3, 'a.at(3) must return 3'); +assert.sameValue(a.at(4), 4, 'a.at(4) must return 4'); +assert.sameValue(a.at(5), undefined, 'a.at(5) returns undefined'); +assert.sameValue(a.at(6), 6, 'a.at(6) must return 6'); +assert.sameValue(a.at(-0), 0, 'a.at(-0) must return 0'); +assert.sameValue(a.at(-1), 6, 'a.at(-1) must return 6'); +assert.sameValue(a.at(-2), undefined, 'a.at(-2) returns undefined'); +assert.sameValue(a.at(-3), 4, 'a.at(-3) must return 4'); +assert.sameValue(a.at(-4), 3, 'a.at(-4) must return 3'); +assert.sameValue(a.at(-5), undefined, 'a.at(-5) returns undefined'); +assert.sameValue(a.at(-6), 1, 'a.at(-6) must return 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/at/returns-undefined-for-out-of-range-index.js b/js/src/tests/test262/built-ins/Array/prototype/at/returns-undefined-for-out-of-range-index.js new file mode 100644 index 0000000000..757ff87241 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/returns-undefined-for-out-of-range-index.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-array.prototype.at +description: > + Returns undefined if the specified index less than or greater than the available index range. +info: | + Array.prototype.at( index ) + + If k < 0 or k ≥ len, then return undefined. +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof Array.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); + +let a = []; + +assert.sameValue(a.at(-2), undefined, 'a.at(-2) returns undefined'); // wrap around the end +assert.sameValue(a.at(0), undefined, 'a.at(0) returns undefined'); +assert.sameValue(a.at(1), undefined, 'a.at(1) returns undefined'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/at/shell.js b/js/src/tests/test262/built-ins/Array/prototype/at/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/browser.js b/js/src/tests/test262/built-ins/Array/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/15.4.4.4-5-b-iii-3-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/concat/15.4.4.4-5-b-iii-3-b-1.js new file mode 100644 index 0000000000..213a63acc5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/15.4.4.4-5-b-iii-3-b-1.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: > + Array.prototype.concat will concat an Array when index property + (read-only) exists in Array.prototype (Step 5.b.iii.3.b) +includes: [propertyHelper.js] +---*/ + +Object.defineProperty(Array.prototype, "0", { + value: 100, + writable: false, + configurable: true +}); + +var oldArr = [101]; +var newArr = Array.prototype.concat.call(oldArr); + +verifyProperty(newArr, "0", { + value: 101, + writable: true, + enumerable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/15.4.4.4-5-c-i-1.js b/js/src/tests/test262/built-ins/Array/prototype/concat/15.4.4.4-5-c-i-1.js new file mode 100644 index 0000000000..104ca1114d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/15.4.4.4-5-c-i-1.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: > + Array.prototype.concat will concat an Array when index property + (read-only) exists in Array.prototype (Step 5.c.i) +includes: [propertyHelper.js] +---*/ + +Object.defineProperty(Array.prototype, "0", { + value: 100, + writable: false, + configurable: true +}); + +var newArrayFromConcat = Array.prototype.concat.call(101); + +assert( + newArrayFromConcat[0] instanceof Number, + 'The result of evaluating (newArrayFromConcat[0] instanceof Number) is expected to be true' +); +verifyProperty(newArrayFromConcat, "0", { + writable: true, + enumerable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-length-to-string-throws.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-length-to-string-throws.js new file mode 100644 index 0000000000..64a1fce627 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-length-to-string-throws.js @@ -0,0 +1,26 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat array like length to string throws +features: [Symbol.isConcatSpreadable] +---*/ +var objWithPoisonedLengthToString = { + "length": { + toString: function() { + throw new Test262Error(); + }, + valueOf: null + }, + "1": "A", + "3": "B", + "5": "C" +}; +objWithPoisonedLengthToString[Symbol.isConcatSpreadable] = true; +assert.throws(Test262Error, function() { + [].concat(objWithPoisonedLengthToString); +}, '[].concat(objWithPoisonedLengthToString) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-length-value-of-throws.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-length-value-of-throws.js new file mode 100644 index 0000000000..2ef6eacd26 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-length-value-of-throws.js @@ -0,0 +1,26 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat array like length valueOf throws +features: [Symbol.isConcatSpreadable] +---*/ +var objWithPoisonedLengthValueOf = { + "length": { + valueOf: function() { + throw new Test262Error(); + }, + toString: null + }, + "1": "A", + "3": "B", + "5": "C" +}; +objWithPoisonedLengthValueOf[Symbol.isConcatSpreadable] = true; +assert.throws(Test262Error, function() { + [].concat(objWithPoisonedLengthValueOf); +}, '[].concat(objWithPoisonedLengthValueOf) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-negative-length.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-negative-length.js new file mode 100644 index 0000000000..91cbc74883 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-negative-length.js @@ -0,0 +1,24 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat array like negative length +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var obj = { + "length": -4294967294, + "1": "A", + "3": "B", + "5": "C" +}; +obj[Symbol.isConcatSpreadable] = true; +assert.compareArray([].concat(obj), [], '[].concat({"length": -4294967294, "1": "A", "3": "B", "5": "C"}) must return []'); +obj.length = -4294967294; +assert.compareArray([].concat(obj), [], '[].concat({"length": -4294967294, "1": "A", "3": "B", "5": "C"}) must return []'); +obj.length = "-4294967294"; +assert.compareArray([].concat(obj), [], '[].concat({"length": -4294967294, "1": "A", "3": "B", "5": "C"}) must return []'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-primitive-non-number-length.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-primitive-non-number-length.js new file mode 100644 index 0000000000..d03a424288 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-primitive-non-number-length.js @@ -0,0 +1,32 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat array like primitive non number length +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var obj = { + "1": "A", + "3": "B", + "5": "C" +}; +obj[Symbol.isConcatSpreadable] = true; +obj.length = { + toString: function() { + return "SIX"; + }, + valueOf: null +}; +assert.compareArray([].concat(obj), [], '[].concat({"1": "A", "3": "B", "5": "C"}) must return []'); +obj.length = { + toString: null, + valueOf: function() { + return "SIX"; + } +}; +assert.compareArray([].concat(obj), [], '[].concat({"1": "A", "3": "B", "5": "C"}) must return []'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-string-length.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-string-length.js new file mode 100644 index 0000000000..1aa0191efd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-string-length.js @@ -0,0 +1,35 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat array like string length +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var obj = { + "length": "6", + "1": "A", + "3": "B", + "5": "C" +}; +obj[Symbol.isConcatSpreadable] = true; +var obj2 = { + length: 3, + "0": "0", + "1": "1", + "2": "2" +}; +var arr = ["X", "Y", "Z"]; + +var expected = [ + void 0, "A", void 0, "B", void 0, "C", + obj2, + "X", "Y", "Z" +]; +var actual = Array.prototype.concat.call(obj, obj2, arr); + +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-to-length-throws.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-to-length-throws.js new file mode 100644 index 0000000000..8aef650339 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like-to-length-throws.js @@ -0,0 +1,31 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat array like to length throws +features: [Symbol.isConcatSpreadable] +---*/ +var spreadableWithBrokenLength = { + "length": { + valueOf: null, + toString: null + }, + "1": "A", + "3": "B", + "5": "C" +}; +spreadableWithBrokenLength[Symbol.isConcatSpreadable] = true; +var obj2 = { + length: 3, + "0": "0", + "1": "1", + "2": "2" +}; +var arr = ["X", "Y", "Z"]; +assert.throws(TypeError, function() { + Array.prototype.concat.call(spreadableWithBrokenLength, obj2, arr); +}, 'Array.prototype.concat.call(spreadableWithBrokenLength, obj2, arr) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like.js new file mode 100644 index 0000000000..f188f17120 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_array-like.js @@ -0,0 +1,36 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat array like +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var obj = { + "length": 6, + "1": "A", + "3": "B", + "5": "C" +}; +obj[Symbol.isConcatSpreadable] = true; +var obj2 = { + length: 3, + "0": "0", + "1": "1", + "2": "2" +}; +var arr = ["X", "Y", "Z"]; + +var expected = [ + void 0, "A", void 0, "B", void 0, "C", + obj2, + "X", "Y", "Z" +]; +var actual = Array.prototype.concat.call(obj, obj2, arr); + +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_holey-sloppy-arguments.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_holey-sloppy-arguments.js new file mode 100644 index 0000000000..5f8cbfaab4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_holey-sloppy-arguments.js @@ -0,0 +1,21 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat holey sloppy arguments +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var args = (function(a) { + return arguments; +})(1, 2, 3); +delete args[1]; +args[Symbol.isConcatSpreadable] = true; +assert.compareArray([1, void 0, 3, 1, void 0, 3], [].concat(args, args), + '[1, void 0, 3, 1, void 0, 3] must return the same value returned by [].concat(args, args)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_large-typed-array.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_large-typed-array.js new file mode 100644 index 0000000000..a4de0ef3a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_large-typed-array.js @@ -0,0 +1,52 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat large typed array +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +function concatTypedArray(type, elems, modulo) { + var items = new Array(elems); + var ta_by_len = new type(elems); + for (var i = 0; i < elems; ++i) { + ta_by_len[i] = items[i] = modulo === false ? i : elems % modulo; + } + var ta = new type(items); + assert.compareArray([].concat(ta, ta), [ta, ta]); + ta[Symbol.isConcatSpreadable] = true; + assert.compareArray([].concat(ta), items); + + assert.compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]); + ta_by_len[Symbol.isConcatSpreadable] = true; + assert.compareArray([].concat(ta_by_len), items); + + // TypedArray with fake `length`. + ta = new type(1); + var defValue = ta[0]; + var expected = new Array(4000); + expected[0] = defValue; + + Object.defineProperty(ta, "length", { + value: 4000 + }); + ta[Symbol.isConcatSpreadable] = true; + assert.compareArray([].concat(ta), expected); +} + +// Float16Array cannot be included in this because it cannot precisely represent integers above 2048 +var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false]; +[ + Uint8Array, + Uint16Array, + Uint32Array, + Float32Array, + Float64Array +].forEach(function(ctor, i) { + concatTypedArray(ctor, 4000, max[i]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_length-throws.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_length-throws.js new file mode 100644 index 0000000000..6ff8e0b3e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_length-throws.js @@ -0,0 +1,27 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat length throws +features: [Symbol.isConcatSpreadable] +---*/ +var spreadablePoisonedLengthGetter = {}; +spreadablePoisonedLengthGetter[Symbol.isConcatSpreadable] = true; +Object.defineProperty(spreadablePoisonedLengthGetter, "length", { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + [].concat(spreadablePoisonedLengthGetter); +}, '[].concat(spreadablePoisonedLengthGetter) throws a Test262Error exception'); + +assert.throws(Test262Error, function() { + Array.prototype.concat.call(spreadablePoisonedLengthGetter, 1, 2, 3); +}, 'Array.prototype.concat.call(spreadablePoisonedLengthGetter, 1, 2, 3) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_no-prototype.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_no-prototype.js new file mode 100644 index 0000000000..bb5dd7277c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_no-prototype.js @@ -0,0 +1,16 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat no prototype +---*/ +assert.sameValue( + Array.prototype.concat.prototype, + void 0, + 'The value of Array.prototype.concat.prototype is expected to be void 0' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_non-array.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_non-array.js new file mode 100644 index 0000000000..a6288b26d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_non-array.js @@ -0,0 +1,31 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: array-concat-non-array +includes: [compareArray.js] +---*/ + +// +// test262 --command "v8 --harmony-classes --harmony_object_literals" array-concat-non-array +// +class NonArray { + constructor() { + Array.apply(this, arguments); + } +} + +var obj = new NonArray(1, 2, 3); +var result = Array.prototype.concat.call(obj, 4, 5, 6); +assert.sameValue(Array, result.constructor, 'The value of Array is expected to equal the value of result.constructor'); +assert.sameValue( + result instanceof NonArray, + false, + 'The result of evaluating (result instanceof NonArray) is expected to be false' +); +assert.compareArray(result, [obj, 4, 5, 6], 'The value of result is expected to be [obj, 4, 5, 6]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments-throws.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments-throws.js new file mode 100644 index 0000000000..72a67f4295 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments-throws.js @@ -0,0 +1,24 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat sloppy arguments throws +features: [Symbol.isConcatSpreadable] +---*/ +var args = (function(a) { + return arguments; +})(1, 2, 3); +Object.defineProperty(args, 0, { + get: function() { + throw new Test262Error(); + } +}); +args[Symbol.isConcatSpreadable] = true; +assert.throws(Test262Error, function() { + return [].concat(args, args); +}, 'return [].concat(args, args) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments-with-dupes.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments-with-dupes.js new file mode 100644 index 0000000000..36af587993 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments-with-dupes.js @@ -0,0 +1,28 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat sloppy arguments with dupes +flags: [noStrict] +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var args = (function(a, a, a) { + return arguments; +})(1, 2, 3); +args[Symbol.isConcatSpreadable] = true; +assert.compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3], + '[].concat((function(a, a, a) {return arguments;})(1, 2, 3), (function(a, a, a) {return arguments;})(1, 2, 3)) must return [1, 2, 3, 1, 2, 3]' +); + +Object.defineProperty(args, "length", { + value: 6 +}); +assert.compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0], + '[].concat((function(a, a, a) {return arguments;})(1, 2, 3)) must return [1, 2, 3, void 0, void 0, void 0]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments.js new file mode 100644 index 0000000000..1027774fde --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments.js @@ -0,0 +1,27 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat sloppy arguments +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var args = (function(a, b, c) { + return arguments; +})(1, 2, 3); +args[Symbol.isConcatSpreadable] = true; +assert.compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3], + '[].concat((function(a, b, c) {return arguments;})(1, 2, 3), (function(a, b, c) {return arguments;})(1, 2, 3)) must return [1, 2, 3, 1, 2, 3]' +); + +Object.defineProperty(args, "length", { + value: 6 +}); +assert.compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0], + '[].concat((function(a, b, c) {return arguments;})(1, 2, 3)) must return [1, 2, 3, void 0, void 0, void 0]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_small-typed-array.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_small-typed-array.js new file mode 100644 index 0000000000..2bb8b17ef3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_small-typed-array.js @@ -0,0 +1,56 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat small typed array +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +function concatTypedArray(type, elems, modulo) { + var items = new Array(elems); + var ta_by_len = new type(elems); + for (var i = 0; i < elems; ++i) { + ta_by_len[i] = items[i] = modulo === false ? i : elems % modulo; + } + var ta = new type(items); + assert.compareArray([].concat(ta, ta), [ta, ta]); + ta[Symbol.isConcatSpreadable] = true; + assert.compareArray([].concat(ta), items); + + assert.compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]); + ta_by_len[Symbol.isConcatSpreadable] = true; + assert.compareArray([].concat(ta_by_len), items); + + // TypedArray with fake `length`. + ta = new type(1); + var defValue = ta[0]; + var expected = new Array(4000); + expected[0] = defValue; + + Object.defineProperty(ta, "length", { + value: 4000 + }); + ta[Symbol.isConcatSpreadable] = true; + assert.compareArray([].concat(ta), expected); +} +var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false]; +var TAs = [ + Uint8Array, + Uint16Array, + Uint32Array, + Float32Array, + Float64Array +]; +if (typeof Float16Array !== 'undefined') { + max.push(false); + TAs.push(Float16Array); +} + +TAs.forEach(function(ctor, i) { + concatTypedArray(ctor, 1, max[i]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-boolean-wrapper.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-boolean-wrapper.js new file mode 100644 index 0000000000..1a1c8cbdcf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-boolean-wrapper.js @@ -0,0 +1,45 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable boolean wrapper +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var bool = new Boolean(true) +// Boolean wrapper objects are not concat-spreadable by default +assert.compareArray([bool], [].concat(bool), '[bool] must return the same value returned by [].concat(bool)'); + +// Boolean wrapper objects may be individually concat-spreadable +bool[Symbol.isConcatSpreadable] = true; +bool.length = 3; +bool[0] = 1, bool[1] = 2, bool[2] = 3; +assert.compareArray([1, 2, 3], [].concat(bool), + '[1, 2, 3] must return the same value returned by [].concat(bool)' +); + +Boolean.prototype[Symbol.isConcatSpreadable] = true; +// Boolean wrapper objects may be concat-spreadable +assert.compareArray([], [].concat(new Boolean(true)), + '[] must return the same value returned by [].concat(new Boolean(true))' +); +Boolean.prototype[0] = 1; +Boolean.prototype[1] = 2; +Boolean.prototype[2] = 3; +Boolean.prototype.length = 3; +assert.compareArray([1, 2, 3], [].concat(new Boolean(true)), + '[1, 2, 3] must return the same value returned by [].concat(new Boolean(true))' +); + +// Boolean values are never concat-spreadable +assert.compareArray([true], [].concat(true), '[true] must return the same value returned by [].concat(true)'); +delete Boolean.prototype[Symbol.isConcatSpreadable]; +delete Boolean.prototype[0]; +delete Boolean.prototype[1]; +delete Boolean.prototype[2]; +delete Boolean.prototype.length; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-function.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-function.js new file mode 100644 index 0000000000..6f692548b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-function.js @@ -0,0 +1,38 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable function +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var fn = function(a, b, c) {} +// Functions are not concat-spreadable by default +assert.compareArray([fn], [].concat(fn), '[fn] must return the same value returned by [].concat(fn)'); + +// Functions may be individually concat-spreadable +fn[Symbol.isConcatSpreadable] = true; +fn[0] = 1, fn[1] = 2, fn[2] = 3; +assert.compareArray([1, 2, 3], [].concat(fn), '[1, 2, 3] must return the same value returned by [].concat(fn)'); + +Function.prototype[Symbol.isConcatSpreadable] = true; +// Functions may be concat-spreadable +assert.compareArray([void 0, void 0, void 0], [].concat(function(a, b, c) {}), + '[void 0, void 0, void 0] must return the same value returned by [].concat(function(a, b, c) {})' +); +Function.prototype[0] = 1; +Function.prototype[1] = 2; +Function.prototype[2] = 3; +assert.compareArray([1, 2, 3], [].concat(function(a, b, c) {}), + '[1, 2, 3] must return the same value returned by [].concat(function(a, b, c) {})' +); + +delete Function.prototype[Symbol.isConcatSpreadable]; +delete Function.prototype[0]; +delete Function.prototype[1]; +delete Function.prototype[2]; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-getter-throws.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-getter-throws.js new file mode 100644 index 0000000000..7027cb04da --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-getter-throws.js @@ -0,0 +1,26 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable getter throws +features: [Symbol.isConcatSpreadable] +---*/ +var spreadablePoisonedGetter = {}; +Object.defineProperty(spreadablePoisonedGetter, Symbol.isConcatSpreadable, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + [].concat(spreadablePoisonedGetter); +}, '[].concat(spreadablePoisonedGetter) throws a Test262Error exception'); + +assert.throws(Test262Error, function() { + Array.prototype.concat.call(spreadablePoisonedGetter, 1, 2, 3); +}, 'Array.prototype.concat.call(spreadablePoisonedGetter, 1, 2, 3) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-number-wrapper.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-number-wrapper.js new file mode 100644 index 0000000000..08923aa009 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-number-wrapper.js @@ -0,0 +1,43 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable number wrapper +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var num = new Number(true) +// Number wrapper objects are not concat-spreadable by default +assert.compareArray([num], [].concat(num), '[num] must return the same value returned by [].concat(num)'); + +// Number wrapper objects may be individually concat-spreadable +num[Symbol.isConcatSpreadable] = true; +num.length = 3; +num[0] = 1, num[1] = 2, num[2] = 3; +assert.compareArray([1, 2, 3], [].concat(num), '[1, 2, 3] must return the same value returned by [].concat(num)'); + +Number.prototype[Symbol.isConcatSpreadable] = true; +// Number wrapper objects may be concat-spreadable +assert.compareArray([], [].concat(new Number(123)), + '[] must return the same value returned by [].concat(new Number(123))' +); +Number.prototype[0] = 1; +Number.prototype[1] = 2; +Number.prototype[2] = 3; +Number.prototype.length = 3; +assert.compareArray([1, 2, 3], [].concat(new Number(123)), + '[1, 2, 3] must return the same value returned by [].concat(new Number(123))' +); + +// Number values are never concat-spreadable +assert.compareArray([true], [].concat(true), '[true] must return the same value returned by [].concat(true)'); +delete Number.prototype[Symbol.isConcatSpreadable]; +delete Number.prototype[0]; +delete Number.prototype[1]; +delete Number.prototype[2]; +delete Number.prototype.length; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-reg-exp.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-reg-exp.js new file mode 100644 index 0000000000..dca75da974 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-reg-exp.js @@ -0,0 +1,41 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable reg exp +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var re = /abc/; +// RegExps are not concat-spreadable by default +assert.compareArray([].concat(re), [re], '[].concat(/abc/) must return [re]'); + +// RegExps may be individually concat-spreadable +re[Symbol.isConcatSpreadable] = true; +re[0] = 1, re[1] = 2, re[2] = 3, re.length = 3; +assert.compareArray([].concat(re), [1, 2, 3], '[].concat(/abc/) must return [1, 2, 3]'); + +// RegExps may be concat-spreadable +RegExp.prototype[Symbol.isConcatSpreadable] = true; +RegExp.prototype.length = 3; + +assert.compareArray([].concat(/abc/), [void 0, void 0, void 0], + '[].concat(/abc/) must return [void 0, void 0, void 0]' +); +RegExp.prototype[0] = 1; +RegExp.prototype[1] = 2; +RegExp.prototype[2] = 3; +assert.compareArray([].concat(/abc/), [1, 2, 3], + '[].concat(/abc/) must return [1, 2, 3]' +); + +delete RegExp.prototype[Symbol.isConcatSpreadable]; +delete RegExp.prototype[0]; +delete RegExp.prototype[1]; +delete RegExp.prototype[2]; +delete RegExp.prototype.length; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-sparse-object.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-sparse-object.js new file mode 100644 index 0000000000..1ede626d06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-sparse-object.js @@ -0,0 +1,25 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable sparse object +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var obj = { + length: 5 +}; +obj[Symbol.isConcatSpreadable] = true; +assert.compareArray([void 0, void 0, void 0, void 0, void 0], [].concat(obj), + '[void 0, void 0, void 0, void 0, void 0] must return the same value returned by [].concat(obj)' +); + +obj.length = 4000; +assert.compareArray(new Array(4000), [].concat(obj), + 'new Array(4000) must return the same value returned by [].concat(obj)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-string-wrapper.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-string-wrapper.js new file mode 100644 index 0000000000..e44fbc769a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-string-wrapper.js @@ -0,0 +1,34 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable string wrapper +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var str1 = new String("yuck\uD83D\uDCA9") +// String wrapper objects are not concat-spreadable by default +assert.compareArray([str1], [].concat(str1), '[str1] must return the same value returned by [].concat(str1)'); + +// String wrapper objects may be individually concat-spreadable +str1[Symbol.isConcatSpreadable] = true; +assert.compareArray(["y", "u", "c", "k", "\uD83D", "\uDCA9"], [].concat(str1), + '["y", "u", "c", "k", "uD83D", "uDCA9"] must return the same value returned by [].concat(str1)' +); + +String.prototype[Symbol.isConcatSpreadable] = true; +// String wrapper objects may be concat-spreadable +assert.compareArray(["y", "u", "c", "k", "\uD83D", "\uDCA9"], [].concat(new String("yuck\uD83D\uDCA9")), + '["y", "u", "c", "k", "uD83D", "uDCA9"] must return the same value returned by [].concat(new String("yuckuD83DuDCA9"))' +); + +// String values are never concat-spreadable +assert.compareArray(["yuck\uD83D\uDCA9"], [].concat("yuck\uD83D\uDCA9"), + '["yuckuD83DuDCA9"] must return the same value returned by [].concat("yuckuD83DuDCA9")' +); +delete String.prototype[Symbol.isConcatSpreadable]; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_strict-arguments.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_strict-arguments.js new file mode 100644 index 0000000000..34f81f0a45 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_strict-arguments.js @@ -0,0 +1,28 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat strict arguments +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var args = (function(a, b, c) { + "use strict"; + return arguments; +})(1, 2, 3); +args[Symbol.isConcatSpreadable] = true; +assert.compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3], + '[].concat("(function(a, b, c) {"use strict"; return arguments;})(1, 2, 3)", "(function(a, b, c) {"use strict"; return arguments;})(1, 2, 3)") must return [1, 2, 3, 1, 2, 3]' +); + +Object.defineProperty(args, "length", { + value: 6 +}); +assert.compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0], + '[].concat("(function(a, b, c) {"use strict"; return arguments;})(1, 2, 3)") must return [1, 2, 3, void 0, void 0, void 0]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T1.js new file mode 100644 index 0000000000..7d4bd82f39 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T1.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +info: | + When the concat method is called with zero or more arguments item1, item2, + etc., it returns an array containing the array elements of the object followed by + the array elements of each argument in order +es5id: 15.4.4.4_A1_T1 +description: Checking this algorithm, items are Array object +---*/ + +var x = new Array(); +var y = new Array(0, 1); +var z = new Array(2, 3, 4); +var arr = x.concat(y, z); + +arr.getClass = Object.prototype.toString; +assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); +assert.sameValue(arr[0], 0, 'The value of arr[0] is expected to be 0'); +assert.sameValue(arr[1], 1, 'The value of arr[1] is expected to be 1'); +assert.sameValue(arr[2], 2, 'The value of arr[2] is expected to be 2'); +assert.sameValue(arr[3], 3, 'The value of arr[3] is expected to be 3'); +assert.sameValue(arr[4], 4, 'The value of arr[4] is expected to be 4'); +assert.sameValue(arr.length, 5, 'The value of arr.length is expected to be 5'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T2.js b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T2.js new file mode 100644 index 0000000000..1ac86bfd21 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T2.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +info: | + When the concat method is called with zero or more arguments item1, item2, + etc., it returns an array containing the array elements of the object followed by + the array elements of each argument in order +es5id: 15.4.4.4_A1_T2 +description: Checking this algorithm, items are objects and primitives +---*/ + +var x = [0]; +var y = new Object(); +var z = new Array(1, 2); +var arr = x.concat(y, z, -1, true, "NaN"); + +arr.getClass = Object.prototype.toString; +assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); +assert.sameValue(arr[0], 0, 'The value of arr[0] is expected to be 0'); +assert.sameValue(arr[1], y, 'The value of arr[1] is expected to equal the value of y'); +assert.sameValue(arr[2], 1, 'The value of arr[2] is expected to be 1'); +assert.sameValue(arr[3], 2, 'The value of arr[3] is expected to be 2'); +assert.sameValue(arr[4], -1, 'The value of arr[4] is expected to be -1'); +assert.sameValue(arr[5], true, 'The value of arr[5] is expected to be true'); +assert.sameValue(arr[6], "NaN", 'The value of arr[6] is expected to be "NaN"'); +assert.sameValue(arr.length, 7, 'The value of arr.length is expected to be 7'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T3.js b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T3.js new file mode 100644 index 0000000000..efcd31f65d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T3.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +info: | + When the concat method is called with zero or more arguments item1, item2, + etc., it returns an array containing the array elements of the object followed by + the array elements of each argument in order +es5id: 15.4.4.4_A1_T3 +description: Checking this algorithm with no items +---*/ + +var x = [0, 1]; +var arr = x.concat(); + +arr.getClass = Object.prototype.toString; +assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); +assert.sameValue(arr[0], 0, 'The value of arr[0] is expected to be 0'); +assert.sameValue(arr[1], 1, 'The value of arr[1] is expected to be 1'); +assert.sameValue(arr.length, 2, 'The value of arr.length is expected to be 2'); +assert.notSameValue(arr, x, 'The value of arr is expected to not equal the value of `x`'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T4.js b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T4.js new file mode 100644 index 0000000000..be7c04c42e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T4.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +info: | + When the concat method is called with zero or more arguments item1, item2, + etc., it returns an array containing the array elements of the object followed by + the array elements of each argument in order +es5id: 15.4.4.4_A1_T4 +description: Checking this algorithm, items are [], [,] +---*/ + +var x = [, 1]; +var arr = x.concat([], [, ]); + +arr.getClass = Object.prototype.toString; +assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); +assert.sameValue(arr[0], undefined, 'The value of arr[0] is expected to equal undefined'); +assert.sameValue(arr[1], 1, 'The value of arr[1] is expected to be 1'); +assert.sameValue(arr[2], undefined, 'The value of arr[2] is expected to equal undefined'); +assert.sameValue(arr.length, 3, 'The value of arr.length is expected to be 3'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A2_T1.js new file mode 100644 index 0000000000..8cf2de37a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A2_T1.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +info: | + The concat function is intentionally generic. + It does not require that its this value be an Array object +es5id: 15.4.4.4_A2_T1 +description: Checking this for Object object, items are objects and primitives +---*/ + +var x = {}; +x.concat = Array.prototype.concat; +var y = new Object(); +var z = new Array(1, 2); +var arr = x.concat(y, z, -1, true, "NaN"); + +arr.getClass = Object.prototype.toString; +assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); +assert.sameValue(arr[0], x, 'The value of arr[0] is expected to equal the value of x'); +assert.sameValue(arr[1], y, 'The value of arr[1] is expected to equal the value of y'); +assert.sameValue(arr[2], 1, 'The value of arr[2] is expected to be 1'); +assert.sameValue(arr[3], 2, 'The value of arr[3] is expected to be 2'); +assert.sameValue(arr[4], -1, 'The value of arr[4] is expected to be -1'); +assert.sameValue(arr[5], true, 'The value of arr[5] is expected to be true'); +assert.sameValue(arr[6], "NaN", 'The value of arr[6] is expected to be "NaN"'); +assert.sameValue(arr.length, 7, 'The value of arr.length is expected to be 7'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A2_T2.js new file mode 100644 index 0000000000..8d0efd6b2f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A2_T2.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +info: | + The concat function is intentionally generic. + It does not require that its this value be an Array object +es5id: 15.4.4.4_A2_T2 +description: Checking this for Object object with no items +---*/ + +var x = {}; +x.concat = Array.prototype.concat; +var arr = x.concat(); + +arr.getClass = Object.prototype.toString; +assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); +assert.sameValue(arr[0], x, 'The value of arr[0] is expected to equal the value of x'); +assert.sameValue(arr.length, 1, 'The value of arr.length is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T1.js b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T1.js new file mode 100644 index 0000000000..34ef8926c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T1.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +info: "[[Get]] from not an inherited property" +es5id: 15.4.4.4_A3_T1 +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Array.prototype[1] = 1; +var x = [0]; +x.length = 2; +var arr = x.concat(); + +assert.sameValue(arr[0], 0, 'The value of arr[0] is expected to be 0'); +assert.sameValue(arr[1], 1, 'The value of arr[1] is expected to be 1'); +assert.sameValue(arr.hasOwnProperty('1'), true, 'arr.hasOwnProperty("1") must return true'); + +Object.prototype[1] = 1; +Object.prototype.length = 2; +Object.prototype.concat = Array.prototype.concat; +x = { + 0: 0 +}; +var arr = x.concat(); + +assert.sameValue(arr[0], x, 'The value of arr[0] is expected to equal the value of x'); +assert.sameValue(arr[1], 1, 'The value of arr[1] is expected to be 1'); +assert.sameValue(arr.hasOwnProperty('1'), false, 'arr.hasOwnProperty("1") must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T2.js b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T2.js new file mode 100644 index 0000000000..858b6080b0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T2.js @@ -0,0 +1,37 @@ +// Copyright (c) 2014 Ecma International. All rights reserved. +// See LICENSE or https://github.com/tc39/test262/blob/HEAD/LICENSE + +/*--- +esid: sec-array.prototype.concat +info: Array.prototype.concat uses [[Get]] on 'length' to determine array length +es5id: 15.4.4.4_A3_T2 +description: > + checking whether non-ownProperties are seen, copied by Array.prototype.concat: Array.prototype[1] +---*/ + +var a = [0]; + +assert.sameValue(a.length, 1, 'The value of a.length is expected to be 1'); + +a.length = 3; + +assert.sameValue(a[1], undefined, 'The value of a[1] is expected to equal undefined'); +assert.sameValue(a[2], undefined, 'The value of a[2] is expected to equal undefined'); + +Array.prototype[2] = 2; + +assert.sameValue(a[1], undefined, 'The value of a[1] is expected to equal undefined'); +assert.sameValue(a[2], 2, 'The value of a[2] is expected to be 2'); +assert.sameValue(a.hasOwnProperty('1'), false, 'a.hasOwnProperty("1") must return false'); +assert.sameValue(a.hasOwnProperty('2'), false, 'a.hasOwnProperty("2") must return false'); + +var b = a.concat(); + +assert.sameValue(b.length, 3, 'The value of b.length is expected to be 3'); +assert.sameValue(b[0], 0, 'The value of b[0] is expected to be 0'); +assert.sameValue(b[1], undefined, 'The value of b[1] is expected to equal undefined'); +assert.sameValue(b[2], 2, 'The value of b[2] is expected to be 2'); +assert.sameValue(b.hasOwnProperty('1'), false, 'b.hasOwnProperty("1") must return false'); +assert.sameValue(b.hasOwnProperty('2'), true, 'b.hasOwnProperty("2") must return true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T3.js b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T3.js new file mode 100644 index 0000000000..270a2a0137 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T3.js @@ -0,0 +1,37 @@ +// Copyright (c) 2014 Ecma International. All rights reserved. +// See LICENSE or https://github.com/tc39/test262/blob/HEAD/LICENSE + +/*--- +esid: sec-array.prototype.concat +info: Array.prototype.concat uses [[Get]] on 'length' to determine array length +es5id: 15.4.4.4_A3_T3 +description: > + checking whether non-ownProperties are seen, copied by Array.prototype.concat: Object.prototype[1] +---*/ + +var a = [0]; + +assert.sameValue(a.length, 1, 'The value of a.length is expected to be 1'); + +a.length = 3; + +assert.sameValue(a[1], undefined, 'The value of a[1] is expected to equal undefined'); +assert.sameValue(a[2], undefined, 'The value of a[2] is expected to equal undefined'); + +Object.prototype[2] = 2; + +assert.sameValue(a[1], undefined, 'The value of a[1] is expected to equal undefined'); +assert.sameValue(a[2], 2, 'The value of a[2] is expected to be 2'); +assert.sameValue(a.hasOwnProperty('1'), false, 'a.hasOwnProperty("1") must return false'); +assert.sameValue(a.hasOwnProperty('2'), false, 'a.hasOwnProperty("2") must return false'); + +var b = a.concat(); + +assert.sameValue(b.length, 3, 'The value of b.length is expected to be 3'); +assert.sameValue(b[0], 0, 'The value of b[0] is expected to be 0'); +assert.sameValue(b[1], undefined, 'The value of b[1] is expected to equal undefined'); +assert.sameValue(b[2], 2, 'The value of b[2] is expected to be 2'); +assert.sameValue(b.hasOwnProperty('1'), false, 'b.hasOwnProperty("1") must return false'); +assert.sameValue(b.hasOwnProperty('2'), true, 'b.hasOwnProperty("2") must return true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/arg-length-exceeding-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/concat/arg-length-exceeding-integer-limit.js new file mode 100644 index 0000000000..3e997498e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/arg-length-exceeding-integer-limit.js @@ -0,0 +1,42 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: > + TypeError is thrown if "length" of result array exceeds 2^53 - 1. +info: | + Array.prototype.concat ( ...arguments ) + + [...] + 5. Repeat, while items is not empty + [...] + c. If spreadable is true, then + [...] + ii. Let len be ? LengthOfArrayLike(E). + iii. If n + len > 2^53 - 1, throw a TypeError exception. + [...] +features: [Symbol.isConcatSpreadable, Proxy] +---*/ + +var spreadableLengthOutOfRange = {}; +spreadableLengthOutOfRange.length = Number.MAX_SAFE_INTEGER; +spreadableLengthOutOfRange[Symbol.isConcatSpreadable] = true; + +assert.throws(TypeError, function() { + [1].concat(spreadableLengthOutOfRange); +}, '[1].concat(spreadableLengthOutOfRange) throws a TypeError exception'); + +var proxyForArrayWithLengthOutOfRange = new Proxy([], { + get: function(_target, key) { + if (key === "length") { + return Number.MAX_SAFE_INTEGER; + } + }, +}); + +assert.throws(TypeError, function() { + [].concat(1, proxyForArrayWithLengthOutOfRange); +}, '[].concat(1, proxyForArrayWithLengthOutOfRange) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/arg-length-near-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/concat/arg-length-near-integer-limit.js new file mode 100644 index 0000000000..438f520e16 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/arg-length-near-integer-limit.js @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: > + Elements are copied from a spreadable array-like object + whose "length" property is near the integer limit. +info: | + Array.prototype.concat ( ...arguments ) + + [...] + 5. Repeat, while items is not empty + [...] + c. If spreadable is true, then + [...] + ii. Let len be ? LengthOfArrayLike(E). + iii. If n + len > 2^53 - 1, throw a TypeError exception. + iv. Repeat, while k < len + [...] + 3. If exists is true, then + a. Let subElement be ? Get(E, P). + [...] +features: [Symbol.isConcatSpreadable] +---*/ + +var spreadableHasPoisonedIndex = { + length: Number.MAX_SAFE_INTEGER, + get 0() { + throw new Test262Error(); + }, +}; +spreadableHasPoisonedIndex[Symbol.isConcatSpreadable] = true; + +assert.throws(Test262Error, function() { + [].concat(spreadableHasPoisonedIndex); +}, '[].concat(spreadableHasPoisonedIndex) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/browser.js b/js/src/tests/test262/built-ins/Array/prototype/concat/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/concat/call-with-boolean.js new file mode 100644 index 0000000000..4f2f0bdbd1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/call-with-boolean.js @@ -0,0 +1,20 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat applied to boolean primitive +---*/ + +assert.sameValue( + Array.prototype.concat.call(true)[0] instanceof Boolean, + true, + 'The result of evaluating (Array.prototype.concat.call(true)[0] instanceof Boolean) is expected to be true' +); +assert.sameValue( + Array.prototype.concat.call(false)[0] instanceof Boolean, + true, + 'The result of evaluating (Array.prototype.concat.call(false)[0] instanceof Boolean) is expected to be true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-ctor-non-object.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-ctor-non-object.js new file mode 100644 index 0000000000..e903ec6b66 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-ctor-non-object.js @@ -0,0 +1,44 @@ +// 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-array.prototype.concat +description: > + Behavior when `constructor` property is neither an Object nor undefined +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 9. If IsConstructor(C) is false, throw a TypeError exception. +---*/ + +var a = []; + +a.constructor = null; +assert.throws(TypeError, function() { + a.concat(); +}, 'a.concat() throws a TypeError exception'); + +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.concat(); +}, 'a.concat() throws a TypeError exception'); + +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.concat(); +}, 'a.concat() throws a TypeError exception'); + +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.concat(); +}, 'a.concat() throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-ctor-poisoned.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-ctor-poisoned.js new file mode 100644 index 0000000000..faaaf7c756 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-ctor-poisoned.js @@ -0,0 +1,28 @@ +// 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-array.prototype.concat +description: Abrupt completion from `constructor` property access +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). +---*/ + +var a = []; + +Object.defineProperty(a, 'constructor', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + a.concat(); +}, 'a.concat() throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-non-array.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-non-array.js new file mode 100644 index 0000000000..6501c3270a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-non-array.js @@ -0,0 +1,40 @@ +// 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-array.prototype.concat +description: Constructor is ignored for non-Array values +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). +---*/ + +var obj = { + length: 0 +}; +var callCount = 0; +var result; +Object.defineProperty(obj, 'constructor', { + get: function() { + callCount += 1; + } +}); + +result = Array.prototype.concat.call(obj); + +assert.sameValue(callCount, 0, 'The value of callCount is expected to be 0'); +assert.sameValue( + Object.getPrototypeOf(result), + Array.prototype, + 'Object.getPrototypeOf(Array.prototype.concat.call(obj)) returns Array.prototype' +); +assert(Array.isArray(result), 'Array.isArray(result) must return true'); +assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); +assert.sameValue(result[0], obj, 'The value of result[0] is expected to equal the value of obj'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-proto-from-ctor-realm-array.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-proto-from-ctor-realm-array.js new file mode 100644 index 0000000000..c23e02c0ce --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-proto-from-ctor-realm-array.js @@ -0,0 +1,48 @@ +// 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-array.prototype.concat +description: Prefer Array constructor of current realm record +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C + be undefined. + [...] +features: [cross-realm, Symbol.species] +---*/ + +var array = []; +var callCount = 0; +var OArray = $262.createRealm().global.Array; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OArray; + +Object.defineProperty(Array, Symbol.species, speciesDesc); +Object.defineProperty(OArray, Symbol.species, speciesDesc); + +result = array.concat(); + +assert.sameValue( + Object.getPrototypeOf(result), + Array.prototype, + 'Object.getPrototypeOf(array.concat()) returns Array.prototype' +); +assert.sameValue(callCount, 0, 'The value of callCount is expected to be 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js new file mode 100644 index 0000000000..eaf05ad755 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js @@ -0,0 +1,49 @@ +// 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-array.prototype.concat +description: Accept non-Array constructors from other realms +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C + be undefined. + [...] +features: [cross-realm, Symbol.species] +---*/ + +var array = []; +var callCount = 0; +var CustomCtor = function() {}; +var OObject = $262.createRealm().global.Object; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OObject; +OObject[Symbol.species] = CustomCtor; + +Object.defineProperty(Array, Symbol.species, speciesDesc); + +result = array.concat(); + +assert.sameValue( + Object.getPrototypeOf(result), + CustomCtor.prototype, + 'Object.getPrototypeOf(array.concat()) returns CustomCtor.prototype' +); +assert.sameValue(callCount, 0, 'The value of callCount is expected to be 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-proxy.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-proxy.js new file mode 100644 index 0000000000..4ce82f5c7f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-proxy.js @@ -0,0 +1,45 @@ +// 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-array.prototype.concat +description: Species constructor of a Proxy object whose target is an array +info: | + [...] + 2. Let A be ? ArraySpeciesCreate(O, 0). + [...] + 7. Return A. + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + + 7.2.2 IsArray + + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is + null, throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy, Symbol.species] +---*/ + +var array = []; +var proxy = new Proxy(new Proxy(array, {}), {}); +var Ctor = function() {}; +var result; + +array.constructor = function() {}; +array.constructor[Symbol.species] = Ctor; + +result = Array.prototype.concat.call(proxy); + +assert.sameValue( + Object.getPrototypeOf(result), + Ctor.prototype, + 'Object.getPrototypeOf(Array.prototype.concat.call(proxy)) returns Ctor.prototype' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-revoked-proxy.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-revoked-proxy.js new file mode 100644 index 0000000000..bac42fd509 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-revoked-proxy.js @@ -0,0 +1,40 @@ +// 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-array.prototype.concat +description: Abrupt completion from constructor that is a revoked Proxy object +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + + 7.2.2 IsArray + + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is + null, throw a TypeError exception. +features: [Proxy] +---*/ + +var o = Proxy.revocable([], {}); +var callCount = 0; + +Object.defineProperty(o.proxy, 'constructor', { + get: function() { + callCount += 1; + } +}); +o.revoke(); + +assert.throws(TypeError, function() { + Array.prototype.concat.call(o.proxy); +}, 'Array.prototype.concat.call(o.proxy) throws a TypeError exception'); + +assert.sameValue(callCount, 0, 'The value of callCount is expected to be 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-abrupt.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-abrupt.js new file mode 100644 index 0000000000..340a42f8cf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-abrupt.js @@ -0,0 +1,34 @@ +// 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-array.prototype.concat +description: Species constructor returns an abrupt completion +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var Ctor = function() { + throw new Test262Error(); +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; + +assert.throws(Test262Error, function() { + a.concat(); +}, 'a.concat() throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-non-ctor.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-non-ctor.js new file mode 100644 index 0000000000..fb102a6052 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-non-ctor.js @@ -0,0 +1,40 @@ +// 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-array.prototype.concat +description: > + Behavior when the @@species attribute is a non-constructor object +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 9. If IsConstructor(C) is false, throw a TypeError exception. +includes: [isConstructor.js] +features: [Symbol.species, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(parseInt), + false, + 'precondition: isConstructor(parseInt) must return false' +); + +var a = []; + +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; + +assert.throws(TypeError, function() { + a.concat(); +}, 'a.concat() throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-non-extensible-spreadable.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-non-extensible-spreadable.js new file mode 100644 index 0000000000..f2d43b7293 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-non-extensible-spreadable.js @@ -0,0 +1,45 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible, argument is spreadable) +info: | + Array.prototype.concat ( ...arguments ) + + [...] + 5. Repeat, while items is not empty + [...] + c. If spreadable is true, then + [...] + iv. Repeat, while k < len + [...] + 3. If exists is true, then + [...] + b. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), subElement). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; + +var arr = []; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.concat([1]); +}, 'arr.concat([1]) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-non-extensible.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-non-extensible.js new file mode 100644 index 0000000000..a3bb4f0a60 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-non-extensible.js @@ -0,0 +1,43 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible, argument is not spreadable) +info: | + Array.prototype.concat ( ...arguments ) + + [...] + 5. Repeat, while items is not empty + [...] + c. If spreadable is true, then + [...] + d. Else, + [...] + iii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), E). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; + +var arr = []; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.concat(1); +}, 'arr.concat(1) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-null.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-null.js new file mode 100644 index 0000000000..0d0e7c7350 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-null.js @@ -0,0 +1,38 @@ +// 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-array.prototype.concat +description: > + A null value for the @@species constructor is interpreted as `undefined` +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). +features: [Symbol.species] +---*/ + +var a = []; +var result; + +a.constructor = {}; +a.constructor[Symbol.species] = null; + +result = a.concat(); + +assert.sameValue( + Object.getPrototypeOf(result), + Array.prototype, + 'Object.getPrototypeOf(a.concat()) returns Array.prototype' +); +assert(Array.isArray(result), 'Array.isArray(result) must return true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-poisoned.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-poisoned.js new file mode 100644 index 0000000000..a4f8cfe80a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-poisoned.js @@ -0,0 +1,33 @@ +// 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-array.prototype.concat +description: Abrupt completion from `@@species` property access +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). +features: [Symbol.species] +---*/ + +var a = []; +a.constructor = {}; + +Object.defineProperty(a.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + a.concat(); +}, 'a.concat() throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-undef.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-undef.js new file mode 100644 index 0000000000..0c64e02017 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-undef.js @@ -0,0 +1,40 @@ +// 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-array.prototype.concat +description: > + An undefined value for the @@species constructor triggers the creation of + an Array exotic object +info: | + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). +features: [Symbol.species] +---*/ + +var a = []; +var result; + +a.constructor = {}; +a.constructor[Symbol.species] = undefined; + +result = a.concat(); + +assert.sameValue( + Object.getPrototypeOf(result), + Array.prototype, + 'Object.getPrototypeOf(a.concat()) returns Array.prototype' +); +assert(Array.isArray(result), 'Array.isArray(result) must return true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js new file mode 100644 index 0000000000..49bbd170f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js @@ -0,0 +1,47 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable, argument is spreadable) +info: | + Array.prototype.concat ( ...arguments ) + + [...] + 5. Repeat, while items is not empty + [...] + c. If spreadable is true, then + [...] + iv. Repeat, while k < len + [...] + 3. If exists is true, then + [...] + b. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), subElement). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + writable: true, + configurable: false, + }); +}; + +var arr = []; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.concat([1]); +}, 'arr.concat([1]) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-configurable-property.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-configurable-property.js new file mode 100644 index 0000000000..cbb724f417 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-configurable-property.js @@ -0,0 +1,45 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable, argument is non-spreadable) +info: | + Array.prototype.concat ( ...arguments ) + + [...] + 5. Repeat, while items is not empty + [...] + c. If spreadable is true, then + [...] + d. Else, + [...] + iii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), E). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + set: function(_value) {}, + configurable: false, + }); +}; + +var arr = []; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.concat(1); +}, 'arr.concat(1) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js new file mode 100644 index 0000000000..98e0efc10d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js @@ -0,0 +1,49 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: > + Non-writable properties are overwritten by CreateDataProperty. + (result object's "0" is non-writable, argument is spreadable) +info: | + Array.prototype.concat ( ...arguments ) + + [...] + 5. Repeat, while items is not empty + [...] + c. If spreadable is true, then + [...] + iv. Repeat, while k < len + [...] + 3. If exists is true, then + [...] + b. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), subElement). + [...] +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + value: 1, + writable: false, + enumerable: false, + configurable: true, + }); +}; + +var arr = []; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +var res = arr.concat([2]); + +verifyProperty(res, "0", { + value: 2, + writable: true, + enumerable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-writable-property.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-writable-property.js new file mode 100644 index 0000000000..b9268c91b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-with-non-writable-property.js @@ -0,0 +1,49 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: > + Non-writable properties are overwritten by CreateDataProperty. + (result object's "0" is non-writable, argument is not spreadable) +info: | + Array.prototype.concat ( ...arguments ) + + [...] + 5. Repeat, while items is not empty + [...] + c. If spreadable is true, then + [...] + iv. Repeat, while k < len + [...] + 3. If exists is true, then + [...] + b. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), subElement). + [...] +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + value: 1, + writable: false, + enumerable: false, + configurable: true, + }); +}; + +var arr = []; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +var res = arr.concat(2); + +verifyProperty(res, "0", { + value: 2, + writable: true, + enumerable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/create-species.js b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species.js new file mode 100644 index 0000000000..60cc7138a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species.js @@ -0,0 +1,48 @@ +// 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-array.prototype.concat +description: Species constructor is used to create a new instance +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var thisValue, args, result; +var callCount = 0; +var instance = []; +var Ctor = function() { + callCount += 1; + thisValue = this; + args = arguments; + return instance; +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; + +result = a.concat(); + +assert.sameValue(callCount, 1, 'The value of callCount is expected to be 1'); +assert.sameValue( + Object.getPrototypeOf(thisValue), + Ctor.prototype, + 'Object.getPrototypeOf(this) returns Ctor.prototype' +); +assert.sameValue(args.length, 1, 'The value of args.length is expected to be 1'); +assert.sameValue(args[0], 0, 'The value of args[0] is expected to be 0'); +assert.sameValue(result, instance, 'The value of result is expected to equal the value of instance'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-get-err.js b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-get-err.js new file mode 100644 index 0000000000..e45bbd57ac --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-get-err.js @@ -0,0 +1,40 @@ +// 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-array.prototype.concat +description: Error thrown when accessing `Symbol.isConcatSpreadable` property +info: | + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let A be ArraySpeciesCreate(O, 0). + 4. ReturnIfAbrupt(A). + 5. Let n be 0. + 6. Let items be a List whose first element is O and whose subsequent + elements are, in left to right order, the arguments that were passed to + this function invocation. + 7. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the element. + b. Let spreadable be IsConcatSpreadable(E). + c. ReturnIfAbrupt(spreadable). + + ES6 22.1.3.1.1: Runtime Semantics: IsConcatSpreadable ( O ) + + 1. If Type(O) is not Object, return false. + 2. Let spreadable be Get(O, @@isConcatSpreadable). + 3. ReturnIfAbrupt(spreadable). +features: [Symbol.isConcatSpreadable] +---*/ + +var o = {}; + +Object.defineProperty(o, Symbol.isConcatSpreadable, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + Array.prototype.concat.call(o); +}, 'Array.prototype.concat.call(o) throws a Test262Error exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-get-order.js b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-get-order.js new file mode 100644 index 0000000000..847dee557b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-get-order.js @@ -0,0 +1,75 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: > + Symbol.isConcatSpreadable should be looked up once for `this value` and + once for each argument, after ArraySpeciesCreate routine. +info: | + Array.prototype.concat ( ...arguments ) + + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + [...] + 5. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the element. + b. Let spreadable be ? IsConcatSpreadable(E). + [...] + + ArraySpeciesCreate ( originalArray, length ) + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + + Runtime Semantics: IsConcatSpreadable ( O ) + + 1. If Type(O) is not Object, return false. + 2. Let spreadable be ? Get(O, @@isConcatSpreadable). + [...] +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ + +var calls = []; +var descConstructor = { + get: function() { + calls.push("constructor"); + return Array; + }, + configurable: true, +}; +var descSpreadable = { + get: function() { + calls.push("isConcatSpreadable"); + }, + configurable: true, +}; + +var arr1 = []; +Object.defineProperty(arr1, "constructor", descConstructor); +Object.defineProperty(arr1, Symbol.isConcatSpreadable, descSpreadable); + +assert.compareArray(arr1.concat(1), [1], 'arr1.concat(1) must return [1]'); +assert.compareArray( + calls, + ["constructor", "isConcatSpreadable"], + 'The value of calls is expected to be ["constructor", "isConcatSpreadable"]' +); + +calls = []; + +var arr2 = []; +var arg = {}; +Object.defineProperty(arr2, "constructor", descConstructor); +Object.defineProperty(arg, Symbol.isConcatSpreadable, descSpreadable); + +assert.compareArray(arr2.concat(arg), [arg], 'arr2.concat({}) must return [arg]'); +assert.compareArray( + calls, + ["constructor", "isConcatSpreadable"], + 'The value of calls is expected to be ["constructor", "isConcatSpreadable"]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js new file mode 100644 index 0000000000..e242f57045 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js @@ -0,0 +1,52 @@ +// 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-isconcatspreadable +description: Revoked proxy value produces a TypeError when supplied to IsArray +info: | + [...] + 5. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the + element. + b. Let spreadable be ? IsConcatSpreadable(E). + c. If spreadable is true, then + [...] + e. Else E is added as a single item rather than spread, + [...] + + ES6 22.1.3.1.1: Runtime Semantics: IsConcatSpreadable ( O ) + + 1. If Type(O) is not Object, return false. + 2. Let spreadable be ? Get(O, @@isConcatSpreadable). + 3. If spreadable is not undefined, return ToBoolean(spreadable). + 4. Return ? IsArray(O). + + 7.2.2 IsArray + + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is null, + throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy, Symbol.isConcatSpreadable] +---*/ + +var target = []; +var handle = Proxy.revocable(target, { + get: function(_, key) { + // Defer proxy revocation until after property access to ensure that the + // expected TypeError originates from the IsArray operation. + if (key === Symbol.isConcatSpreadable) { + handle.revoke(); + } + return target[key]; + } +}); + +assert.throws(TypeError, function() { + [].concat(handle.proxy); +}, '[].concat(handle.proxy) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js new file mode 100644 index 0000000000..41f4bfb6c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js @@ -0,0 +1,45 @@ +// 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-isconcatspreadable +description: > + Revoked proxy value produces a TypeError during access of + `Symbol.isConcatSpreadable` property +info: | + [...] + 5. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the + element. + b. Let spreadable be ? IsConcatSpreadable(E). + c. If spreadable is true, then + [...] + e. Else E is added as a single item rather than spread, + [...] + + ES6 22.1.3.1.1: Runtime Semantics: IsConcatSpreadable ( O ) + + 1. If Type(O) is not Object, return false. + 2. Let spreadable be ? Get(O, @@isConcatSpreadable). + + 7.3.1 Get + + [...] + 3. Return ? O.[[Get]](P, O). + + 9.5.8 [[Get]] + + [...] + 2. Let handler be O.[[ProxyHandler]]. + 3. If handler is null, throw a TypeError exception. +features: [Proxy] +---*/ + +var handle = Proxy.revocable([], {}); + +handle.revoke(); + +assert.throws(TypeError, function() { + [].concat(handle.proxy); +}, '[].concat(handle.proxy) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-proxy.js b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-proxy.js new file mode 100644 index 0000000000..52dde72e68 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-proxy.js @@ -0,0 +1,53 @@ +// 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-isconcatspreadable +description: > + Proxies who final targets are arrays are considered spreadable +info: | + [...] + 5. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the + element. + b. Let spreadable be ? IsConcatSpreadable(E). + c. If spreadable is true, then + [...] + e. Else E is added as a single item rather than spread, + [...] + + ES6 22.1.3.1.1: Runtime Semantics: IsConcatSpreadable ( O ) + + 1. If Type(O) is not Object, return false. + 2. Let spreadable be ? Get(O, @@isConcatSpreadable). + 3. If spreadable is not undefined, return ToBoolean(spreadable). + 4. Return ? IsArray(O). + + 7.2.2 IsArray + + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is null, + throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy, Symbol.isConcatSpreadable] +---*/ + +var arrayProxy = new Proxy([], {}); +var arrayProxyProxy = new Proxy(arrayProxy, {}); +var spreadable = {}; +spreadable[Symbol.isConcatSpreadable] = true; +var spreadableProxy = new Proxy(spreadable, {}); + +assert.sameValue([].concat(arrayProxy).length, 0, 'The value of [].concat(arrayProxy).length is expected to be 0'); +assert.sameValue( + [].concat(arrayProxyProxy).length, 0, 'The value of [].concat(arrayProxyProxy).length is expected to be 0' +); +assert.sameValue( + [].concat(spreadableProxy).length, + 0, + 'The value of [].concat(spreadableProxy).length is expected to be 0' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-val-falsey.js b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-val-falsey.js new file mode 100644 index 0000000000..c565bac64a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-val-falsey.js @@ -0,0 +1,57 @@ +// 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-array.prototype.concat +description: > + The `Symbol.isConcatSpreadable` property is defined and coerces to `false` +info: | + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let A be ArraySpeciesCreate(O, 0). + 4. ReturnIfAbrupt(A). + 5. Let n be 0. + 6. Let items be a List whose first element is O and whose subsequent + elements are, in left to right order, the arguments that were passed to + this function invocation. + 7. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the element. + b. Let spreadable be IsConcatSpreadable(E). + c. ReturnIfAbrupt(spreadable). + d. If spreadable is true, then + [...] + e. Else E is added as a single item rather than spread, + [...] + + ES6 22.1.3.1.1: Runtime Semantics: IsConcatSpreadable ( O ) + + 1. If Type(O) is not Object, return false. + 2. Let spreadable be Get(O, @@isConcatSpreadable). + 3. ReturnIfAbrupt(spreadable). + 4. If spreadable is not undefined, return ToBoolean(spreadable). +features: [Symbol.isConcatSpreadable] +---*/ + +var item = [1, 2]; +var result; + +item[Symbol.isConcatSpreadable] = null; +result = [].concat(item); +assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); +assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); + +item[Symbol.isConcatSpreadable] = false; +result = [].concat(item); +assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); +assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); + +item[Symbol.isConcatSpreadable] = 0; +result = [].concat(item); +assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); +assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); + +item[Symbol.isConcatSpreadable] = NaN; +result = [].concat(item); +assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); +assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-val-truthy.js b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-val-truthy.js new file mode 100644 index 0000000000..9f08bfe6b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-val-truthy.js @@ -0,0 +1,55 @@ +// 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-array.prototype.concat +description: > + The `Symbol.isConcatSpreadable` property is defined and coerces to `true` +info: | + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let A be ArraySpeciesCreate(O, 0). + 4. ReturnIfAbrupt(A). + 5. Let n be 0. + 6. Let items be a List whose first element is O and whose subsequent + elements are, in left to right order, the arguments that were passed to + this function invocation. + 7. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the element. + b. Let spreadable be IsConcatSpreadable(E). + c. ReturnIfAbrupt(spreadable). + d. If spreadable is true, then + [...] + + ES6 22.1.3.1.1: Runtime Semantics: IsConcatSpreadable ( O ) + + 1. If Type(O) is not Object, return false. + 2. Let spreadable be Get(O, @@isConcatSpreadable). + 3. ReturnIfAbrupt(spreadable). + 4. If spreadable is not undefined, return ToBoolean(spreadable). +features: [Symbol, Symbol.isConcatSpreadable] +---*/ + +var item = {}; +var result; + +item[Symbol.isConcatSpreadable] = true; +result = [].concat(item); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); + +item[Symbol.isConcatSpreadable] = 86; +result = [].concat(item); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); + +item[Symbol.isConcatSpreadable] = 'string'; +result = [].concat(item); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); + +item[Symbol.isConcatSpreadable] = Symbol(); +result = [].concat(item); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); + +item[Symbol.isConcatSpreadable] = {}; +result = [].concat(item); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-val-undefined.js b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-val-undefined.js new file mode 100644 index 0000000000..9a66a6a168 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-val-undefined.js @@ -0,0 +1,43 @@ +// 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-array.prototype.concat +description: > + The `Symbol.isConcatSpreadable` property is defined as the value `undefined` +info: | + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let A be ArraySpeciesCreate(O, 0). + 4. ReturnIfAbrupt(A). + 5. Let n be 0. + 6. Let items be a List whose first element is O and whose subsequent + elements are, in left to right order, the arguments that were passed to + this function invocation. + 7. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the element. + b. Let spreadable be IsConcatSpreadable(E). + c. ReturnIfAbrupt(spreadable). + d. If spreadable is true, then + [...] + e. Else E is added as a single item rather than spread, + [...] + + ES6 22.1.3.1.1: Runtime Semantics: IsConcatSpreadable ( O ) + + 1. If Type(O) is not Object, return false. + 2. Let spreadable be Get(O, @@isConcatSpreadable). + 3. ReturnIfAbrupt(spreadable). + 4. If spreadable is not undefined, return ToBoolean(spreadable). + 5. Return IsArray(O). +features: [Symbol.isConcatSpreadable] +---*/ + +var item = []; +var result; + +item[Symbol.isConcatSpreadable] = undefined; +result = [].concat(item); + +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/length.js b/js/src/tests/test262/built-ins/Array/prototype/concat/length.js new file mode 100644 index 0000000000..5bff590dfd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: > + The "length" property of Array.prototype.concat +info: | + 22.1.3.1 Array.prototype.concat ( ...arguments ) + + The length property of the concat method is 1. + + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.concat.length, 1, 'The value of Array.prototype.concat.length is expected to be 1'); + +verifyNotEnumerable(Array.prototype.concat, 'length'); +verifyNotWritable(Array.prototype.concat, 'length'); +verifyConfigurable(Array.prototype.concat, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/name.js b/js/src/tests/test262/built-ins/Array/prototype/concat/name.js new file mode 100644 index 0000000000..f81660ad08 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/name.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: > + Array.prototype.concat.name is "concat". +info: | + Array.prototype.concat ( ...arguments ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.concat.name, + "concat", + 'The value of Array.prototype.concat.name is expected to be "concat"' +); + +verifyNotEnumerable(Array.prototype.concat, "name"); +verifyNotWritable(Array.prototype.concat, "name"); +verifyConfigurable(Array.prototype.concat, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/concat/not-a-constructor.js new file mode 100644 index 0000000000..10bdab75dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/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: > + Array.prototype.concat 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.concat), + false, + 'isConstructor(Array.prototype.concat) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.concat([]); +}, 'new Array.prototype.concat([]) throws a TypeError exception'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/concat/prop-desc.js new file mode 100644 index 0000000000..6dc2ebc718 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.concat +description: > + "concat" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.concat, 'function', 'The value of `typeof Array.prototype.concat` is expected to be "function"'); + +verifyNotEnumerable(Array.prototype, "concat"); +verifyWritable(Array.prototype, "concat"); +verifyConfigurable(Array.prototype, "concat"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/shell.js b/js/src/tests/test262/built-ins/Array/prototype/concat/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/constructor.js b/js/src/tests/test262/built-ins/Array/prototype/constructor.js new file mode 100644 index 0000000000..93e2c2a863 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/constructor.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.constructor +description: > + Array.prototype.constructor +info: | + 22.1.3.2 Array.prototype.constructor + + The initial value of Array.prototype.constructor is the intrinsic object %Array%. + + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.constructor, Array); + +verifyNotEnumerable(Array.prototype, 'constructor'); +verifyWritable(Array.prototype, 'constructor'); +verifyConfigurable(Array.prototype, 'constructor'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/browser.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/call-with-boolean.js new file mode 100644 index 0000000000..27d06cec41 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/call-with-boolean.js @@ -0,0 +1,20 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.copyWithin +description: Array.prototype.copyWithin applied to boolean primitive +---*/ + +assert.sameValue( + Array.prototype.copyWithin.call(true) instanceof Boolean, + true, + 'The result of evaluating (Array.prototype.copyWithin.call(true) instanceof Boolean) is expected to be true' +); +assert.sameValue( + Array.prototype.copyWithin.call(false) instanceof Boolean, + true, + 'The result of evaluating (Array.prototype.copyWithin.call(false) instanceof Boolean) is expected to be true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-end.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-end.js new file mode 100644 index 0000000000..7759eea41d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-end.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-array.prototype.copywithin +description: > + end argument is coerced to an integer values. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, 0, null), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(1, 0, null) must return [0, 1, 2, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, 0, NaN), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(1, 0, NaN) must return [0, 1, 2, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, 0, false), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(1, 0, false) must return [0, 1, 2, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, 0, true), [0, 0, 2, 3], + '[0, 1, 2, 3].copyWithin(1, 0, true) must return [0, 0, 2, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, 0, '-2'), [0, 0, 1, 3], + '[0, 1, 2, 3].copyWithin(1, 0, "-2") must return [0, 0, 1, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, 0, -2.5), [0, 0, 1, 3], + '[0, 1, 2, 3].copyWithin(1, 0, -2.5) must return [0, 0, 1, 3]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start-change-start.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start-change-start.js new file mode 100644 index 0000000000..0692e72247 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start-change-start.js @@ -0,0 +1,57 @@ +// Copyright (C) 2019 Google. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.copywithin +description: > + SECURITY: start argument is coerced to an integer value + and side effects change the length of the array so that + the start is out of bounds +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 8. Let relativeStart be ToInteger(start). + ... +includes: [compareArray.js] +---*/ + + +// make a long integer Array +function longDenseArray(){ + var a = [0]; + for(var i = 0; i < 1024; i++){ + a[i] = i; + } + return a; +} + +function shorten(){ + currArray.length = 20; + return 1000; +} + +var array = []; +array.length = 20; + +var currArray = longDenseArray(); + +assert.compareArray( + currArray.copyWithin(0, {valueOf: shorten}), array, + 'currArray.copyWithin(0, {valueOf: shorten}) returns array' +); + +currArray = longDenseArray(); +Object.setPrototypeOf(currArray, longDenseArray()); + +var array2 = longDenseArray(); +array2.length = 20; +for(var i = 0; i < 24; i++){ + array2[i] = Object.getPrototypeOf(currArray)[i+1000]; +} + +assert.compareArray( + currArray.copyWithin(0, {valueOf: shorten}), array2, + 'currArray.copyWithin(0, {valueOf: shorten}) returns array2' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start-change-target.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start-change-target.js new file mode 100644 index 0000000000..cefe3e64a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start-change-target.js @@ -0,0 +1,46 @@ +// Copyright (C) 2019 Google. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.copywithin +description: > + SECURITY: start argument is coerced to an integer value + and side effects change the length of the array so that + the target is out of bounds +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 8. Let relativeStart be ToInteger(start). + ... +includes: [compareArray.js] +---*/ + + +// make a long integer Array +function longDenseArray(){ + var a = [0]; + for(var i = 0; i < 1024; i++){ + a[i] = i; + } + return a; +} + +function shorten(){ + currArray.length = 20; + return 1; +} + +var array = longDenseArray(); +array.length = 20; +for(var i = 0; i < 19; i++){ + array[i+1000] = array[i+1]; +} + +var currArray = longDenseArray(); + +assert.compareArray( + currArray.copyWithin(1000, {valueOf: shorten}), array, + 'currArray.copyWithin(1000, {valueOf: shorten}) returns array' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start.js new file mode 100644 index 0000000000..804e795b56 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start.js @@ -0,0 +1,58 @@ +// 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-array.prototype.copywithin +description: > + start argument is coerced to an integer value. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 8. Let relativeStart be ToInteger(start). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, undefined), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin(1, undefined) must return [0, 0, 1, 2]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, false), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin(1, false) must return [0, 0, 1, 2]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, NaN), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin(1, NaN) must return [0, 0, 1, 2]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, null), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin(1, null) must return [0, 0, 1, 2]' +); + + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, true), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0, true) must return [1, 2, 3, 3]' +); + + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, '1'), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0, "1") must return [1, 2, 3, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, 0.5), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin(1, 0.5) must return [0, 0, 1, 2]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1.5), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0, 1.5) must return [1, 2, 3, 3]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-target.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-target.js new file mode 100644 index 0000000000..dac3cfd53b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-target.js @@ -0,0 +1,63 @@ +// 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-array.prototype.copywithin +description: > + target argument is coerced to an integer value. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 5. Let relativeTarget be ToInteger(target). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(undefined, 1), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(undefined, 1) must return [1, 2, 3, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(false, 1), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(false, 1) must return [1, 2, 3, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(NaN, 1), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(NaN, 1) must return [1, 2, 3, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(null, 1), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(null, 1) must return [1, 2, 3, 3]' +); + + +assert.compareArray( + [0, 1, 2, 3].copyWithin(true, 0), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin(true, 0) must return [0, 0, 1, 2]' +); + + +assert.compareArray( + [0, 1, 2, 3].copyWithin('1', 0), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin("1", 0) must return [0, 0, 1, 2]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0.5, 1), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0.5, 1) must return [1, 2, 3, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(1.5, 0), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin(1.5, 0) must return [0, 0, 1, 2]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin({}, 1), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin({}, 1) must return [1, 2, 3, 3]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/fill-holes.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/fill-holes.js new file mode 100644 index 0000000000..972c5d82a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/fill-holes.js @@ -0,0 +1,20 @@ +// 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-array.prototype.copywithin +description: > + Loop from each property, even empty holes. +---*/ + +var arr = [0, 1, , , 1]; + +arr.copyWithin(0, 1, 4); + +assert.sameValue(arr.length, 5); +assert.sameValue(arr[0], 1); +assert.sameValue(arr[4], 1); +assert.sameValue(arr.hasOwnProperty(1), false); +assert.sameValue(arr.hasOwnProperty(2), false); +assert.sameValue(arr.hasOwnProperty(3), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/length-near-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/length-near-integer-limit.js new file mode 100644 index 0000000000..ba7b59991a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/length-near-integer-limit.js @@ -0,0 +1,45 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.copywithin +description: > + Elements are copied and deleted in an array-like object + whose "length" property is near the integer limit. +info: | + Array.prototype.copyWithin ( target, start [ , end ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + [...] + 9. Let count be min(final - from, len - to). + [...] + 12. Repeat, while count > 0 + [...] + d. If fromPresent is true, then + i. Let fromVal be ? Get(O, fromKey). + ii. Perform ? Set(O, toKey, fromVal, true). + e. Else, + i. Assert: fromPresent is false. + ii. Perform ? DeletePropertyOrThrow(O, toKey). + [...] +---*/ + +var startIndex = Number.MAX_SAFE_INTEGER - 3; +var arrayLike = { + 0: 0, + 1: 1, + 2: 2, + length: Number.MAX_SAFE_INTEGER, +}; + +arrayLike[startIndex] = -3; +arrayLike[startIndex + 2] = -1; + +Array.prototype.copyWithin.call(arrayLike, 0, startIndex, startIndex + 3); + +assert.sameValue(arrayLike[0], -3); +assert.sameValue(1 in arrayLike, false); +assert.sameValue(arrayLike[2], -1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/length.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/length.js new file mode 100644 index 0000000000..e846f74754 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/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-array.prototype.copywithin +description: Array.prototype.copyWithin.length value and descriptor. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + The length property of the copyWithin method is 2. +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.copyWithin.length, 2, + 'The value of `Array.prototype.copyWithin.length` is `2`' +); + +verifyNotEnumerable(Array.prototype.copyWithin, 'length'); +verifyNotWritable(Array.prototype.copyWithin, 'length'); +verifyConfigurable(Array.prototype.copyWithin, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/name.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/name.js new file mode 100644 index 0000000000..c8c6c0b5b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/name.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-array.prototype.copywithin +description: > + Array.prototype.copyWithin.name value and descriptor. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.copyWithin.name, 'copyWithin', + 'The value of `Array.prototype.copyWithin.name` is `"copyWithin"`' +); + +verifyNotEnumerable(Array.prototype.copyWithin, 'name'); +verifyNotWritable(Array.prototype.copyWithin, 'name'); +verifyConfigurable(Array.prototype.copyWithin, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-end.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-end.js new file mode 100644 index 0000000000..3bea4299b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-end.js @@ -0,0 +1,60 @@ +// 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-array.prototype.copywithin +description: > + Set values with negative end argument. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 12. ReturnIfAbrupt(relativeEnd). + 13. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let + final be min(relativeEnd, len). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1, -1), [1, 2, 2, 3], + '[0, 1, 2, 3].copyWithin(0, 1, -1) must return [1, 2, 2, 3]' +); + +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(2, 0, -1), [0, 1, 0, 1, 2], + '[0, 1, 2, 3, 4].copyWithin(2, 0, -1) must return [0, 1, 0, 1, 2]' +); + +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(1, 2, -2), [0, 2, 2, 3, 4], + '[0, 1, 2, 3, 4].copyWithin(1, 2, -2) must return [0, 2, 2, 3, 4]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, -2, -1), [2, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, -2, -1) must return [2, 1, 2, 3]' +); + +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(2, -2, -1), [0, 1, 3, 3, 4], + '[0, 1, 2, 3, 4].copyWithin(2, -2, -1) must return [0, 1, 3, 3, 4]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(-3, -2, -1), [0, 2, 2, 3], + '[0, 1, 2, 3].copyWithin(-3, -2, -1) must return [0, 2, 2, 3]' +); + +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(-2, -3, -1), [0, 1, 2, 2, 3], + '[0, 1, 2, 3, 4].copyWithin(-2, -3, -1) must return [0, 1, 2, 2, 3]' +); + +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(-5, -2, -1), [3, 1, 2, 3, 4], + '[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) must return [3, 1, 2, 3, 4]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-end.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-end.js new file mode 100644 index 0000000000..acd8f91c95 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-end.js @@ -0,0 +1,70 @@ +// 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-array.prototype.copywithin +description: > + Set values with negative out of bounds end argument. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 12. ReturnIfAbrupt(relativeEnd). + 13. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let + final be min(relativeEnd, len). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1, -10), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, 1, -10) must return [0, 1, 2, 3]' +); + +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity) must return [1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, -2, -10), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, -2, -10) must return [0, 1, 2, 3]' +); + +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity) must return [1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, -9, -10), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, -9, -10) must return [0, 1, 2, 3]' +); + +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity) must return [1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(-3, -2, -10), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(-3, -2, -10) must return [0, 1, 2, 3]' +); + +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity) must return [1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(-7, -8, -9), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(-7, -8, -9) must return [0, 1, 2, 3]' +); + +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) must return [1, 2, 3, 4, 5]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-start.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-start.js new file mode 100644 index 0000000000..7faf5378eb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-start.js @@ -0,0 +1,59 @@ +// 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-array.prototype.copywithin +description: > + Set values with out of bounds negative start argument. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, -10), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, -10) must return [0, 1, 2, 3]' +); + +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(0, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(0, -Infinity) must return [1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(2, -10), [0, 1, 0, 1, 2], + '[0, 1, 2, 3, 4].copyWithin(2, -10) must return [0, 1, 0, 1, 2]' +); + +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(2, -Infinity), [1, 2, 1, 2, 3], + '[1, 2, 3, 4, 5].copyWithin(2, -Infinity) must return [1, 2, 1, 2, 3]' +); + + +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(10, -10), [0, 1, 2, 3, 4], + '[0, 1, 2, 3, 4].copyWithin(10, -10) must return [0, 1, 2, 3, 4]' +); + +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(10, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(10, -Infinity) must return [1, 2, 3, 4, 5]' +); + + +assert.compareArray( + [0, 1, 2, 3].copyWithin(-9, -10), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(-9, -10) must return [0, 1, 2, 3]' +); + +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(-9, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) must return [1, 2, 3, 4, 5]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-target.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-target.js new file mode 100644 index 0000000000..6bc927c1fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-target.js @@ -0,0 +1,37 @@ +// 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-array.prototype.copywithin +description: > + Set values with out of bounds negative target argument. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to + be min(relativeTarget, len). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(-10, 0), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(-10, 0) must return [0, 1, 2, 3]' +); + +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(-Infinity, 0), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(-Infinity, 0) must return [1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(-10, 2), [2, 3, 4, 3, 4], + '[0, 1, 2, 3, 4].copyWithin(-10, 2) must return [2, 3, 4, 3, 4]' +); + +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(-Infinity, 2), [3, 4, 5, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) must return [3, 4, 5, 4, 5]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-start.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-start.js new file mode 100644 index 0000000000..9bed566c60 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-start.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-array.prototype.copywithin +description: > + Set values with negative start argument. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, -1), [3, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, -1) must return [3, 1, 2, 3]' +); + +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(2, -2), [0, 1, 3, 4, 4], + '[0, 1, 2, 3, 4].copyWithin(2, -2) must return [0, 1, 3, 4, 4]' +); + +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(1, -2), [0, 3, 4, 3, 4], + '[0, 1, 2, 3, 4].copyWithin(1, -2) must return [0, 3, 4, 3, 4]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(-1, -2), [0, 1, 2, 2], + '[0, 1, 2, 3].copyWithin(-1, -2) must return [0, 1, 2, 2]' +); + +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(-2, -3), [0, 1, 2, 2, 3], + '[0, 1, 2, 3, 4].copyWithin(-2, -3) must return [0, 1, 2, 2, 3]' +); + +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(-5, -2), [3, 4, 2, 3, 4], + '[0, 1, 2, 3, 4].copyWithin(-5, -2) must return [3, 4, 2, 3, 4]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-target.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-target.js new file mode 100644 index 0000000000..232ddf0d2d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-target.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-array.prototype.copywithin +description: > + Set values with negative target argument. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to + be min(relativeTarget, len). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(-1, 0), [0, 1, 2, 0], + '[0, 1, 2, 3].copyWithin(-1, 0) must return [0, 1, 2, 0]' +); + +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(-2, 2), [0, 1, 2, 2, 3], + '[0, 1, 2, 3, 4].copyWithin(-2, 2) must return [0, 1, 2, 2, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(-1, 2), [0, 1, 2, 2], + '[0, 1, 2, 3].copyWithin(-1, 2) must return [0, 1, 2, 2]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-out-of-bounds-end.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-out-of-bounds-end.js new file mode 100644 index 0000000000..079beae545 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-out-of-bounds-end.js @@ -0,0 +1,56 @@ +// 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-array.prototype.copywithin +description: > + Max value of end position is the this.length. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to + be min(relativeTarget, len). + ... + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + ... + 14. Let count be min(final-from, len-to). + 15. If from 0 + ... + a. If fromPresent is true, then + i. Let fromVal be Get(O, fromKey). + ... + iii. Let setStatus be Set(O, toKey, fromVal, true). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1, 6), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0, 1, 6) must return [1, 2, 3, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1, Infinity), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0, 1, Infinity) must return [1, 2, 3, 3]' +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6), [0, 3, 4, 5, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6) must return [0, 3, 4, 5, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(1, 3, Infinity), [0, 3, 4, 5, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) must return [0, 3, 4, 5, 4, 5]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js new file mode 100644 index 0000000000..13f3ff3388 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js @@ -0,0 +1,107 @@ +// 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-array.prototype.copywithin +description: > + Max values of target and start positions are this.length. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to + be min(relativeTarget, len). + ... + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + ... + 14. Let count be min(final-from, len-to). + 15. If from 0 + ... + ... +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(6, 0), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(6, 0) must return [0, 1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(7, 0), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(7, 0) must return [0, 1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(Infinity, 0), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(Infinity, 0) must return [0, 1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(6, 2), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(6, 2) must return [0, 1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(7, 2), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(7, 2) must return [0, 1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(Infinity, 2), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(Infinity, 2) must return [0, 1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(0, 6), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(0, 6) must return [0, 1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(0, 7), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(0, 7) must return [0, 1, 2, 3, 4, 5]' +); + + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(0, Infinity), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(0, Infinity) must return [0, 1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(2, 6), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(2, 6) must return [0, 1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(1, 7), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(1, 7) must return [0, 1, 2, 3, 4, 5]' +); + + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(3, Infinity), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(3, Infinity) must return [0, 1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(6, 6), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(6, 6) must return [0, 1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(10, 10), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(10, 10) must return [0, 1, 2, 3, 4, 5]' +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(Infinity, Infinity), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) must return [0, 1, 2, 3, 4, 5]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-target-and-start.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-target-and-start.js new file mode 100644 index 0000000000..da1d411abc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-target-and-start.js @@ -0,0 +1,54 @@ +// 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-array.prototype.copywithin +description: > + Copy values with non-negative target and start positions. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to + be min(relativeTarget, len). + ... + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + ... + 14. Let count be min(final-from, len-to). + 15. If from 0 + ... + a. If fromPresent is true, then + i. Let fromVal be Get(O, fromKey). + ... + iii. Let setStatus be Set(O, toKey, fromVal, true). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray( + ['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(0, 0), + ['a', 'b', 'c', 'd', 'e', 'f'] +); + +assert.compareArray( + ['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(0, 2), + ['c', 'd', 'e', 'f', 'e', 'f'] +); + +assert.compareArray( + ['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(3, 0), + ['a', 'b', 'c', 'a', 'b', 'c'] +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(1, 4), + [0, 4, 5, 3, 4, 5] +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-target-start-and-end.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-target-start-and-end.js new file mode 100644 index 0000000000..ffbda9c208 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-target-start-and-end.js @@ -0,0 +1,72 @@ +// 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-array.prototype.copywithin +description: > + Copy values with non-negative target, start and end positions. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to + be min(relativeTarget, len). + ... + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + ... + 14. Let count be min(final-from, len-to). + 15. If from 0 + ... + a. If fromPresent is true, then + i. Let fromVal be Get(O, fromKey). + ... + iii. Let setStatus be Set(O, toKey, fromVal, true). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 0, 0), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, 0, 0) must return [0, 1, 2, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 0, 2), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, 0, 2) must return [0, 1, 2, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1, 2), [1, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, 1, 2) must return [1, 1, 2, 3]' +); + +/* + * 15. If from + Array.prototype.copyWithin 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.copyWithin), + false, + 'isConstructor(Array.prototype.copyWithin) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.copyWithin(); +}, '`new Array.prototype.copyWithin()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/prop-desc.js new file mode 100644 index 0000000000..0142ba32ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/prop-desc.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-array.prototype.copywithin +description: Property type and descriptor. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Array.prototype.copyWithin, + 'function', + '`typeof Array.prototype.copyWithin` is `function`' +); + +verifyNotEnumerable(Array.prototype, 'copyWithin'); +verifyWritable(Array.prototype, 'copyWithin'); +verifyConfigurable(Array.prototype, 'copyWithin'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-delete-proxy-target.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-delete-proxy-target.js new file mode 100644 index 0000000000..efbb992e30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-delete-proxy-target.js @@ -0,0 +1,40 @@ +// 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-array.prototype.copywithin +description: > + Return abrupt from deleting property value - using Proxy +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 17. Repeat, while count > 0 + a. Let fromKey be ToString(from). + b. Let toKey be ToString(to). + c. Let fromPresent be HasProperty(O, fromKey). + ... + f. Else fromPresent is false, + i. Let deleteStatus be DeletePropertyOrThrow(O, toKey). + ii. ReturnIfAbrupt(deleteStatus). + ... +features: [Proxy] +---*/ + +var o = { + '42': true, + length: 43 +}; + +var p = new Proxy(o, { + deleteProperty: function(t, prop) { + if (prop === '42') { + throw new Test262Error(); + } + } +}); + +assert.throws(Test262Error, function() { + Array.prototype.copyWithin.call(p, 42, 0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-delete-target.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-delete-target.js new file mode 100644 index 0000000000..14c970ecb5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-delete-target.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-array.prototype.copywithin +description: > + Return abrupt from deleting property value on DeletePropertyOrThrow(O, toKey). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 17. Repeat, while count > 0 + a. Let fromKey be ToString(from). + b. Let toKey be ToString(to). + c. Let fromPresent be HasProperty(O, fromKey). + ... + f. Else fromPresent is false, + i. Let deleteStatus be DeletePropertyOrThrow(O, toKey). + ii. ReturnIfAbrupt(deleteStatus). + ... +---*/ + +var o = { + length: 43 +}; + +Object.defineProperty(o, '42', { + configurable: false, + writable: true +}); + +assert.throws(TypeError, function() { + Array.prototype.copyWithin.call(o, 42, 0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-end-as-symbol.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-end-as-symbol.js new file mode 100644 index 0000000000..345ad8d3c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-end-as-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-array.prototype.copywithin +description: > + Return abrupt from end as a Symbol. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 12. ReturnIfAbrupt(relativeEnd). + ... +features: [Symbol] +---*/ + +var s = Symbol(1); +assert.throws(TypeError, function() { + [].copyWithin(0, 0, s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-end.js new file mode 100644 index 0000000000..cfe2a7353f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-end.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-array.prototype.copywithin +description: > + Return abrupt from ToInteger(end). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 12. ReturnIfAbrupt(relativeEnd). + ... +---*/ + +var o1 = { + valueOf: function() { + throw new Test262Error(); + } +}; +assert.throws(Test262Error, function() { + [].copyWithin(0, 0, o1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-get-start-value.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-get-start-value.js new file mode 100644 index 0000000000..559520b1c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-get-start-value.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-array.prototype.copywithin +description: > + Return abrupt from getting property value - Get(O, fromKey). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 8. Let relativeStart be ToInteger(start). + 9. ReturnIfAbrupt(relativeStart). + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). + ... + 17. Repeat, while count > 0 + a. Let fromKey be ToString(from). + b. Let toKey be ToString(to). + c. Let fromPresent be HasProperty(O, fromKey). + d. ReturnIfAbrupt(fromPresent). + e. If fromPresent is true, then + i. Let fromVal be Get(O, fromKey). + ii. ReturnIfAbrupt(fromVal). + ... +---*/ + +var o = { + length: 1 +}; + +Object.defineProperty(o, '0', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + Array.prototype.copyWithin.call(o, 0, 0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-has-start.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-has-start.js new file mode 100644 index 0000000000..8a7d16735c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-has-start.js @@ -0,0 +1,40 @@ +// 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-array.prototype.copywithin +description: > + Return abrupt from HasProperty(O, fromKey). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 8. Let relativeStart be ToInteger(start). + 9. ReturnIfAbrupt(relativeStart). + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). + ... + 17. Repeat, while count > 0 + a. Let fromKey be ToString(from). + b. Let toKey be ToString(to). + c. Let fromPresent be HasProperty(O, fromKey). + d. ReturnIfAbrupt(fromPresent). + ... +features: [Proxy] +---*/ + +var o = { + '0': 42, + length: 1 +}; + +var p = new Proxy(o, { + has: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + Array.prototype.copyWithin.call(p, 0, 0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-set-target-value.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-set-target-value.js new file mode 100644 index 0000000000..fa66f8a706 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-set-target-value.js @@ -0,0 +1,42 @@ +// 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-array.prototype.copywithin +description: > + Return abrupt from setting property value - Set(O, toKey, fromVal, true). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 5. Let relativeTarget be ToInteger(target). + 6. ReturnIfAbrupt(relativeTarget). + 7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to + be min(relativeTarget, len). + ... + 17. Repeat, while count > 0 + a. Let fromKey be ToString(from). + b. Let toKey be ToString(to). + ... + e. If fromPresent is true, then + ... + iii. Let setStatus be Set(O, toKey, fromVal, true). + iv. ReturnIfAbrupt(setStatus). + ... +---*/ + +var o = { + '0': true, + length: 43 +}; + +Object.defineProperty(o, '42', { + set: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + Array.prototype.copyWithin.call(o, 42, 0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-start-as-symbol.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-start-as-symbol.js new file mode 100644 index 0000000000..a766cafaeb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-start-as-symbol.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-array.prototype.copywithin +description: > + Return abrupt from start as a Symbol. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 8. Let relativeStart be ToInteger(start). + 9. ReturnIfAbrupt(relativeStart). + ... +features: [Symbol] +---*/ + +var s = Symbol(1); +assert.throws(TypeError, function() { + [].copyWithin(0, s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-start.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-start.js new file mode 100644 index 0000000000..93eb3cf5d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-start.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-array.prototype.copywithin +description: > + Return abrupt from ToInteger(start). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 8. Let relativeStart be ToInteger(start). + 9. ReturnIfAbrupt(relativeStart). + ... +---*/ + +var o1 = { + valueOf: function() { + throw new Test262Error(); + } +}; +assert.throws(Test262Error, function() { + [].copyWithin(0, o1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-target-as-symbol.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-target-as-symbol.js new file mode 100644 index 0000000000..2c318faa5e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-target-as-symbol.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-array.prototype.copywithin +description: > + Return abrupt from target as a Symbol. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 5. Let relativeTarget be ToInteger(target). + 6. ReturnIfAbrupt(relativeTarget). + ... +features: [Symbol] +---*/ + +var s = Symbol(1); +assert.throws(TypeError, function() { + [].copyWithin(s, 0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-target.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-target.js new file mode 100644 index 0000000000..4eb0d794b0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-target.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-array.prototype.copywithin +description: > + Return abrupt from ToInteger(target). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 5. Let relativeTarget be ToInteger(target). + 6. ReturnIfAbrupt(relativeTarget). + ... +---*/ + +var o1 = { + valueOf: function() { + throw new Test262Error(); + } +}; +assert.throws(Test262Error, function() { + [].copyWithin(o1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-this-length-as-symbol.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-this-length-as-symbol.js new file mode 100644 index 0000000000..51de5bcc74 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-this-length-as-symbol.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-array.prototype.copywithin +description: > + Return abrupt from ToLength(Get(O, "length")) where length is a Symbol. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let len be ToLength(Get(O, "length")). + 4. ReturnIfAbrupt(len). +features: [Symbol] +---*/ + +var o = {}; + +o.length = Symbol(1); + +// value argument is given to avoid false positives +assert.throws(TypeError, function() { + [].copyWithin.call(o, 0, 0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-this-length.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-this-length.js new file mode 100644 index 0000000000..99f789d9e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-this-length.js @@ -0,0 +1,38 @@ +// 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-array.prototype.copywithin +description: > + Return abrupt from ToLength(Get(O, "length")). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let len be ToLength(Get(O, "length")). + 4. ReturnIfAbrupt(len). +---*/ + +var o1 = {}; + +Object.defineProperty(o1, 'length', { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + [].copyWithin.call(o1); +}); + +var o2 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; +assert.throws(Test262Error, function() { + [].copyWithin.call(o2); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-this.js new file mode 100644 index 0000000000..52b27cc214 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-abrupt-from-this.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-array.prototype.copywithin +description: > + Return abrupt from ToObject(this value). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +assert.throws(TypeError, function() { + Array.prototype.copyWithin.call(undefined, 0, 0); +}); + +assert.throws(TypeError, function() { + Array.prototype.copyWithin.call(null, 0, 0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-this.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-this.js new file mode 100644 index 0000000000..6a60d8479f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/return-this.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-array.prototype.copywithin +description: > + Returns `this`. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + 18. Return O. +---*/ + +var arr = []; +var result = arr.copyWithin(0, 0); + +assert.sameValue(result, arr); + +var o = { + length: 0 +}; +result = Array.prototype.copyWithin.call(o, 0, 0); +assert.sameValue(result, o); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/shell.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/undefined-end.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/undefined-end.js new file mode 100644 index 0000000000..ae2f4e3256 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/undefined-end.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-array.prototype.copywithin +description: > + If `end` is undefined, set final position to `this.length`. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1, undefined), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0, 1, undefined) must return [1, 2, 3, 3]' +); + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0, 1) must return [1, 2, 3, 3]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/browser.js b/js/src/tests/test262/built-ins/Array/prototype/entries/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/iteration-mutable.js b/js/src/tests/test262/built-ins/Array/prototype/entries/iteration-mutable.js new file mode 100644 index 0000000000..b69fb5927a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/iteration-mutable.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-array.prototype.entries +description: > + New items in the array are accessible via iteration until iterator is "done". +info: | + The method should return a valid iterator with the context as the + IteratedObject. When an item is added to the array after the iterator is + created but before the iterator is "done" (as defined by 22.1.5.2.1) the + new item should be accessible via iteration. +---*/ + +var array = []; +var iterator = array.entries(); +var result; + +array.push('a'); + +result = iterator.next(); +assert.sameValue(result.done, false, 'First result `done` flag'); +assert.sameValue(result.value[0], 0, 'First result `value` (array key)'); +assert.sameValue(result.value[1], 'a', 'First result `value (array value)'); +assert.sameValue(result.value.length, 2, 'First result `value` (length)'); + +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); + +array.push('b'); + +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag (after push)'); +assert.sameValue(result.value, undefined, 'Exhausted result `value` (after push)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/iteration.js b/js/src/tests/test262/built-ins/Array/prototype/entries/iteration.js new file mode 100644 index 0000000000..ce725c24db --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/iteration.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-array.prototype.entries +description: > + The return is a valid iterator with the array's numeric properties. +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key+value"). +---*/ + +var array = ['a', 'b', 'c']; +var iterator = array.entries(); +var result; + +result = iterator.next(); +assert.sameValue(result.done, false, 'First result `done` flag'); +assert.sameValue(result.value[0], 0, 'First result `value` (array key)'); +assert.sameValue(result.value[1], 'a', 'First result `value` (array value)'); +assert.sameValue(result.value.length, 2, 'First result `value` (length)'); + +result = iterator.next(); +assert.sameValue(result.done, false, 'Second result `done` flag'); +assert.sameValue(result.value[0], 1, 'Second result `value` (array key)'); +assert.sameValue(result.value[1], 'b', 'Second result `value` (array value)'); +assert.sameValue(result.value.length, 2, 'Second result `value` (length)'); + +result = iterator.next(); +assert.sameValue(result.done, false, 'Third result `done` flag'); +assert.sameValue(result.value[0], 2, 'Third result `value` (array key)'); +assert.sameValue(result.value[1], 'c', 'Third result `value` (array value)'); +assert.sameValue(result.value.length, 2, 'Third result `value` (length)'); + +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/length.js b/js/src/tests/test262/built-ins/Array/prototype/entries/length.js new file mode 100644 index 0000000000..28f3093b6b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/length.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-array.prototype.entries +description: > + Array.prototype.entries.length value and descriptor. +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.entries.length, 0, + 'The value of `Array.prototype.entries.length` is `0`' +); + +verifyNotEnumerable(Array.prototype.entries, 'length'); +verifyNotWritable(Array.prototype.entries, 'length'); +verifyConfigurable(Array.prototype.entries, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/name.js b/js/src/tests/test262/built-ins/Array/prototype/entries/name.js new file mode 100644 index 0000000000..db9cd7a5d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/name.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-array.prototype.entries +description: > + Array.prototype.entries.name value and descriptor. +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.entries.name, 'entries', + 'The value of `Array.prototype.entries.name` is `"entries"`' +); + +verifyNotEnumerable(Array.prototype.entries, 'name'); +verifyNotWritable(Array.prototype.entries, 'name'); +verifyConfigurable(Array.prototype.entries, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/entries/not-a-constructor.js new file mode 100644 index 0000000000..7629f5b507 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/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: > + Array.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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.entries), + false, + 'isConstructor(Array.prototype.entries) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.entries(); +}, '`new Array.prototype.entries()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/entries/prop-desc.js new file mode 100644 index 0000000000..c04251a9a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/prop-desc.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-array.prototype.entries +description: > + Property type and descriptor. +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Array.prototype.entries, + 'function', + '`typeof Array.prototype.entries` is `function`' +); + +verifyNotEnumerable(Array.prototype, 'entries'); +verifyWritable(Array.prototype, 'entries'); +verifyConfigurable(Array.prototype, 'entries'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/Array/prototype/entries/return-abrupt-from-this.js new file mode 100644 index 0000000000..91a57bf125 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/return-abrupt-from-this.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-array.prototype.entries +description: > + Return abrupt from ToObject(this value). +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +assert.throws(TypeError, function() { + Array.prototype.entries.call(undefined); +}); + +assert.throws(TypeError, function() { + Array.prototype.entries.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator-from-object.js b/js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator-from-object.js new file mode 100644 index 0000000000..2a4ba60806 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator-from-object.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-array.prototype.entries +description: > + Creates an iterator from a custom object. +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key+value"). +features: [Symbol.iterator] +---*/ + +var obj = { + length: 2 +}; +var iter = Array.prototype.entries.call(obj); +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].entries() is %ArrayIteratorPrototype%' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator.js b/js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator.js new file mode 100644 index 0000000000..f07261270e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator.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-array.prototype.entries +description: > + The method should return an Iterator instance. +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key+value"). + + 22.1.5.1 CreateArrayIterator Abstract Operation + + ... + 2. Let iterator be ObjectCreate(%ArrayIteratorPrototype%, «‍[[IteratedObject]], + [[ArrayIteratorNextIndex]], [[ArrayIterationKind]]»). + ... + 6. Return iterator. +features: [Symbol.iterator] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); +var iter = [].entries(); + +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].entries() is %ArrayIteratorPrototype%' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/shell.js b/js/src/tests/test262/built-ins/Array/prototype/entries/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-0-1.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-0-1.js new file mode 100644 index 0000000000..5748303499 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-0-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every must exist as a function +---*/ + +var f = Array.prototype.every; + +assert.sameValue(typeof(f), "function", 'typeof(f)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-1.js new file mode 100644 index 0000000000..28ea6d417b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to undefined throws a TypeError +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.every.call(undefined); // TypeError is thrown if value is undefined +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-10.js new file mode 100644 index 0000000000..84d73fedf7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-10.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to the Math object +---*/ + +function callbackfn(val, idx, obj) { + return ('[object Math]' !== Object.prototype.toString.call(obj)); +} + +Math.length = 1; +Math[0] = 1; + +assert.sameValue(Array.prototype.every.call(Math, callbackfn), false, 'Array.prototype.every.call(Math, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-11.js new file mode 100644 index 0000000000..07413cbbab --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-11.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to Date object +---*/ + +function callbackfn(val, idx, obj) { + return !(obj instanceof Date); +} + +var obj = new Date(); +obj.length = 1; +obj[0] = 1; + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-12.js new file mode 100644 index 0000000000..725940e814 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-12.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to RegExp object +---*/ + +function callbackfn(val, idx, obj) { + return !(obj instanceof RegExp); +} + +var obj = new RegExp(); +obj.length = 1; +obj[0] = 1; + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-13.js new file mode 100644 index 0000000000..b4a4ee5a5b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-13.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to the JSON object +---*/ + +function callbackfn(val, idx, obj) { + return ('[object JSON]' !== Object.prototype.toString.call(obj)); +} + +JSON.length = 1; +JSON[0] = 1; + +assert.sameValue(Array.prototype.every.call(JSON, callbackfn), false, 'Array.prototype.every.call(JSON, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-14.js new file mode 100644 index 0000000000..89ff1df9e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-14.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to Error object +---*/ + +function callbackfn(val, idx, obj) { + return !(obj instanceof Error); +} + +var obj = new Error(); +obj.length = 1; +obj[0] = 1; + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-15.js new file mode 100644 index 0000000000..a6ffd11526 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-15.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to the Arguments object +---*/ + +function callbackfn(val, idx, obj) { + return ('[object Arguments]' !== Object.prototype.toString.call(obj)); +} + +var obj = (function fun() { + return arguments; +}("a", "b")); + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-2.js new file mode 100644 index 0000000000..d3ca2b6104 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to null throws a TypeError +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.every.call(null); // TypeError is thrown if value is null +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-3.js new file mode 100644 index 0000000000..53710c52a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-3.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to boolean primitive +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return obj instanceof Boolean; +} + +Boolean.prototype[0] = 1; +Boolean.prototype.length = 1; + +assert(Array.prototype.every.call(false, callbackfn), 'Array.prototype.every.call(false, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-4.js new file mode 100644 index 0000000000..502fddcc8b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-4.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to Boolean object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return obj instanceof Boolean; +} + +var obj = new Boolean(true); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-5.js new file mode 100644 index 0000000000..7f705289f6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-5.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to number primitive +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return obj instanceof Number; +} + +Number.prototype[0] = 1; +Number.prototype.length = 1; + +assert(Array.prototype.every.call(2.5, callbackfn), 'Array.prototype.every.call(2.5, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-6.js new file mode 100644 index 0000000000..1900feccdb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-6.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to Number object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return obj instanceof Number; +} + +var obj = new Number(-128); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-7.js new file mode 100644 index 0000000000..11a157862b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-7.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to string primitive +---*/ + +function callbackfn(val, idx, obj) { + return !(obj instanceof String); +} + +assert.sameValue(Array.prototype.every.call("hello\nworld\\!", callbackfn), false, 'Array.prototype.every.call("hello\nworld\\!", callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-8.js new file mode 100644 index 0000000000..8c91c089e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-8.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to String object +---*/ + +function callbackfn(val, idx, obj) { + return !(obj instanceof String); +} + +var obj = new String("hello\nworld\\!"); + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-9.js new file mode 100644 index 0000000000..b6f878e640 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-1-9.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to Function object +---*/ + +function callbackfn(val, idx, obj) { + return !(obj instanceof Function); +} + +var obj = function(a, b) { + return a + b; +}; +obj[0] = 11; +obj[1] = 9; + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-1.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-1.js new file mode 100644 index 0000000000..bb4777ce82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + own data property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2 +}; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-10.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-10.js new file mode 100644 index 0000000000..1fb57d459f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-10.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + inherited accessor property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert(Array.prototype.every.call(child, callbackfn1), 'Array.prototype.every.call(child, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(child, callbackfn2), false, 'Array.prototype.every.call(child, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-11.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-11.js new file mode 100644 index 0000000000..0c4a6515d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-11.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + own accessor property without a get function +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 9, + 1: 8 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-12.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-12.js new file mode 100644 index 0000000000..06ac2af411 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-12.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is own accessor property without + a get function that overrides an inherited accessor property +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var obj = { + 0: 9, + 1: 8 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-13.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-13.js new file mode 100644 index 0000000000..3dfed8d28c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-13.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to the Array-like object that + 'length' is inherited accessor property without a get function +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 9; +child[1] = 8; + +assert(Array.prototype.every.call(child, callbackfn), 'Array.prototype.every.call(child, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-14.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-14.js new file mode 100644 index 0000000000..5ba3993d15 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-14.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to the Array-like object that + 'length' property doesn't exist +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + 1: 12 +}; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-17.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-17.js new file mode 100644 index 0000000000..d6d41c06ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-17.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to the Arguments object, which + implements its own property get method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var func = function(a, b) { + arguments[2] = 9; + return Array.prototype.every.call(arguments, callbackfn1) && + !Array.prototype.every.call(arguments, callbackfn2); +}; + +assert(func(12, 11), 'func(12, 11) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-18.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-18.js new file mode 100644 index 0000000000..ea410a0e7e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-18.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to String object, which implements + its own property get method +---*/ + +function callbackfn1(val, idx, obj) { + return parseInt(val, 10) > 1; +} + +function callbackfn2(val, idx, obj) { + return parseInt(val, 10) > 2; +} + +var str = new String("432"); + +String.prototype[3] = "1"; + +assert(Array.prototype.every.call(str, callbackfn1), 'Array.prototype.every.call(str, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(str, callbackfn2), false, 'Array.prototype.every.call(str, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-19.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-19.js new file mode 100644 index 0000000000..9b4e28396c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-19.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Function object, which implements + its own property get method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var fun = function(a, b) { + return a + b; +}; +fun[0] = 12; +fun[1] = 11; +fun[2] = 9; + +assert(Array.prototype.every.call(fun, callbackfn1), 'Array.prototype.every.call(fun, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(fun, callbackfn2), false, 'Array.prototype.every.call(fun, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-2.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-2.js new file mode 100644 index 0000000000..66517da434 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-2.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - 'length' is own data property on an Array +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +Array.prototype[2] = 9; + +assert([12, 11].every(callbackfn1), '[12, 11].every(callbackfn1) !== true'); +assert.sameValue([12, 11].every(callbackfn2), false, '[12, 11].every(callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-3.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-3.js new file mode 100644 index 0000000000..34edd6487f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-3.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + own data property that overrides an inherited data property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var proto = { + length: 3 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert(Array.prototype.every.call(child, callbackfn1), 'Array.prototype.every.call(child, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(child, callbackfn2), false, 'Array.prototype.every.call(child, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-4.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-4.js new file mode 100644 index 0000000000..401816a1dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-4.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is own data property that + overrides an inherited data property on an Array +---*/ + +var arrProtoLen = 0; + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +arrProtoLen = Array.prototype.length; +Array.prototype.length = 0; +Array.prototype[2] = 9; + +assert([12, 11].every(callbackfn1), '[12, 11].every(callbackfn1) !== true'); +assert.sameValue([12, 11].every(callbackfn2), false, '[12, 11].every(callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-5.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-5.js new file mode 100644 index 0000000000..71a5cf7422 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-5.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + own data property that overrides an inherited accessor property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); + +assert(Array.prototype.every.call(child, callbackfn1), 'Array.prototype.every.call(child, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(child, callbackfn2), false, 'Array.prototype.every.call(child, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-6.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-6.js new file mode 100644 index 0000000000..afbe1bc864 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-6.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + inherited data property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var proto = { + length: 2 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert(Array.prototype.every.call(child, callbackfn1), 'Array.prototype.every.call(child, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(child, callbackfn2), false, 'Array.prototype.every.call(child, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-7.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-7.js new file mode 100644 index 0000000000..63646b52c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-7.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + own accessor property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +obj[0] = 12; +obj[1] = 11; +obj[2] = 9; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-8.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-8.js new file mode 100644 index 0000000000..a84db41a55 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-8.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + own accessor property that overrides an inherited data property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var proto = { + length: 3 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert(Array.prototype.every.call(child, callbackfn1), 'Array.prototype.every.call(child, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(child, callbackfn2), false, 'Array.prototype.every.call(child, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-9.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-9.js new file mode 100644 index 0000000000..294a8ca36c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-2-9.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + own accessor property that overrides an inherited accessor property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert(Array.prototype.every.call(child, callbackfn1), 'Array.prototype.every.call(child, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(child, callbackfn2), false, 'Array.prototype.every.call(child, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-1.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-1.js new file mode 100644 index 0000000000..2bb0e7335c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-1.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - value of 'length' is undefined +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 9, + length: undefined +}; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-10.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-10.js new file mode 100644 index 0000000000..eb41b2930b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-10.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is a number (value is + NaN) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 9, + length: NaN +}; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-11.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-11.js new file mode 100644 index 0000000000..274cecba8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-11.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is a string containing a positive + number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "2" +}; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-12.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-12.js new file mode 100644 index 0000000000..574d2775d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-12.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is a string containing a negative + number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 11, + 1: 12, + 2: 9, + length: "-4294967294" +}; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert(Array.prototype.every.call(obj, callbackfn2), 'Array.prototype.every.call(obj, callbackfn2) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-13.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-13.js new file mode 100644 index 0000000000..67629eea18 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-13.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is a string containing a decimal + number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "2.5" +}; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-14.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-14.js new file mode 100644 index 0000000000..3bb80e60f6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-14.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - 'length' is a string containing +/-Infinity +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var objOne = { + 0: 9, + length: "Infinity" +}; +var objTwo = { + 0: 9, + length: "+Infinity" +}; +var objThree = { + 0: 9, + length: "-Infinity" +}; + +assert.sameValue(Array.prototype.every.call(objOne, callbackfn), false, 'Array.prototype.every.call(objOne, callbackfn)'); +assert.sameValue(Array.prototype.every.call(objTwo, callbackfn), false, 'Array.prototype.every.call(objTwo, callbackfn)'); +assert(Array.prototype.every.call(objThree, callbackfn), 'Array.prototype.every.call(objThree, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-15.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-15.js new file mode 100644 index 0000000000..44c8bd416a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-15.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is a string containing an + exponential number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "2E0" +}; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-16.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-16.js new file mode 100644 index 0000000000..e89b05d06c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-16.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is a string containing a hex + number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "0x0002" +}; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-17.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-17.js new file mode 100644 index 0000000000..96c78cd4ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-17.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is a string containing a number + with leading zeros +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "0002.00" +}; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-18.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-18.js new file mode 100644 index 0000000000..06f0631b71 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-18.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is a string that can't + convert to a number +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 9, + 1: 8, + length: "two" +}; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-19.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-19.js new file mode 100644 index 0000000000..f6d9887381 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-19.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is an Object which has + an own toString method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var toStringAccessed = false; +var obj = { + 0: 12, + 1: 11, + 2: 9, + + length: { + toString: function() { + toStringAccessed = true; + return '2'; + } + } +}; + +// objects inherit the default valueOf() method from Object +// that simply returns itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); +assert(toStringAccessed, 'toStringAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-2.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-2.js new file mode 100644 index 0000000000..cb811b2e4c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-2.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every on an Array-like object if 'length' is 1 + (length overridden to true(type conversion)) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 11, + 1: 9, + length: true +}; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-20.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-20.js new file mode 100644 index 0000000000..acd8b90006 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-20.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is an Object which has + an own valueOf method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var valueOfAccessed = false; + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: { + valueOf: function() { + valueOfAccessed = true; + return 2; + } + } +}; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-21.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-21.js new file mode 100644 index 0000000000..237423b379 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-21.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is an object that has an own + valueOf method that returns an object and toString method that + returns a string +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var toStringAccessed = false; +var valueOfAccessed = false; + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: { + valueOf: function() { + valueOfAccessed = true; + return {}; + }, + toString: function() { + toStringAccessed = true; + return '2'; + } + } +}; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert(toStringAccessed, 'toStringAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-22.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-22.js new file mode 100644 index 0000000000..047a45dd92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-22.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every throws TypeError exception when 'length' is + an object with toString and valueOf methods that don�t return + primitive values +---*/ + +var callbackfnAccessed = false; +var toStringAccessed = false; +var valueOfAccessed = false; + +function callbackfn(val, idx, obj) { + callbackfnAccessed = true; + return val > 10; +} + +var obj = { + 0: 11, + 1: 12, + + length: { + valueOf: function() { + valueOfAccessed = true; + return {}; + }, + toString: function() { + toStringAccessed = true; + return {}; + } + } +}; +assert.throws(TypeError, function() { + Array.prototype.every.call(obj, callbackfn); +}); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(callbackfnAccessed, false, 'callbackfnAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-23.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-23.js new file mode 100644 index 0000000000..957425b49e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-23.js @@ -0,0 +1,51 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every uses inherited valueOf method when 'length' + is an object with an own toString and inherited valueOf methods +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var valueOfAccessed = false; +var toStringAccessed = false; + +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +child.toString = function() { + toStringAccessed = true; + return '1'; +}; + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: child +}; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-24.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-24.js new file mode 100644 index 0000000000..cf3e03afb4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-24.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2.685 +}; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-25.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-25.js new file mode 100644 index 0000000000..a0172b5547 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-25.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - value of 'length' is a negative non-integer +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: -4294967294.5 +}; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert(Array.prototype.every.call(obj, callbackfn2), 'Array.prototype.every.call(obj, callbackfn2) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-29.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-29.js new file mode 100644 index 0000000000..f1515ea20f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-29.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is boundary value (2^32 + + 1) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 11, + 1: 9, + length: 4294967297 +}; + +assert.sameValue(Array.prototype.every.call(obj, callbackfn1), false, 'Array.prototype.every.call(obj, callbackfn1)'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-3.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-3.js new file mode 100644 index 0000000000..343a0f2283 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - value of 'length' is a number (value is 0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 9, + length: 0 +}; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-4.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-4.js new file mode 100644 index 0000000000..39978edf22 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-4.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - value of 'length' is a number (value is +0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 9, + length: +0 +}; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-5.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-5.js new file mode 100644 index 0000000000..05e0a87044 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-5.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - value of 'length' is a number (value is -0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 9, + length: -0 +}; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-6.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-6.js new file mode 100644 index 0000000000..b416e4edbd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-6.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is a number (value is + positive) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2 +}; + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.every.call(obj, callbackfn2), false, 'Array.prototype.every.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-7.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-7.js new file mode 100644 index 0000000000..9864dabcc5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-7.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is a number (value is + negative) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: -4294967294 +}; //length used to exec while loop is 0 + +assert(Array.prototype.every.call(obj, callbackfn1), 'Array.prototype.every.call(obj, callbackfn1) !== true'); +assert(Array.prototype.every.call(obj, callbackfn2), 'Array.prototype.every.call(obj, callbackfn2) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-8.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-8.js new file mode 100644 index 0000000000..89c0f289df --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-8.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-3-8 +description: > + Array.prototype.every - value of 'length' is a number (value is + Infinity) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 9, + length: Infinity +}; + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-9.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-9.js new file mode 100644 index 0000000000..68982576f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-3-9.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-3-9 +description: > + Array.prototype.every - value of 'length' is a number (value is + -Infinity) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 9, + length: -Infinity +}; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-1.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-1.js new file mode 100644 index 0000000000..660ec859fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-1.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-1 +description: Array.prototype.every throws TypeError if callbackfn is undefined +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.every(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-10.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-10.js new file mode 100644 index 0000000000..436b110fde --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-10.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-10 +description: > + Array.prototype.every - the exception is not thrown if exception + was thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.every.call(obj, undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-11.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-11.js new file mode 100644 index 0000000000..237922ffce --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-11.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-11 +description: > + Array.prototype.every - the exception is not thrown if exception + was thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.every.call(obj, undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-12.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-12.js new file mode 100644 index 0000000000..6621699bb0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-12.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-12 +description: Array.prototype.every - 'callbackfn' is a function +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +assert.sameValue([11, 9].every(callbackfn), false, '[11, 9].every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-15.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-15.js new file mode 100644 index 0000000000..bb36b41b38 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-15.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-15 +description: > + Array.prototype.every - calling with no callbackfn is the same as + passing undefined for callbackfn +---*/ + +var obj = { + 10: 10 +}; +var lengthAccessed = false; +var loopAccessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + lengthAccessed = true; + return 20; + }, + configurable: true +}); + +Object.defineProperty(obj, "0", { + get: function() { + loopAccessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.every.call(obj); +}); +assert(lengthAccessed, 'lengthAccessed !== true'); +assert.sameValue(loopAccessed, false, 'loopAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-3.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-3.js new file mode 100644 index 0000000000..4e474a3aba --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-3.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-3 +description: Array.prototype.every throws TypeError if callbackfn is null +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.every(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-4.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-4.js new file mode 100644 index 0000000000..41ba39632c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-4.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-4 +description: Array.prototype.every throws TypeError if callbackfn is boolean +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.every(true); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-5.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-5.js new file mode 100644 index 0000000000..e8c3e10d4c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-5.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-5 +description: Array.prototype.every throws TypeError if callbackfn is number +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.every(5); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-6.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-6.js new file mode 100644 index 0000000000..9f3ecf12a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-6.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-6 +description: Array.prototype.every throws TypeError if callbackfn is string +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.every("abc"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-7.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-7.js new file mode 100644 index 0000000000..8e19f45269 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-7.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-7 +description: > + Array.prototype.every throws TypeError if callbackfn is Object + without a Call internal method +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.every({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-8.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-8.js new file mode 100644 index 0000000000..2478684e7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-8.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-8 +description: > + Array.prototype.every - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.every.call(obj, null); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-9.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-9.js new file mode 100644 index 0000000000..62e27db550 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-4-9.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-9 +description: > + Array.prototype.every - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.every.call(obj, null); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-1-s.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-1-s.js new file mode 100644 index 0000000000..b58627a9ac --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-1-s.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-1-s +description: Array.prototype.every - thisArg not passed to strict callbackfn +flags: [noStrict] +---*/ + +var innerThisCorrect = false; + +function callbackfn(val, idx, obj) { + "use strict"; + innerThisCorrect = this === undefined; + return true; +} + +[1].every(callbackfn); + +assert(innerThisCorrect, 'innerThisCorrect !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-1.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-1.js new file mode 100644 index 0000000000..dbbd29508b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-1.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-1 +description: Array.prototype.every - thisArg not passed +flags: [noStrict] +---*/ + +var global = this; + +function callbackfn(val, idx, obj) +{ + return this === global; +} + +var arr = [1]; + +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-10.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-10.js new file mode 100644 index 0000000000..772cdcf93e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-10.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-10 +description: Array.prototype.every - Array Object can be used as thisArg +---*/ + +var accessed = false; +var objArray = []; + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objArray; +} + + + +assert([11].every(callbackfn, objArray), '[11].every(callbackfn, objArray) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-11.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-11.js new file mode 100644 index 0000000000..c06aa99f50 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-11.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-11 +description: Array.prototype.every - String Object can be used as thisArg +---*/ + +var accessed = false; +var objString = new String(); + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objString; +} + + + +assert([11].every(callbackfn, objString), '[11].every(callbackfn, objString) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-12.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-12.js new file mode 100644 index 0000000000..8429f21f1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-12.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-12 +description: Array.prototype.every - Boolean Object can be used as thisArg +---*/ + +var accessed = false; +var objBoolean = new Boolean(); + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objBoolean; +} + + + +assert([11].every(callbackfn, objBoolean), '[11].every(callbackfn, objBoolean) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-13.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-13.js new file mode 100644 index 0000000000..f22b4dd5bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-13.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-13 +description: Array.prototype.every - Number Object can be used as thisArg +---*/ + +var accessed = false; +var objNumber = new Number(); + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objNumber; +} + +assert([11].every(callbackfn, objNumber), '[11].every(callbackfn, objNumber) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-14.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-14.js new file mode 100644 index 0000000000..6cb8c66d25 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-14.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-14 +description: Array.prototype.every - the Math object can be used as thisArg +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this === Math; +} + +assert([11].every(callbackfn, Math), '[11].every(callbackfn, Math) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-15.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-15.js new file mode 100644 index 0000000000..0e76efc48c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-15.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-15 +description: Array.prototype.every - Date Object can be used as thisArg +---*/ + +var accessed = false; +var objDate = new Date(); + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objDate; +} + +assert([11].every(callbackfn, objDate), '[11].every(callbackfn, objDate) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-16.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-16.js new file mode 100644 index 0000000000..2e7e8a453d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-16.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-16 +description: Array.prototype.every - RegExp Object can be used as thisArg +---*/ + +var accessed = false; +var objRegExp = new RegExp(); + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objRegExp; +} + +assert([11].every(callbackfn, objRegExp), '[11].every(callbackfn, objRegExp) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-17.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-17.js new file mode 100644 index 0000000000..5c856a3b35 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-17.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-17 +description: Array.prototype.every - the JSON object can be used as thisArg +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this === JSON; +} + +assert([11].every(callbackfn, JSON), '[11].every(callbackfn, JSON) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-18.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-18.js new file mode 100644 index 0000000000..da70339083 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-18.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-18 +description: Array.prototype.every - Error Object can be used as thisArg +---*/ + +var accessed = false; +var objError = new RangeError(); + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objError; +} + +assert([11].every(callbackfn, objError), '[11].every(callbackfn, objError) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-19.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-19.js new file mode 100644 index 0000000000..2c77316dbd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-19.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-19 +description: Array.prototype.every - the Arguments object can be used as thisArg +---*/ + +var accessed = false; +var arg; + +function callbackfn(val, idx, obj) { + accessed = true; + return this === arg; +} + +(function fun() { + arg = arguments; +}(1, 2, 3)); + +assert([11].every(callbackfn, arg), '[11].every(callbackfn, arg) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-2.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-2.js new file mode 100644 index 0000000000..8a119b612b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-2.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-2 +description: Array.prototype.every - thisArg is Object +---*/ + +var res = false; +var o = new Object(); +o.res = true; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +var arr = [1]; + +assert.sameValue(arr.every(callbackfn, o), true, 'arr.every(callbackfn, o)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-21.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-21.js new file mode 100644 index 0000000000..f3c0bb3e2f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-21.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-21 +description: Array.prototype.every - the global object can be used as thisArg +---*/ + +var global = this; +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this === global; +} + +assert([11].every(callbackfn, global), '[11].every(callbackfn, global) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-22.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-22.js new file mode 100644 index 0000000000..1439f3cca3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-22.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-22 +description: Array.prototype.every - boolean primitive can be used as thisArg +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this.valueOf() === false; +} + +assert([11].every(callbackfn, false), '[11].every(callbackfn, false) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-23.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-23.js new file mode 100644 index 0000000000..8726eb7180 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-23.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-23 +description: Array.prototype.every - number primitive can be used as thisArg +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this.valueOf() === 101; +} + +assert([11].every(callbackfn, 101), '[11].every(callbackfn, 101) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-24.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-24.js new file mode 100644 index 0000000000..6807fafebb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-24.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-24 +description: Array.prototype.every - string primitive can be used as thisArg +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this.valueOf() === "abc"; +} + +assert([11].every(callbackfn, "abc"), '[11].every(callbackfn, "abc") !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-3.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-3.js new file mode 100644 index 0000000000..1ef5836771 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-3.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-3 +description: Array.prototype.every - thisArg is Array +---*/ + +var res = false; +var a = new Array(); +a.res = true; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +var arr = [1]; + +assert.sameValue(arr.every(callbackfn, a), true, 'arr.every(callbackfn, a)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-4.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-4.js new file mode 100644 index 0000000000..e6792a467c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-4.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - thisArg is object from object + template(prototype) +---*/ + +var res = false; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +function foo() {} +foo.prototype.res = true; +var f = new foo(); +var arr = [1]; + +assert.sameValue(arr.every(callbackfn, f), true, 'arr.every(callbackfn,f)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-5.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-5.js new file mode 100644 index 0000000000..bd15cad257 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-5.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - thisArg is object from object template +---*/ + +var res = false; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +function foo() {} +var f = new foo(); +f.res = true; +var arr = [1]; + +assert.sameValue(arr.every(callbackfn, f), true, 'arr.every(callbackfn,f)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-6.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-6.js new file mode 100644 index 0000000000..ae582cd1aa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-6.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - thisArg is function +---*/ + +var res = false; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +function foo() {} +foo.res = true; +var arr = [1]; + +assert.sameValue(arr.every(callbackfn, foo), true, 'arr.every(callbackfn,foo)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-7.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-7.js new file mode 100644 index 0000000000..39af89d8b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-7.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - built-in functions can be used as thisArg +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this === eval; +} + +assert([11].every(callbackfn, eval), '[11].every(callbackfn, eval) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-9.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-9.js new file mode 100644 index 0000000000..6e74e1ef9a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-5-9.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - Function Object can be used as thisArg +---*/ + +var accessed = false; +var objFunction = function() {}; + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objFunction; +} + +assert([11].every(callbackfn, objFunction), '[11].every(callbackfn, objFunction) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-1.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-1.js new file mode 100644 index 0000000000..eaf18b68c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-1.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every considers new elements added to array after + the call +---*/ + +var calledForThree = false; + +function callbackfn(val, Idx, obj) +{ + arr[2] = 3; + if (val == 3) + calledForThree = true; + return true; +} + +var arr = [1, 2, , 4, 5]; + +var res = arr.every(callbackfn); + +assert(calledForThree, 'calledForThree !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-2.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-2.js new file mode 100644 index 0000000000..95ca0bee7e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-2.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every considers new value of elements in array + after the call +---*/ + +function callbackfn(val, Idx, obj) +{ + arr[4] = 6; + if (val < 6) + return true; + else + return false; +} + +var arr = [1, 2, 3, 4, 5]; + + +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-3.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-3.js new file mode 100644 index 0000000000..f0af51e8b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-3.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every doesn't visit deleted elements in array + after the call +---*/ + +function callbackfn(val, Idx, obj) +{ + delete arr[2]; + if (val == 3) + return false; + else + return true; +} + +var arr = [1, 2, 3, 4, 5]; + + +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-4.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-4.js new file mode 100644 index 0000000000..8e933e580f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-4.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every doesn't visit deleted elements when + Array.length is decreased +---*/ + +function callbackfn(val, Idx, obj) +{ + arr.length = 3; + if (val < 4) + return true; + else + return false; +} + +var arr = [1, 2, 3, 4, 6]; + + +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-5.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-5.js new file mode 100644 index 0000000000..16e3d6100f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-5.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every doesn't consider newly added elements in + sparse array +---*/ + +function callbackfn(val, Idx, obj) +{ + arr[1000] = 3; + if (val < 3) + return true; + else + return false; +} + +var arr = new Array(10); +arr[1] = 1; +arr[2] = 2; + + +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-6.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-6.js new file mode 100644 index 0000000000..3c0aea28c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-6.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every visits deleted element in array after the + call when same index is also present in prototype +---*/ + +function callbackfn(val, Idx, obj) +{ + delete arr[2]; + if (val == 3) + return false; + else + return true; +} + +Array.prototype[2] = 3; +var arr = [1, 2, 3, 4, 5]; + +var res = arr.every(callbackfn); +delete Array.prototype[2]; + +assert.sameValue(res, false, 'res'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-7.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-7.js new file mode 100644 index 0000000000..4b3366964b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-7.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - Deleting the array itself within the + callbackfn of Array.prototype.every is successful once + Array.prototype.every is called for all elements +---*/ + +var o = new Object(); +o.arr = [1, 2, 3, 4, 5]; + +function callbackfn(val, Idx, obj) { + delete o.arr; + if (val === Idx + 1) + return true; + else + return false; +} + +assert(o.arr.every(callbackfn), 'o.arr.every(callbackfn) !== true'); +assert.sameValue(o.hasOwnProperty("arr"), false, 'o.hasOwnProperty("arr")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-8.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-8.js new file mode 100644 index 0000000000..68a382931b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-8.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - no observable effects occur if len is 0 +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + 1: 12, + length: 0 +}; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-9.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-9.js new file mode 100644 index 0000000000..0e778e091d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-9.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - modifications to length don't change + number of iterations +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + return val > 10; +} + +var obj = { + 1: 12, + 2: 9, + length: 2 +}; + +Object.defineProperty(obj, "0", { + get: function() { + obj.length = 3; + return 11; + }, + configurable: true +}); + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-1.js new file mode 100644 index 0000000000..b221961a43 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-1.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn not called for indexes never + been assigned values +---*/ + +var callCnt = 0.; + +function callbackfn(val, Idx, obj) +{ + callCnt++; + return true; +} + +var arr = new Array(10); +arr[1] = undefined; +arr.every(callbackfn); + +assert.sameValue(callCnt, 1, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-10.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-10.js new file mode 100644 index 0000000000..67d49de5dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-10.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - deleting property of prototype causes + prototype index property not to be visited on an Array-like Object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return idx !== 1; +} +var arr = { + 2: 2, + length: 20 +}; + +Object.defineProperty(arr, "0", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; + +assert(Array.prototype.every.call(arr, callbackfn), 'Array.prototype.every.call(arr, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-11.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-11.js new file mode 100644 index 0000000000..5b92707559 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-11.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - deleting property of prototype causes + prototype index property not to be visited on an Array +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return idx !== 1; +} +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + delete Array.prototype[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; + +assert(arr.every(callbackfn), 'arr.every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-12.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-12.js new file mode 100644 index 0000000000..77d666ec9c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-12.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return false; + } else { + return true; + } +} +var arr = { + 0: 0, + 1: 111, + 2: 2, + length: 10 +}; + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; + +assert.sameValue(Array.prototype.every.call(arr, callbackfn), false, 'Array.prototype.every.call(arr, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-13.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-13.js new file mode 100644 index 0000000000..0fa44eca4d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-13.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return false; + } else { + return true; + } +} +var arr = [0, 111, 2]; + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; + +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-14.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-14.js new file mode 100644 index 0000000000..19b1312ebd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-14.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - decreasing length of array causes index + property not to be visited +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return idx !== 3; +} +var arr = [0, 1, 2, "last"]; + +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); + +assert(arr.every(callbackfn), 'arr.every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-15.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-15.js new file mode 100644 index 0000000000..fce7ac918e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-15.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - decreasing length of array with prototype + property causes prototype index property to be visited +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "prototype") { + return false; + } else { + return true; + } +} +var arr = [0, 1, 2]; + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-16.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-16.js new file mode 100644 index 0000000000..e60d1682bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-16.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - decreasing length of array does not delete + non-configurable properties +flags: [noStrict] +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "unconfigurable") { + return false; + } else { + return true; + } +} + +var arr = [0, 1, 2]; + +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); + +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-2.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-2.js new file mode 100644 index 0000000000..25914b29bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-2.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - added properties in step 2 are visible here +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "length") { + return false; + } else { + return true; + } +} + +var arr = {}; + +Object.defineProperty(arr, "length", { + get: function() { + arr[2] = "length"; + return 3; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.every.call(arr, callbackfn), false, 'Array.prototype.every.call(arr, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-3.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-3.js new file mode 100644 index 0000000000..73a2623d5f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-3.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - deleted properties in step 2 are visible + here +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return idx !== 2; +} +var arr = { + 2: 6.99, + 8: 19 +}; + +Object.defineProperty(arr, "length", { + get: function() { + delete arr[2]; + return 10; + }, + configurable: true +}); + +assert(Array.prototype.every.call(arr, callbackfn), 'Array.prototype.every.call(arr, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-4.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-4.js new file mode 100644 index 0000000000..2b87ad1e0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-4.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - properties added into own object after + current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return false; + } else { + return true; + } +} + +var arr = { + length: 2 +}; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.every.call(arr, callbackfn), false, 'Array.prototype.every.call(arr, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-5.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-5.js new file mode 100644 index 0000000000..cda8b9df39 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-5.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - properties added into own object after + current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return false; + } else { + return true; + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-6.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-6.js new file mode 100644 index 0000000000..727635b49d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-6.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - properties can be added to prototype after + current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + return false; + } else { + return true; + } +} +var arr = { + length: 2 +}; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.every.call(arr, callbackfn), false, 'Array.prototype.every.call(arr, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-7.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-7.js new file mode 100644 index 0000000000..9ff0cf2689 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-7.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - properties can be added to prototype after + current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + return false; + } else { + return true; + } +} +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(Array.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-8.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-8.js new file mode 100644 index 0000000000..f57a6a8d79 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-8.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - deleting own property causes index + property not to be visited on an Array-like object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return idx !== 1; +} +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); + +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-9.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-9.js new file mode 100644 index 0000000000..af743c4c9a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-b-9.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - deleting own property causes index + property not to be visited on an Array +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return idx !== 1; +} +var arr = [1, 2]; + +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +assert(arr.every(callbackfn), 'arr.every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-1.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-1.js new file mode 100644 index 0000000000..a3ec312a6f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-1.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own data + property on an Array-like object +---*/ + +var kValue = {}; + +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val !== kValue; + } else { + return true; + } +} + +var obj = { + 5: kValue, + length: 100 +}; + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-10.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-10.js new file mode 100644 index 0000000000..e6ce8319dc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-10.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2) { + return val !== 12; + } else { + return true; + } +} + +var arr = []; + +Object.defineProperty(arr, "2", { + get: function() { + return 12; + }, + configurable: true +}); + +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-11.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-11.js new file mode 100644 index 0000000000..9dbb01c5c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-11.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 5; + } else { + return true; + } +} + +var proto = { + 0: 5, + 1: 6 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 10; + +Object.defineProperty(child, "0", { + get: function() { + return 11; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.every.call(child, callbackfn), false, 'Array.prototype.every.call(child, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-12.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-12.js new file mode 100644 index 0000000000..f84e20f1bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-12.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 10; + } else { + return true; + } +} + +var arr = []; + +Array.prototype[0] = 10; + +Object.defineProperty(arr, "0", { + get: function() { + return 111; + }, + configurable: true +}); + +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-13.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-13.js new file mode 100644 index 0000000000..1189f25845 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-13.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === 6; + } else { + return true; + } +} + +var proto = {}; + +Object.defineProperty(proto, "1", { + get: function() { + return 6; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 10; + +Object.defineProperty(child, "1", { + get: function() { + return 12; + }, + configurable: true +}); + + +assert.sameValue(Array.prototype.every.call(child, callbackfn), false, 'Array.prototype.every.call(child, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-14.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-14.js new file mode 100644 index 0000000000..a02801f02d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-14.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 5; + } else { + return true; + } +} + +var arr = []; + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 5; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + return 11; + }, + configurable: true +}); + +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-15.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-15.js new file mode 100644 index 0000000000..eafb0d8281 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-15.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val !== 11; + } else { + return true; + } +} + +var proto = {}; + +Object.defineProperty(proto, "1", { + get: function() { + return 11; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 20; + +assert.sameValue(Array.prototype.every.call(child, callbackfn), false, 'Array.prototype.every.call(child, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-16.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-16.js new file mode 100644 index 0000000000..91b7955ae5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-16.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is inherited + accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val !== 11; + } else { + return true; + } +} + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 11; + }, + configurable: true +}); + +assert.sameValue([, , , ].every(callbackfn), false, '[, , , ].every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-17.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-17.js new file mode 100644 index 0000000000..0b2a3ca6e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-17.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return typeof val === "undefined"; +} + +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-18.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-18.js new file mode 100644 index 0000000000..0a54c4f918 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-18.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return typeof val === "undefined"; +} + +var arr = []; + +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +assert(arr.every(callbackfn), 'arr.every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-19.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-19.js new file mode 100644 index 0000000000..760a06ae6e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-19.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return typeof val === "undefined"; +} + +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); + +Object.prototype[1] = 10; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-2.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-2.js new file mode 100644 index 0000000000..98b6c2bdbd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-2.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own data + property on an Array +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + return val === 11; +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert.sameValue(called, 1, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-20.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-20.js new file mode 100644 index 0000000000..e321a06144 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-20.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return typeof val === "undefined"; +} + +var arr = []; + +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +Array.prototype[0] = 100; + +assert(arr.every(callbackfn), 'arr.every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-21.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-21.js new file mode 100644 index 0000000000..4eb8479bf3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-21.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return typeof val === "undefined"; +} + +var proto = {}; +Object.defineProperty(proto, "1", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; + +assert(Array.prototype.every.call(child, callbackfn), 'Array.prototype.every.call(child, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-22.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-22.js new file mode 100644 index 0000000000..ce383847fa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-22.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return typeof val === "undefined"; +} + +Object.defineProperty(Array.prototype, "0", { + set: function() {}, + configurable: true +}); + +assert([, ].every(callbackfn), '[, ].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-25.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-25.js new file mode 100644 index 0000000000..89bdfc77b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-25.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - This object is the Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + return val === 11; +} + +var func = function(a, b) { + return Array.prototype.every.call(arguments, callbackfn); +}; + +assert(func(11), 'func(11) !== true'); +assert.sameValue(called, 1, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-26.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-26.js new file mode 100644 index 0000000000..95085b4dc5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-26.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - This object is the Arguments object which + implements its own property get method (number of arguments equals + number of parameters) +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + if (idx === 0) { + return val === 11; + } else if (idx === 1) { + return val === 9; + } else { + return false; + } +} + +var func = function(a, b) { + return Array.prototype.every.call(arguments, callbackfn); +}; + +assert(func(11, 9), 'func(11, 9) !== true'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-27.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-27.js new file mode 100644 index 0000000000..5828d3d03a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-27.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - This object is the Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + if (idx < 2) { + return val > 10; + } else if (idx === 2) { + return val < 10; + } else { + return false; + } +} + +var func = function(a, b) { + return Array.prototype.every.call(arguments, callbackfn); +}; + +assert(func(11, 12, 9), 'func(11, 12, 9) !== true'); +assert.sameValue(called, 3, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-28.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-28.js new file mode 100644 index 0000000000..13fc6575d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-28.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element changed by getter on previous + iterations is observed on an Array +---*/ + +var preIterVisible = false; +var arr = []; + +function callbackfn(val, idx, obj) { + return val > 10; +} + +Object.defineProperty(arr, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 11; + } + }, + configurable: true +}); + +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-29.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-29.js new file mode 100644 index 0000000000..ec59d0df3e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-29.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element changed by getter on previous + iterations is observed on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var preIterVisible = false; +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 13; + } + }, + configurable: true +}); + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-3.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-3.js new file mode 100644 index 0000000000..5d51ec7e94 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-3.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val === 100; + } else { + return true; + } +} + +var proto = { + 0: 11, + 5: 100 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[5] = "abc"; +child.length = 10; + +assert.sameValue(Array.prototype.every.call(child, callbackfn), false, 'Array.prototype.every.call(child, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-30.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-30.js new file mode 100644 index 0000000000..1827b8392c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-30.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - unnhandled exceptions happened in getter + terminate iteration on an Array-like object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } + return true; +} + +var obj = { + 0: 11, + 5: 10, + 10: 8, + length: 20 +}; +Object.defineProperty(obj, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + Array.prototype.every.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-31.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-31.js new file mode 100644 index 0000000000..b31a514d9b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-31.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - unhandled exceptions happened in getter + terminate iteration on an Array +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } + return true; +} + +var arr = []; +arr[5] = 10; +arr[10] = 100; + +Object.defineProperty(arr, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.every(callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-4.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-4.js new file mode 100644 index 0000000000..c80150753e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-4.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + return val === 12; +} + +Array.prototype[0] = 11; +Array.prototype[1] = 11; + +assert([12, 12].every(callbackfn), '[12, 12].every(callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-5.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-5.js new file mode 100644 index 0000000000..75da7d1972 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-5.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 5; + } else { + return true; + } +} + +var proto = {}; + +Object.defineProperty(proto, "0", { + get: function() { + return 5; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +Object.defineProperty(child, "0", { + value: 11, + configurable: true +}); +child[1] = 12; + +assert.sameValue(Array.prototype.every.call(child, callbackfn), false, 'Array.prototype.every.call(child, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-6.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-6.js new file mode 100644 index 0000000000..b5a7668a9c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-6.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val === 11; +} + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 9; + }, + configurable: true +}); + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-7.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-7.js new file mode 100644 index 0000000000..9b94b838a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-7.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is inherited data + property on an Array-like object +---*/ + +var kValue = 'abc'; + +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val !== kValue; + } else { + return true; + } +} + +var proto = { + 5: kValue +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 10; + +assert.sameValue(Array.prototype.every.call(child, callbackfn), false, 'Array.prototype.every.call(child, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-8.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-8.js new file mode 100644 index 0000000000..d3acaa169d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-8.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is inherited data + property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val !== 13; + } else { + return true; + } +} + +Array.prototype[1] = 13; + +assert.sameValue([, , , ].every(callbackfn), false, '[, , , ].every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-9.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-9.js new file mode 100644 index 0000000000..5676f4d329 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-i-9.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val !== 11; + } else { + return true; + } +} + +var obj = { + 10: 10, + length: 20 +}; + +Object.defineProperty(obj, "0", { + get: function() { + return 11; + }, + configurable: true +}); + + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-1.js new file mode 100644 index 0000000000..cafd32233c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-1.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - callbackfn called with correct parameters +---*/ + +function callbackfn(val, Idx, obj) +{ + if (obj[Idx] === val) + return true; +} + +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-10.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-10.js new file mode 100644 index 0000000000..8e70a78688 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-10.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn is called with 1 formal + parameter +---*/ + +var called = 0; + +function callbackfn(val) { + called++; + return val > 10; +} + +assert([11, 12].every(callbackfn), '[11, 12].every(callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-11.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-11.js new file mode 100644 index 0000000000..8f62a39f46 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-11.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn is called with 2 formal + parameter +---*/ + +var called = 0; + +function callbackfn(val, idx) { + called++; + return val > 10 && arguments[2][idx] === val; +} + +assert([11, 12].every(callbackfn), '[11, 12].every(callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-12.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-12.js new file mode 100644 index 0000000000..41a1faeb43 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-12.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn is called with 3 formal + parameter +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + return val > 10 && obj[idx] === val; +} + +assert([11, 12, 13].every(callbackfn), '[11, 12, 13].every(callbackfn) !== true'); +assert.sameValue(called, 3, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-13.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-13.js new file mode 100644 index 0000000000..1744fed957 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-13.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn that uses arguments object to + get parameter value +---*/ + +var called = 0; + +function callbackfn() { + called++; + return arguments[2][arguments[1]] === arguments[0]; +} + +assert([11, 12].every(callbackfn), '[11, 12].every(callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-16.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-16.js new file mode 100644 index 0000000000..f3703a9d63 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-16.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'this' of 'callbackfn' is a Boolean object + when T is not an object (T is a boolean primitive) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this.valueOf() !== false; +} + +var obj = { + 0: 11, + length: 2 +}; + +assert.sameValue(Array.prototype.every.call(obj, callbackfn, false), false, 'Array.prototype.every.call(obj, callbackfn, false)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-17.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-17.js new file mode 100644 index 0000000000..c802a549d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-17.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every -'this' of 'callbackfn' is a Number object + when T is not an object (T is a number primitive) +---*/ + +var accessed = false; + +function callbackfn(val, idx, o) { + accessed = true; + return 5 === this.valueOf(); +} + +var obj = { + 0: 11, + length: 2 +}; + +assert(Array.prototype.every.call(obj, callbackfn, 5), 'Array.prototype.every.call(obj, callbackfn, 5) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-18.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-18.js new file mode 100644 index 0000000000..0efd97e77f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-18.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'this' of 'callbackfn' is an String object + when T is not an object (T is a string primitive) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return 'hello' === this.valueOf(); +} + +var obj = { + 0: 11, + length: 2 +}; + +assert(Array.prototype.every.call(obj, callbackfn, "hello"), 'Array.prototype.every.call(obj, callbackfn, "hello") !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-19.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-19.js new file mode 100644 index 0000000000..074faed23a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-19.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - non-indexed properties are not called +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + return val !== 8; +} + +var obj = { + 0: 11, + 10: 12, + non_index_property: 8, + length: 20 +}; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-2.js new file mode 100644 index 0000000000..9ff21a0194 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-2.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - callbackfn takes 3 arguments +---*/ + +function callbackfn(val, Idx, obj) +{ + if (arguments.length === 3) //verify if callbackfn was called with 3 parameters + return true; +} + +var arr = [0, 1, true, null, new Object(), "five"]; +arr[999999] = -6.6; + + +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-20.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-20.js new file mode 100644 index 0000000000..31df2f4e2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-20.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn called with correct parameters + (thisArg is correct) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return 10 === this.threshold; +} + +var thisArg = { + threshold: 10 +}; + +var obj = { + 0: 11, + length: 1 +}; + +assert(Array.prototype.every.call(obj, callbackfn, thisArg), 'Array.prototype.every.call(obj, callbackfn, thisArg) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-21.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-21.js new file mode 100644 index 0000000000..008fa8586c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-21.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn called with correct parameters + (kValue is correct) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + if (idx === 0) { + return val === 11; + } + + if (idx === 1) { + return val === 12; + } + +} + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-22.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-22.js new file mode 100644 index 0000000000..70d72b873f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-22.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn called with correct parameters + (the index k is correct) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + if (val === 11) { + return idx === 0; + } + + if (val === 12) { + return idx === 1; + } + +} + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-23.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-23.js new file mode 100644 index 0000000000..ac38a0b929 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-23.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn called with correct parameters + (this object O is correct) +---*/ + +var called = 0; +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +function callbackfn(val, idx, o) { + called++; + return obj === o; +} + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-3.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-3.js new file mode 100644 index 0000000000..a0f62215e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-3.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every immediately returns false if callbackfn + returns false +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + callCnt++; + if (idx > 5) + return false; + else + return true; +} + +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); +assert.sameValue(callCnt, 7, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-4.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-4.js new file mode 100644 index 0000000000..6962bc7c4f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-4.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - k values are passed in ascending numeric + order +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +var lastIdx = 0; +var called = 0; + +function callbackfn(val, idx, o) { + called++; + if (lastIdx !== idx) { + return false; + } else { + lastIdx++; + return true; + } +} + +assert(arr.every(callbackfn), 'arr.every(callbackfn) !== true'); +assert.sameValue(arr.length, called, 'arr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-5.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-5.js new file mode 100644 index 0000000000..655134d01a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-5.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - k values are accessed during each + iteration and not prior to starting the loop on an Array +---*/ + +var called = 0; +var kIndex = []; + +//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(val, idx, obj) { + called++; + //Each position should be visited one time, which means k is accessed one time during iterations. + if (typeof kIndex[idx] === "undefined") { + //when current position is visited, its previous index should has been visited. + if (idx !== 0 && typeof kIndex[idx - 1] === "undefined") { + return false; + } + kIndex[idx] = 1; + return true; + } else { + return false; + } +} + +assert([11, 12, 13, 14].every(callbackfn, undefined), '[11, 12, 13, 14].every(callbackfn, undefined) !== true'); +assert.sameValue(called, 4, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-6.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-6.js new file mode 100644 index 0000000000..16eba872ab --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-6.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - arguments to callbackfn are self consistent +---*/ + +var accessed = false; +var thisArg = {}; +var obj = { + 0: 11, + length: 1 +}; + +function callbackfn() { + accessed = true; + return this === thisArg && + arguments[0] === 11 && + arguments[1] === 0 && + arguments[2] === obj; +} + +assert(Array.prototype.every.call(obj, callbackfn, thisArg), 'Array.prototype.every.call(obj, callbackfn, thisArg) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-7.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-7.js new file mode 100644 index 0000000000..7f6039c2f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-7.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - unhandled exceptions happened in + callbackfn terminate iteration +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + if (called === 1) { + throw new Test262Error("Exception occurred in callbackfn"); + } + return true; +} + +var obj = { + 0: 11, + 4: 10, + 10: 8, + length: 20 +}; + +assert.throws(Test262Error, function() { + Array.prototype.every.call(obj, callbackfn); +}); + +assert.sameValue(called, 1, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-8.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-8.js new file mode 100644 index 0000000000..3ca6cfa324 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-8.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element changed by callbackfn on previous + iterations is observed +---*/ + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +function callbackfn(val, idx, o) { + if (idx === 0) { + obj[idx + 1] = 8; + } + return val > 10; +} + + + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-9.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-9.js new file mode 100644 index 0000000000..e3f1679c60 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-ii-9.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn is called with 0 formal + parameter +---*/ + +var called = 0; + +function callbackfn() { + called++; + return true; +} + +assert([11, 12].every(callbackfn), '[11, 12].every(callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-1.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-1.js new file mode 100644 index 0000000000..822414b772 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-1.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - return value of callbackfn is undefined +---*/ + +var accessed = false; +var obj = { + 0: 11, + length: 1 +}; + +function callbackfn(val, idx, o) { + accessed = true; + return undefined; +} + + + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-10.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-10.js new file mode 100644 index 0000000000..ddba79131b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-10.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a number + (value is Infinity) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return Infinity; +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-11.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-11.js new file mode 100644 index 0000000000..4e0da36fe9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-11.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a number + (value is -Infinity) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return -Infinity; +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-12.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-12.js new file mode 100644 index 0000000000..3849133131 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-12.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a number + (value is NaN) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return NaN; +} + +assert.sameValue([11].every(callbackfn), false, '[11].every(callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-13.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-13.js new file mode 100644 index 0000000000..3edcf5499d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-13.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is an empty + string +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return ""; +} + +assert.sameValue([11].every(callbackfn), false, '[11].every(callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-14.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-14.js new file mode 100644 index 0000000000..52a5f92bab --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-14.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a non-empty + string +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return "non-empty string"; +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-15.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-15.js new file mode 100644 index 0000000000..88c930c3bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-15.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a Function + object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return function() {}; +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-16.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-16.js new file mode 100644 index 0000000000..94f14a52e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-16.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is an Array + object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return []; +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-17.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-17.js new file mode 100644 index 0000000000..09bfc4a0f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-17.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a String + object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return new String(); +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-18.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-18.js new file mode 100644 index 0000000000..5de172c4c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-18.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a Boolean + object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return new Boolean(); +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-19.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-19.js new file mode 100644 index 0000000000..a53fff8bc0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-19.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a Number + object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return new Number(); +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-2.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-2.js new file mode 100644 index 0000000000..be850ac536 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-2.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - return value of callbackfn is null +---*/ + +var accessed = false; +var obj = { + 0: 11, + length: 1 +}; + +function callbackfn(val, idx, obj) { + accessed = true; + return null; +} + + + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-20.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-20.js new file mode 100644 index 0000000000..5f20d29720 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-20.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is the Math + object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return Math; +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-21.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-21.js new file mode 100644 index 0000000000..6ce6fa52ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-21.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - return value of callbackfn is a Date object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return new Date(); +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-22.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-22.js new file mode 100644 index 0000000000..3fd482cc75 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-22.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a RegExp + object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return new RegExp(); +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-23.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-23.js new file mode 100644 index 0000000000..d18cf83cff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-23.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is the JSON + object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return JSON; +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-24.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-24.js new file mode 100644 index 0000000000..58cad1d777 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-24.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is an Error + object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return new EvalError(); +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-25.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-25.js new file mode 100644 index 0000000000..05680e0df5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-25.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is the + Arguments object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return arguments; +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-27.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-27.js new file mode 100644 index 0000000000..3985d330dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-27.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is the global + object +---*/ + +var global = this; +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return global; +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-28.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-28.js new file mode 100644 index 0000000000..f4fde7c5c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-28.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - false prevents further side effects +---*/ + +var result = false; +var obj = { + length: 20 +}; + +function callbackfn(val, idx, obj) { + if (idx > 1) { + result = true; + } + return val > 10; +} + +Object.defineProperty(obj, "0", { + get: function() { + return 11; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + return 8; + }, + configurable: true +}); + +Object.defineProperty(obj, "2", { + get: function() { + result = true; + return 8; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); +assert.sameValue(result, false, 'result'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-29.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-29.js new file mode 100644 index 0000000000..77a3b0894f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-29.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value (new Boolean(false)) of + callbackfn is treated as true value +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return new Boolean(false); +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-3.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-3.js new file mode 100644 index 0000000000..0a7c070b47 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-3.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a boolean + (value is false) +---*/ + +var accessed = false; +var obj = { + 0: 11, + length: 1 +}; + +function callbackfn(val, idx, obj) { + accessed = true; + return false; +} + +assert.sameValue(Array.prototype.every.call(obj, callbackfn), false, 'Array.prototype.every.call(obj, callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-4.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-4.js new file mode 100644 index 0000000000..8d090b844c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-4.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a boolean + (value is true) +---*/ + +var accessed = false; +var obj = { + 0: 11, + length: 1 +}; + +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} + + + +assert(Array.prototype.every.call(obj, callbackfn), 'Array.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-5.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-5.js new file mode 100644 index 0000000000..1560afa6e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-5.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a number + (value is 0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return 0; +} + +assert.sameValue([11].every(callbackfn), false, '[11].every(callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-6.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-6.js new file mode 100644 index 0000000000..23eeb249b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-6.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a number + (value is +0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return +0; +} + +assert.sameValue([11].every(callbackfn), false, '[11].every(callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-7.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-7.js new file mode 100644 index 0000000000..1dbb74c91b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-7.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a nunmber + (value is -0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return -0; +} + +assert.sameValue([11].every(callbackfn), false, '[11].every(callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-8.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-8.js new file mode 100644 index 0000000000..9998803a04 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-8.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a number + (value is positive number) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return 5; +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-9.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-9.js new file mode 100644 index 0000000000..45731e95a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-7-c-iii-9.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a number + (value is negative number) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return -5; +} + +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-1.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-1.js new file mode 100644 index 0000000000..e21788de75 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every returns true if 'length' is 0 (empty array) +---*/ + +function cb() {} +var i = [].every(cb); + +assert.sameValue(i, true, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-10.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-10.js new file mode 100644 index 0000000000..8be8730c95 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-10.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - subclassed array when length is reduced +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 2; + +function cb(val) +{ + if (val > 2) + return false; + else + return true; +} +var i = f.every(cb); + + +assert.sameValue(i, true, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-11.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-11.js new file mode 100644 index 0000000000..0ffed8116e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-11.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true when all calls to callbackfn + return true +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + callCnt++; + return true; +} + +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); +assert.sameValue(callCnt, 10, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-12.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-12.js new file mode 100644 index 0000000000..f26076a8a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-12.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every doesn't mutate the array on which it is + called on +---*/ + +function callbackfn(val, idx, obj) +{ + return true; +} +var arr = [1, 2, 3, 4, 5]; +arr.every(callbackfn); + +assert.sameValue(arr[0], 1, 'arr[0]'); +assert.sameValue(arr[1], 2, 'arr[1]'); +assert.sameValue(arr[2], 3, 'arr[2]'); +assert.sameValue(arr[3], 4, 'arr[3]'); +assert.sameValue(arr[4], 5, 'arr[4]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-13.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-13.js new file mode 100644 index 0000000000..73ddb2f547 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-13.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every doesn't visit expandos +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + callCnt++; + return true; +} + +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +arr["i"] = 10; +arr[true] = 11; + + +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); +assert.sameValue(callCnt, 10, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-2.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-2.js new file mode 100644 index 0000000000..cfceada732 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-2.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true if 'length' is 0 (subclassed + Array, length overridden to null (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = null; + +function cb() {} +var i = f.every(cb); + + +assert.sameValue(i, true, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-3.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-3.js new file mode 100644 index 0000000000..0848d2a83c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-3.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true if 'length' is 0 (subclassed + Array, length overridden to false (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = false; + +function cb() {} +var i = f.every(cb); + + +assert.sameValue(i, true, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-4.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-4.js new file mode 100644 index 0000000000..9e4d263ae7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-4.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true if 'length' is 0 (subclassed + Array, length overridden to 0 (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 0; + +function cb() {} +var i = f.every(cb); + + +assert.sameValue(i, true, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-5.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-5.js new file mode 100644 index 0000000000..df0ff6b2d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-5.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true if 'length' is 0 (subclassed + Array, length overridden to '0' (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = '0'; + +function cb() {} +var i = f.every(cb); + + +assert.sameValue(i, true, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-6.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-6.js new file mode 100644 index 0000000000..2424224c4d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-6.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true if 'length' is 0 (subclassed + Array, length overridden with obj with valueOf) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; + +function cb() {} +var i = f.every(cb); + + +assert.sameValue(i, true, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-7.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-7.js new file mode 100644 index 0000000000..72a6dc4569 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-7.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true if 'length' is 0 (subclassed + Array, length overridden with obj w/o valueOf (toString)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +function cb() {} +var i = f.every(cb); + + +assert.sameValue(i, true, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-8.js b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-8.js new file mode 100644 index 0000000000..c888904a33 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/15.4.4.16-8-8.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true if 'length' is 0 (subclassed + Array, length overridden with [] +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +f.length = []; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. + +function cb() {} +var i = f.every(cb); + + +assert.sameValue(i, true, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/browser.js b/js/src/tests/test262/built-ins/Array/prototype/every/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/every/call-with-boolean.js new file mode 100644 index 0000000000..76e4bab1a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/call-with-boolean.js @@ -0,0 +1,20 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to boolean primitive +---*/ + +assert.sameValue( + Array.prototype.every.call(true, () => {}), + true, + 'Array.prototype.every.call(true, () => {}) must return true' +); +assert.sameValue( + Array.prototype.every.call(false, () => {}), + true, + 'Array.prototype.every.call(false, () => {}) must return true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/every/callbackfn-resize-arraybuffer.js new file mode 100644 index 0000000000..a1a4ee5456 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/callbackfn-resize-arraybuffer.js @@ -0,0 +1,74 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.every +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.every.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return true; + }); + + assert.compareArray(elements, expectedElements, 'elements (shrink)'); + assert.compareArray(indices, expectedIndices, 'indices (shrink)'); + assert.compareArray(arrays, expectedArrays, 'arrays (shrink)'); + assert.sameValue(result, true, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.every.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return true; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, true, 'result (grow)'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/length.js b/js/src/tests/test262/built-ins/Array/prototype/every/length.js new file mode 100644 index 0000000000..65015d9799 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/length.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// Copyright (C) 2017 Corey Frang. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every.length value and property descriptor +info: | + Array.prototype.every ( callbackfn [ , thisArg] ) + The length property of the of function is 1. +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.every.length, 1, + 'The value of `Array.prototype.every.length` is `1`' +); + +verifyNotEnumerable(Array.prototype.every, 'length'); +verifyNotWritable(Array.prototype.every, 'length'); +verifyConfigurable(Array.prototype.every, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/name.js b/js/src/tests/test262/built-ins/Array/prototype/every/name.js new file mode 100644 index 0000000000..5bb10976b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every.name is "every". +info: | + Array.prototype.every ( callbackfn [ , thisArg] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.every.name, "every"); + +verifyNotEnumerable(Array.prototype.every, "name"); +verifyNotWritable(Array.prototype.every, "name"); +verifyConfigurable(Array.prototype.every, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/every/not-a-constructor.js new file mode 100644 index 0000000000..54dee55e8b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/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: > + Array.prototype.every 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.every), + false, + 'isConstructor(Array.prototype.every) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.every(() => {}); +}, '`new Array.prototype.every(() => {})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/every/prop-desc.js new file mode 100644 index 0000000000..1bc9174eef --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.every +description: > + "every" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.every, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "every"); +verifyWritable(Array.prototype, "every"); +verifyConfigurable(Array.prototype, "every"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/shell.js b/js/src/tests/test262/built-ins/Array/prototype/every/shell.js new file mode 100644 index 0000000000..05fecd6ef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/every/shell.js @@ -0,0 +1,161 @@ +// GENERATED, DO NOT EDIT +// file: testTypedArray.js +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - floatArrayConstructors + - nonClampedIntArrayConstructors + - intArrayConstructors + - typedArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - nonAtomicsFriendlyTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +var floatArrayConstructors = [ + Float64Array, + Float32Array +]; + +var nonClampedIntArrayConstructors = [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array +]; + +var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]); + +// Float16Array is a newer feature +// adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it +if (typeof Float16Array !== 'undefined') { + floatArrayConstructors.push(Float16Array); +} + +/** + * Array containing every non-bigint typed array constructor. + */ + +var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]); +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} + +/** + * Checks if the given argument is one of the float-based TypedArray constructors. + * + * @param {constructor} ctor - the value to check + * @returns {boolean} + */ +function isFloatTypedArrayConstructor(arg) { + return floatArrayConstructors.indexOf(arg) !== -1; +} + +/** + * Determines the precision of the given float-based TypedArray constructor. + * + * @param {constructor} ctor - the value to check + * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively. + */ +function floatTypedArrayConstructorPrecision(FA) { + if (typeof Float16Array !== "undefined" && FA === Float16Array) { + return "half"; + } else if (FA === Float32Array) { + return "single"; + } else if (FA === Float64Array) { + return "double"; + } else { + throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray"); + } +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/exotic-array.js b/js/src/tests/test262/built-ins/Array/prototype/exotic-array.js new file mode 100644 index 0000000000..b1ab60ace7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/exotic-array.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-the-array-prototype-object +description: > + Array.prototype is an exoctic array object +info: | + 22.1.3 Properties of the Array Prototype Object + + (...) + The Array prototype object is an Array exotic object and has the internal + methods specified for such objects. +---*/ + +Array.prototype[2] = 42; + +assert.sameValue(Array.prototype.length, 3); +assert.sameValue(Array.prototype[0], undefined, 'Array.prototype[0]'); +assert.sameValue(Array.prototype[1], undefined, 'Array.prototype[1]'); +assert.sameValue(Array.prototype[2], 42, 'Array.prototype[2]'); + +assert.sameValue({}.toString.call(Array.prototype), '[object Array]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/browser.js b/js/src/tests/test262/built-ins/Array/prototype/fill/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/fill/call-with-boolean.js new file mode 100644 index 0000000000..0796174edd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/call-with-boolean.js @@ -0,0 +1,20 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.fill +description: Array.prototype.fill applied to boolean primitive +---*/ + +assert.sameValue( + Array.prototype.fill.call(true) instanceof Boolean, + true, + 'The result of `(Array.prototype.fill.call(true) instanceof Boolean)` is true' +); +assert.sameValue( + Array.prototype.fill.call(false) instanceof Boolean, + true, + 'The result of `(Array.prototype.fill.call(false) instanceof Boolean)` is true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/coerced-indexes.js b/js/src/tests/test262/built-ins/Array/prototype/fill/coerced-indexes.js new file mode 100644 index 0000000000..3cf5954171 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/coerced-indexes.js @@ -0,0 +1,77 @@ +// 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-array.prototype.fill +description: > + Fills elements from coerced to Integer `start` and `end` values +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 7. Let relativeStart be ToInteger(start). + 8. ReturnIfAbrupt(relativeStart). + 9. If relativeStart < 0, let k be max((len + relativeStart),0); else let k be + min(relativeStart, len). + 10. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray([0, 0].fill(1, undefined), [1, 1], + '[0, 0].fill(1, undefined) must return [1, 1]' +); + +assert.compareArray([0, 0].fill(1, 0, undefined), [1, 1], + '[0, 0].fill(1, 0, undefined) must return [1, 1]' +); + +assert.compareArray([0, 0].fill(1, null), [1, 1], + '[0, 0].fill(1, null) must return [1, 1]' +); + +assert.compareArray([0, 0].fill(1, 0, null), [0, 0], + '[0, 0].fill(1, 0, null) must return [0, 0]' +); + +assert.compareArray([0, 0].fill(1, true), [0, 1], + '[0, 0].fill(1, true) must return [0, 1]' +); + +assert.compareArray([0, 0].fill(1, 0, true), [1, 0], + '[0, 0].fill(1, 0, true) must return [1, 0]' +); + +assert.compareArray([0, 0].fill(1, false), [1, 1], + '[0, 0].fill(1, false) must return [1, 1]' +); + +assert.compareArray([0, 0].fill(1, 0, false), [0, 0], + '[0, 0].fill(1, 0, false) must return [0, 0]' +); + +assert.compareArray([0, 0].fill(1, NaN), [1, 1], + '[0, 0].fill(1, NaN) must return [1, 1]' +); + +assert.compareArray([0, 0].fill(1, 0, NaN), [0, 0], + '[0, 0].fill(1, 0, NaN) must return [0, 0]' +); + +assert.compareArray([0, 0].fill(1, '1'), [0, 1], + '[0, 0].fill(1, "1") must return [0, 1]' +); + +assert.compareArray([0, 0].fill(1, 0, '1'), [1, 0], + '[0, 0].fill(1, 0, "1") must return [1, 0]' +); + +assert.compareArray([0, 0].fill(1, 1.5), [0, 1], + '[0, 0].fill(1, 1.5) must return [0, 1]' +); + +assert.compareArray([0, 0].fill(1, 0, 1.5), [1, 0], + '[0, 0].fill(1, 0, 1.5) must return [1, 0]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-custom-start-and-end.js b/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-custom-start-and-end.js new file mode 100644 index 0000000000..5eeedcfc92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-custom-start-and-end.js @@ -0,0 +1,40 @@ +// 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-array.prototype.fill +description: > + Fills all the elements from a with a custom start and end indexes. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 7. If relativeStart < 0, let k be max((len + relativeStart),0); else let k be + min(relativeStart, len). + 8. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 9. ReturnIfAbrupt(relativeEnd). + 10. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let + final be min(relativeEnd, len). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray([0, 0, 0].fill(8, 1, 2), [0, 8, 0], '[0, 0, 0].fill(8, 1, 2) must return [0, 8, 0]'); +assert.compareArray( + [0, 0, 0, 0, 0].fill(8, -3, 4), + [0, 0, 8, 8, 0], + '[0, 0, 0, 0, 0].fill(8, -3, 4) must return [0, 0, 8, 8, 0]' +); +assert.compareArray( + [0, 0, 0, 0, 0].fill(8, -2, -1), + [0, 0, 0, 8, 0], + '[0, 0, 0, 0, 0].fill(8, -2, -1) must return [0, 0, 0, 8, 0]' +); +assert.compareArray( + [0, 0, 0, 0, 0].fill(8, -1, -3), + [0, 0, 0, 0, 0], + '[0, 0, 0, 0, 0].fill(8, -1, -3) must return [0, 0, 0, 0, 0]' +); +assert.compareArray([, , , , 0].fill(8, 1, 3), [, 8, 8, , 0], '[, , , , 0].fill(8, 1, 3) must return [, 8, 8, , 0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-relative-end.js b/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-relative-end.js new file mode 100644 index 0000000000..078c8b6574 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-relative-end.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-array.prototype.fill +description: > + Fills all the elements from a with a custom start index. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 8. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 9. ReturnIfAbrupt(relativeEnd). + 10. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let + final be min(relativeEnd, len). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray([0, 0, 0].fill(8, 0, 1), [8, 0, 0], + '[0, 0, 0].fill(8, 0, 1) must return [8, 0, 0]' +); + +assert.compareArray([0, 0, 0].fill(8, 0, -1), [8, 8, 0], + '[0, 0, 0].fill(8, 0, -1) must return [8, 8, 0]' +); + +assert.compareArray([0, 0, 0].fill(8, 0, 5), [8, 8, 8], + '[0, 0, 0].fill(8, 0, 5) must return [8, 8, 8]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-relative-start.js b/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-relative-start.js new file mode 100644 index 0000000000..da7aa5f642 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-relative-start.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-array.prototype.fill +description: > + Fills all the elements from a with a custom start index. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 7. If relativeStart < 0, let k be max((len + relativeStart),0); else let k be + min(relativeStart, len). + ... +includes: [compareArray.js] +---*/ + +assert.compareArray([0, 0, 0].fill(8, 1), [0, 8, 8], + '[0, 0, 0].fill(8, 1) must return [0, 8, 8]' +); + +assert.compareArray([0, 0, 0].fill(8, 4), [0, 0, 0], + '[0, 0, 0].fill(8, 4) must return [0, 0, 0]' +); + +assert.compareArray([0, 0, 0].fill(8, -1), [0, 0, 8], + '[0, 0, 0].fill(8, -1) must return [0, 0, 8]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values.js b/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values.js new file mode 100644 index 0000000000..124da418f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values.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-array.prototype.fill +description: > + Fills all the elements with `value` from a defaul start and index. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 7. If relativeStart < 0, let k be max((len + relativeStart),0); else let k be + min(relativeStart, len). + 8. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 9. ReturnIfAbrupt(relativeEnd). + 10. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let + final be min(relativeEnd, len). + 11. Repeat, while k < final + a. Let Pk be ToString(k). + b. Let setStatus be Set(O, Pk, value, true). + c. ReturnIfAbrupt(setStatus). + d. Increase k by 1. + 12. Return O. +includes: [compareArray.js] +---*/ + +assert.compareArray([].fill(8), [], '[].fill(8) must return []'); + +assert.compareArray([0, 0].fill(), [undefined, undefined], '[0, 0].fill() must return [undefined, undefined]'); + +assert.compareArray([0, 0, 0].fill(8), [8, 8, 8], + '[0, 0, 0].fill(8) must return [8, 8, 8]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/length-near-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/fill/length-near-integer-limit.js new file mode 100644 index 0000000000..413175dcfb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/length-near-integer-limit.js @@ -0,0 +1,33 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.fill +description: > + Elements are filled in an array-like object + whose "length" property is near the integer limit. +info: | + Array.prototype.fill ( value [ , start [ , end ] ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + [...] + 7. Repeat, while k < final + a. Let Pk be ! ToString(k). + b. Perform ? Set(O, Pk, value, true). + [...] +---*/ + +var value = {}; +var startIndex = Number.MAX_SAFE_INTEGER - 3; +var arrayLike = { + length: Number.MAX_SAFE_INTEGER, +}; + +Array.prototype.fill.call(arrayLike, value, startIndex, startIndex + 3); + +assert.sameValue(arrayLike[startIndex], value); +assert.sameValue(arrayLike[startIndex + 1], value); +assert.sameValue(arrayLike[startIndex + 2], value); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/length.js b/js/src/tests/test262/built-ins/Array/prototype/fill/length.js new file mode 100644 index 0000000000..1d12345bc0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/length.js @@ -0,0 +1,20 @@ +// 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-array.prototype.fill +description: Array.prototype.fill.length value and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.fill.length, 1, + 'The value of `Array.prototype.fill.length` is `1`' +); + +verifyNotEnumerable(Array.prototype.fill, 'length'); +verifyNotWritable(Array.prototype.fill, 'length'); +verifyConfigurable(Array.prototype.fill, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/name.js b/js/src/tests/test262/built-ins/Array/prototype/fill/name.js new file mode 100644 index 0000000000..35d210dec3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/name.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-array.prototype.fill +description: > + Array.prototype.fill.name value and descriptor. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.fill.name, 'fill', + 'The value of `Array.prototype.fill.name` is `"fill"`' +); + +verifyNotEnumerable(Array.prototype.fill, 'name'); +verifyNotWritable(Array.prototype.fill, 'name'); +verifyConfigurable(Array.prototype.fill, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/fill/not-a-constructor.js new file mode 100644 index 0000000000..77d1be633b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/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: > + Array.prototype.fill 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, arrow-function] +---*/ + +assert.sameValue(isConstructor(Array.prototype.fill), false, 'isConstructor(Array.prototype.fill) must return false'); + +assert.throws(TypeError, () => { + new Array.prototype.fill(); +}, '`new Array.prototype.fill()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/fill/prop-desc.js new file mode 100644 index 0000000000..bd0d1314ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/prop-desc.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-array.prototype.fill +description: Property type and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Array.prototype.fill, + 'function', + '`typeof Array.prototype.fill` is `function`' +); + +verifyNotEnumerable(Array.prototype, 'fill'); +verifyWritable(Array.prototype, 'fill'); +verifyConfigurable(Array.prototype, 'fill'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-end-as-symbol.js b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-end-as-symbol.js new file mode 100644 index 0000000000..c6976b08a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-end-as-symbol.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-array.prototype.fill +description: > + Return abrupt from ToInteger(end) as a Symbol. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 8. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 9. ReturnIfAbrupt(relativeEnd). + ... +features: [Symbol] +---*/ + +var end = Symbol(1); + +assert.throws(TypeError, function() { + [].fill(1, 0, end); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-end.js new file mode 100644 index 0000000000..644b5fb097 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-end.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-array.prototype.fill +description: > + Return abrupt from ToInteger(end). +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 8. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 9. ReturnIfAbrupt(relativeEnd). + ... +---*/ + +var end = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + [].fill(1, 0, end); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-setting-property-value.js b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-setting-property-value.js new file mode 100644 index 0000000000..bbd439ffae --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-setting-property-value.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-array.prototype.fill +description: > + Return abrupt from setting a property value. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 11. Repeat, while k < final + a. Let Pk be ToString(k). + b. Let setStatus be Set(O, Pk, value, true). + c. ReturnIfAbrupt(setStatus). + ... +---*/ + +var a1 = []; +Object.freeze(a1); + +// won't break on an empty array. +a1.fill(1); + +var a2 = { + length: 1 +}; +Object.defineProperty(a2, '0', { + set: function() { + throw new Test262Error(); + } +}) +assert.throws(Test262Error, function() { + Array.prototype.fill.call(a2); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-start-as-symbol.js b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-start-as-symbol.js new file mode 100644 index 0000000000..572486c7f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-start-as-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-array.prototype.fill +description: > + Return abrupt from ToInteger(start) as a Symbol. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 5. Let relativeStart be ToInteger(start). + 6. ReturnIfAbrupt(relativeStart). + ... +features: [Symbol] +---*/ + +var start = Symbol(1); + +assert.throws(TypeError, function() { + [].fill(1, start); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-start.js b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-start.js new file mode 100644 index 0000000000..326c9a9009 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-start.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-array.prototype.fill +description: > + Return abrupt from ToInteger(start). +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 5. Let relativeStart be ToInteger(start). + 6. ReturnIfAbrupt(relativeStart). + ... +---*/ + +var start = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + [].fill(1, start); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-this-length-as-symbol.js b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-this-length-as-symbol.js new file mode 100644 index 0000000000..5fe17d264e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-this-length-as-symbol.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-array.prototype.fill +description: > + Return abrupt from ToLength(Get(O, "length")) where length is a Symbol. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let len be ToLength(Get(O, "length")). + 4. ReturnIfAbrupt(len). +features: [Symbol] +---*/ + +var o = {}; + +o.length = Symbol(1); + +// value argument is given to avoid false positives +assert.throws(TypeError, function() { + [].fill.call(o, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-this-length.js b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-this-length.js new file mode 100644 index 0000000000..c4d7384549 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-this-length.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-array.prototype.fill +description: > + Return abrupt from ToLength(Get(O, "length")). +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let len be ToLength(Get(O, "length")). + 4. ReturnIfAbrupt(len). +---*/ + +var o1 = {}; + +Object.defineProperty(o1, 'length', { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + [].fill.call(o1, 1); +}); + +var o2 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; +assert.throws(Test262Error, function() { + [].fill.call(o2, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-this.js new file mode 100644 index 0000000000..5f3f7294d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/return-abrupt-from-this.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-array.prototype.fill +description: > + Return abrupt from ToObject(this value). +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +assert.throws(TypeError, function() { + Array.prototype.fill.call(undefined, 1); +}); + +assert.throws(TypeError, function() { + Array.prototype.fill.call(null, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/return-this.js b/js/src/tests/test262/built-ins/Array/prototype/fill/return-this.js new file mode 100644 index 0000000000..40c4389738 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/return-this.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-array.prototype.fill +description: > + Returns `this`. +info: | + 12. Return O. +---*/ + +var arr = []; +var result = arr.fill(1); + +assert.sameValue(result, arr); + +var o = { + length: 0 +}; +result = Array.prototype.fill.call(o); +assert.sameValue(result, o); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/shell.js b/js/src/tests/test262/built-ins/Array/prototype/fill/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-1.js new file mode 100644 index 0000000000..353a38d2bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to undefined throws a TypeError +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.filter.call(undefined); // TypeError is thrown if value is undefined +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-10.js new file mode 100644 index 0000000000..5b57ba7a12 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-10.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to the Math object +---*/ + +function callbackfn(val, idx, obj) { + return '[object Math]' === Object.prototype.toString.call(obj); +} + +Math.length = 1; +Math[0] = 1; +var newArr = Array.prototype.filter.call(Math, callbackfn); + +assert.sameValue(newArr[0], 1, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-11.js new file mode 100644 index 0000000000..8f187eb12f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-11.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to Date object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Date; +} + +var obj = new Date(); +obj.length = 1; +obj[0] = 1; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr[0], 1, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-12.js new file mode 100644 index 0000000000..99a2fbb219 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-12.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to RegExp object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof RegExp; +} + +var obj = new RegExp(); +obj.length = 2; +obj[1] = true; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr[0], true, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-13.js new file mode 100644 index 0000000000..81433b27d3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-13.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to the JSON object +---*/ + +function callbackfn(val, idx, obj) { + return '[object JSON]' === Object.prototype.toString.call(JSON); +} + +JSON.length = 1; +JSON[0] = 1; +var newArr = Array.prototype.filter.call(JSON, callbackfn); + +assert.sameValue(newArr[0], 1, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-14.js new file mode 100644 index 0000000000..c92ef73121 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-14.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to Error object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Error; +} + +var obj = new Error(); +obj.length = 1; +obj[0] = 1; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr[0], 1, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-15.js new file mode 100644 index 0000000000..ae7b4382ce --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-15.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to the Arguments object +---*/ + +function callbackfn(val, idx, obj) { + return '[object Arguments]' === Object.prototype.toString.call(obj); +} + +var obj = (function() { + return arguments; +}("a", "b")); + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr[0], "a", 'newArr[0]'); +assert.sameValue(newArr[1], "b", 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-2.js new file mode 100644 index 0000000000..a060c4dbcb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to null throws a TypeError +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.filter.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-3.js new file mode 100644 index 0000000000..ded3e11af6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-3.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to boolean primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Boolean; +} + +Boolean.prototype[0] = true; +Boolean.prototype.length = 1; + +var newArr = Array.prototype.filter.call(false, callbackfn); + +assert.sameValue(newArr[0], true, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-4.js new file mode 100644 index 0000000000..8ee3b23f02 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-4.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to Boolean Object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Boolean; +} + +var obj = new Boolean(true); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert.sameValue(newArr[1], 12, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-5.js new file mode 100644 index 0000000000..f1877b6544 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-5.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to number primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Number; +} + +Number.prototype[0] = 1; +Number.prototype.length = 1; + +var newArr = Array.prototype.filter.call(2.5, callbackfn); + +assert.sameValue(newArr[0], 1, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-6.js new file mode 100644 index 0000000000..210a2b538e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-6.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to Number object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Number; +} + +var obj = new Number(-128); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert.sameValue(newArr[1], 12, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-7.js new file mode 100644 index 0000000000..fc358c7460 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-7.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to string primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof String; +} + +var newArr = Array.prototype.filter.call("abc", callbackfn); + +assert.sameValue(newArr[0], "a", 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-8.js new file mode 100644 index 0000000000..7e0ddc08d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-8.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to String object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof String; +} + +var obj = new String("abc"); +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr[0], "a", 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-9.js new file mode 100644 index 0000000000..da468f6cb0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-1-9.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to Function object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Function; +} + +var obj = function(a, b) { + return a + b; +}; +obj[0] = 11; +obj[1] = 9; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert.sameValue(newArr[1], 9, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-1.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-1.js new file mode 100644 index 0000000000..d69b8f89ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-1.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter doesn't mutate the Array on which it is + called on +---*/ + +function callbackfn(val, idx, obj) +{ + return true; +} +var srcArr = [1, 2, 3, 4, 5]; +srcArr.filter(callbackfn); + +assert.sameValue(srcArr[0], 1, 'srcArr[0]'); +assert.sameValue(srcArr[1], 2, 'srcArr[1]'); +assert.sameValue(srcArr[2], 3, 'srcArr[2]'); +assert.sameValue(srcArr[3], 4, 'srcArr[3]'); +assert.sameValue(srcArr[4], 5, 'srcArr[4]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-2.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-2.js new file mode 100644 index 0000000000..b1e81d72ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-2.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter returns new Array with length equal to + number of true returned by callbackfn +---*/ + +function callbackfn(val, idx, obj) +{ + if (val % 2) + return true; + else + return false; +} +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.filter(callbackfn); + +assert.sameValue(resArr.length, 3, 'resArr.length'); +assert.sameValue(resArr[0], 1, 'resArr[0]'); +assert.sameValue(resArr[1], 3, 'resArr[1]'); +assert.sameValue(resArr[2], 5, 'resArr[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-3.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-3.js new file mode 100644 index 0000000000..ea732a2775 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - subclassed array when length is reduced +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 1; + +function cb() { + return true; +} +var a = f.filter(cb); + + +assert(Array.isArray(a), 'Array.isArray(a) !== true'); +assert.sameValue(a.length, 1, 'a.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-4.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-4.js new file mode 100644 index 0000000000..417828fe76 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-10-4.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter doesn't visit expandos +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + callCnt++; +} +var srcArr = [1, 2, 3, 4, 5]; +srcArr["i"] = 10; +srcArr[true] = 11; + +var resArr = srcArr.filter(callbackfn); + +assert.sameValue(callCnt, 5, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-1.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-1.js new file mode 100644 index 0000000000..48bd125ee0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-1.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + own data property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2 +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-10.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-10.js new file mode 100644 index 0000000000..36ccaaa6f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-10.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + inherited accessor property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +var newArr = Array.prototype.filter.call(child, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-11.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-11.js new file mode 100644 index 0000000000..5a677b381b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-11.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + own accessor property without a get function +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-12.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-12.js new file mode 100644 index 0000000000..195c29d06d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-12.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is own accessor property without + a get function that overrides an inherited accessor property +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} + +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var obj = { + 0: 12, + 1: 11 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-13.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-13.js new file mode 100644 index 0000000000..dac99a967d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-13.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to the Array-like object that + 'length' is inherited accessor property without a get function +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} + +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 11; +child[1] = 12; + +var newArr = Array.prototype.filter.call(child, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-14.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-14.js new file mode 100644 index 0000000000..f2d7e5e276 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-14.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to the Array-like object that + 'length property doesn't exist +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} + +var obj = { + 0: 11, + 1: 12 +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-17.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-17.js new file mode 100644 index 0000000000..9250b9fbd9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-17.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to the Arguments object, which + implements its own property get method +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} + +var func = function(a, b) { + var newArr = Array.prototype.filter.call(arguments, callbackfn); + return newArr.length === 2; +}; + +assert(func(12, 11), 'func(12, 11) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-18.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-18.js new file mode 100644 index 0000000000..3660e392ad --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-18.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to String object, which implements + its own property get method +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 3; +} + +var str = new String("012"); + +var newArr = Array.prototype.filter.call(str, callbackfn); + +assert.sameValue(newArr.length, 3, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-19.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-19.js new file mode 100644 index 0000000000..876e104660 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-19.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Function object, which + implements its own property get method +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} + +var fun = function(a, b) { + return a + b; +}; +fun[0] = 12; +fun[1] = 11; +fun[2] = 9; + +var newArr = Array.prototype.filter.call(fun, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-2.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-2.js new file mode 100644 index 0000000000..b67bb19b26 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-2.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - 'length' is own data property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} + +var newArr = [12, 11].filter(callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-3.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-3.js new file mode 100644 index 0000000000..674169313a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-3.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + an own data property that overrides an inherited data property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} + +var proto = { + length: 3 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +child[0] = 12; +child[1] = 11; +child[2] = 9; + +var newArr = Array.prototype.filter.call(child, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-4.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-4.js new file mode 100644 index 0000000000..33c1bf0fc5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-4.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is own data property that + overrides an inherited data property on an Array +---*/ + +var arrProtoLen; + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} + +arrProtoLen = Array.prototype.length; +Array.prototype.length = 0; +var newArr = [12, 11].filter(callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-5.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-5.js new file mode 100644 index 0000000000..0e3692f636 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-5.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter to Array-like object, 'length' is an own + data property that overrides an inherited accessor property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +var newArr = Array.prototype.filter.call(child, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-6.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-6.js new file mode 100644 index 0000000000..e6c242e034 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-6.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + an inherited data property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} + +var proto = { + length: 2 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +var newArr = Array.prototype.filter.call(child, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-7.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-7.js new file mode 100644 index 0000000000..1cc47a52e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-7.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + an own accessor property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +obj[0] = 12; +obj[1] = 11; +obj[2] = 9; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-8.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-8.js new file mode 100644 index 0000000000..739aed6976 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-8.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + own accessor property that overrides an inherited data property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} + +var proto = { + length: 3 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +child[0] = 12; +child[1] = 11; +child[2] = 9; + +var newArr = Array.prototype.filter.call(child, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-9.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-9.js new file mode 100644 index 0000000000..5f0a0f513b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-2-9.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + an own accessor property that overrides an inherited accessor + property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +child[0] = 12; +child[1] = 11; +child[2] = 9; + +var newArr = Array.prototype.filter.call(child, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-1.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-1.js new file mode 100644 index 0000000000..68cb7c9124 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-1.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - value of 'length' is undefined +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} + +var obj = { + 0: 0, + 1: 1, + length: undefined +}; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-10.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-10.js new file mode 100644 index 0000000000..4d2bb32d41 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-10.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a number (value is + NaN) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} + +var obj = { + 0: 9, + length: NaN +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-11.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-11.js new file mode 100644 index 0000000000..90943c5308 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-11.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is a string containing a + positive number +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 1: 11, + 2: 9, + length: "2" +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-12.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-12.js new file mode 100644 index 0000000000..8188fddfd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-12.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is a string containing a + negative number +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 1: 11, + 2: 9, + length: "-4294967294" +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-13.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-13.js new file mode 100644 index 0000000000..802c761bc1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-13.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is a string containing a decimal + number +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 1: 11, + 2: 9, + length: "2.5" +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-14.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-14.js new file mode 100644 index 0000000000..5be62103ba --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-14.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - 'length' is a string containing -Infinity +---*/ + +var accessed2 = false; + +function callbackfn2(val, idx, obj) { + accessed2 = true; + return true; +} + +var obj2 = { + 0: 9, + length: "-Infinity" +}; + +var newArr2 = Array.prototype.filter.call(obj2, callbackfn2); + +assert.sameValue(accessed2, false, 'accessed2'); +assert.sameValue(newArr2.length, 0, 'newArr2.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-15.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-15.js new file mode 100644 index 0000000000..cca36b39c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-15.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is a string containing an + exponential number +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 1: 11, + 2: 9, + length: "2E0" +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-16.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-16.js new file mode 100644 index 0000000000..29cf064b6b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-16.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is a string containing a hex + number +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 1: 11, + 2: 9, + length: "0x0002" +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-17.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-17.js new file mode 100644 index 0000000000..30b986ef1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-17.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is a string containing a number + with leading zeros +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 1: 11, + 2: 9, + length: "0002.00" +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-18.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-18.js new file mode 100644 index 0000000000..0215e2694b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-18.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a string that can't + convert to a number +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} + +var obj = { + 0: 9, + length: "asdf!_" +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(newArr.length, 0, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-19.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-19.js new file mode 100644 index 0000000000..3ab158f710 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-19.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is an Object which has + an own toString method. +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 1: 11, + 2: 9, + length: { + toString: function() { + return '2'; + } + } +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-2.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-2.js new file mode 100644 index 0000000000..22e01265b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-2.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied on an Array-like object if 'length' + is 1 (length overridden to true(type conversion)) +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 0: 11, + 1: 9, + length: true +}; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-20.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-20.js new file mode 100644 index 0000000000..f90742ca90 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-20.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is an Object which has + an own valueOf method. +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 1: 11, + 2: 9, + length: { + valueOf: function() { + return 2; + } + } +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-21.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-21.js new file mode 100644 index 0000000000..9ff6c26339 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-21.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is an object that has an own + valueOf method that returns an object and toString method that + returns a string +---*/ + +var firstStepOccured = false; +var secondStepOccured = false; + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 1: 11, + 2: 9, + length: { + valueOf: function() { + firstStepOccured = true; + return {}; + }, + toString: function() { + secondStepOccured = true; + return '2'; + } + } +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(firstStepOccured, 'firstStepOccured !== true'); +assert(secondStepOccured, 'secondStepOccured !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-22.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-22.js new file mode 100644 index 0000000000..154689a2fb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-22.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter throws TypeError exception when 'length' is + an object with toString and valueOf methods that don�t return + primitive values +---*/ + +var accessed = false; +var firstStepOccured = false; +var secondStepOccured = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} + +var obj = { + 1: 11, + 2: 12, + + length: { + valueOf: function() { + firstStepOccured = true; + return {}; + }, + toString: function() { + secondStepOccured = true; + return {}; + } + } +}; +assert.throws(TypeError, function() { + Array.prototype.filter.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); +assert(firstStepOccured, 'firstStepOccured !== true'); +assert(secondStepOccured, 'secondStepOccured !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-23.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-23.js new file mode 100644 index 0000000000..b8c1c53bf7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-23.js @@ -0,0 +1,48 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter uses inherited valueOf method when 'length' + is an object with an own toString and inherited valueOf methods +---*/ + +var valueOfAccessed = false; +var toStringAccessed = false; + +function callbackfn(val, idx, obj) { + return true; +} + +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +child.toString = function() { + toStringAccessed = true; + return '1'; +}; + +var obj = { + 1: 11, + 2: 9, + length: child +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-24.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-24.js new file mode 100644 index 0000000000..3e36d93bde --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-24.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 1: 11, + 2: 9, + length: 2.685 +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-25.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-25.js new file mode 100644 index 0000000000..7c49e457ba --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-25.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a negative + non-integer +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 1: 11, + 2: 9, + length: -4294967294.5 +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-3.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-3.js new file mode 100644 index 0000000000..1c736e81fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-3.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - value of 'length' is a number (value is 0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} + +var obj = { + 0: 11, + length: 0 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-4.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-4.js new file mode 100644 index 0000000000..b2c07a36e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-4.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a number (value is + +0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} + +var obj = { + 0: 11, + length: +0 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-5.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-5.js new file mode 100644 index 0000000000..1f42a8adb7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-5.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a number (value is + -0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} + +var obj = { + 0: 11, + length: -0 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-6.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-6.js new file mode 100644 index 0000000000..b1c1ce75a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-6.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a number (value is + positive) +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 1: 11, + 2: 9, + length: 2 +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-7.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-7.js new file mode 100644 index 0000000000..d1271b8e26 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-7.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a number (value is + negative) +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 1: 11, + 2: 9, + length: -4294967294 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-9.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-9.js new file mode 100644 index 0000000000..04964b5017 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-3-9.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a number (value is + -Infinity) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} + +var obj = { + 0: 9, + length: -Infinity +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-1.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-1.js new file mode 100644 index 0000000000..195ff47c06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter throws TypeError if callbackfn is undefined +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.filter(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-10.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-10.js new file mode 100644 index 0000000000..d96861317d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-10.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - the exception is not thrown if exception + was thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.filter.call(obj, undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-11.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-11.js new file mode 100644 index 0000000000..a9ece8bd6e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-11.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - the exception is not thrown if exception + was thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.filter.call(obj, undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-12.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-12.js new file mode 100644 index 0000000000..4b7a09be3a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-12.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - 'callbackfn' is a function +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === 9; + } + return false; +} + +var newArr = [11, 9].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 9, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-15.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-15.js new file mode 100644 index 0000000000..5da546cf1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-15.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - calling with no callbackfn is the same as + passing undefined for callbackfn +---*/ + +var obj = { + 10: 10 +}; +var lengthAccessed = false; +var loopAccessed = false; +Object.defineProperty(obj, "length", { + get: function() { + lengthAccessed = true; + return 20; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + loopAccessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.filter.call(obj); +}); +assert(lengthAccessed, 'lengthAccessed !== true'); +assert.sameValue(loopAccessed, false, 'loopAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-2.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-2.js new file mode 100644 index 0000000000..2cbeba24f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-2.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter throws ReferenceError if callbackfn is + unreferenced +---*/ + +var arr = new Array(10); +assert.throws(ReferenceError, function() { + arr.filter(foo); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-3.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-3.js new file mode 100644 index 0000000000..00e84f9daa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-3.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter throws TypeError if callbackfn is null +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.filter(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-4.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-4.js new file mode 100644 index 0000000000..c3903d90df --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-4.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter throws TypeError if callbackfn is boolean +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.filter(true); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-5.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-5.js new file mode 100644 index 0000000000..20df59f015 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-5.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter throws TypeError if callbackfn is number +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.filter(5); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-6.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-6.js new file mode 100644 index 0000000000..ea86a87569 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-6.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter throws TypeError if callbackfn is string +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.filter("abc"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-7.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-7.js new file mode 100644 index 0000000000..b5438a1094 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-7.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter throws TypeError if callbackfn is Object + without [[Call]] internal method +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.filter(new Object()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-8.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-8.js new file mode 100644 index 0000000000..ee4539946c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-8.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.filter.call(obj, null); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-9.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-9.js new file mode 100644 index 0000000000..172734d3d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-4-9.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.filter.call(obj, null); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-1-s.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-1-s.js new file mode 100644 index 0000000000..c9a8b2fdf7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-1-s.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - thisArg not passed to strict callbackfn +flags: [noStrict] +---*/ + +var innerThisCorrect = false; + +function callbackfn(val, idx, obj) { + "use strict"; + innerThisCorrect = this === undefined; + return true; +} + +[1].filter(callbackfn); + +assert(innerThisCorrect, 'innerThisCorrect !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-1.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-1.js new file mode 100644 index 0000000000..b1aa2e4d26 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-1.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - thisArg is passed +flags: [noStrict] +---*/ + +(function() { + this._15_4_4_20_5_1 = false; + var _15_4_4_20_5_1 = true; + + function callbackfn(val, idx, obj) { + return this._15_4_4_20_5_1; + } + var srcArr = [1]; + var resArr = srcArr.filter(callbackfn); + + assert.sameValue(resArr.length, 0, 'resArr.length'); +})(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-10.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-10.js new file mode 100644 index 0000000000..57f34c4413 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-10.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - Array Object can be used as thisArg +---*/ + +var accessed = false; +var objArray = new Array(10); + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objArray; +} + + +var newArr = [11].filter(callbackfn, objArray); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-11.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-11.js new file mode 100644 index 0000000000..8046262733 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-11.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - String Object can be used as thisArg +---*/ + +var accessed = false; +var objString = new String(); + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objString; +} + +var newArr = [11].filter(callbackfn, objString); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-12.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-12.js new file mode 100644 index 0000000000..38088bbfa6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-12.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - Boolean Object can be used as thisArg +---*/ + +var accessed = false; +var objBoolean = new Boolean(); + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objBoolean; +} + +var newArr = [11].filter(callbackfn, objBoolean); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-13.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-13.js new file mode 100644 index 0000000000..7015603bab --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-13.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - Number Object can be used as thisArg +---*/ + +var accessed = false; +var objNumber = new Number(); + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objNumber; +} + +var newArr = [11].filter(callbackfn, objNumber); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-14.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-14.js new file mode 100644 index 0000000000..d920aeb176 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-14.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - the Math object can be used as thisArg +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this === Math; +} + +var newArr = [11].filter(callbackfn, Math); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-15.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-15.js new file mode 100644 index 0000000000..5d8633d077 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-15.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - Date Object can be used as thisArg +---*/ + +var accessed = false; + +var objDate = new Date(); + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objDate; +} + +var newArr = [11].filter(callbackfn, objDate); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-16.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-16.js new file mode 100644 index 0000000000..cc8b0c651d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-16.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - RegExp Object can be used as thisArg +---*/ + +var accessed = false; + +var objRegExp = new RegExp(); + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objRegExp; +} + +var newArr = [11].filter(callbackfn, objRegExp); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-17.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-17.js new file mode 100644 index 0000000000..162cec62bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-17.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - the JSON object can be used as thisArg +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this === JSON; +} + +var newArr = [11].filter(callbackfn, JSON); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-18.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-18.js new file mode 100644 index 0000000000..4803e432ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-18.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - Error Object can be used as thisArg +---*/ + +var accessed = false; +var objError = new RangeError(); + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objError; +} + +var newArr = [11].filter(callbackfn, objError); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-19.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-19.js new file mode 100644 index 0000000000..fdf60d6557 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-19.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - the Arguments object can be used as + thisArg +---*/ + +var accessed = false; +var arg; + +function callbackfn(val, idx, obj) { + accessed = true; + return this === arg; +} + +(function fun() { + arg = arguments; +}(1, 2, 3)); + +var newArr = [11].filter(callbackfn, arg); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-2.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-2.js new file mode 100644 index 0000000000..3049d8b4d3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-2.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - thisArg is Object +---*/ + +var res = false; +var o = new Object(); +o.res = true; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +var srcArr = [1]; +var resArr = srcArr.filter(callbackfn, o); + +assert.sameValue(resArr.length, 1, 'resArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-21.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-21.js new file mode 100644 index 0000000000..fcee8ec25c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-21.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - the global object can be used as thisArg +---*/ + +var global = this; + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this === global; +} + +var newArr = [11].filter(callbackfn, global); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-22.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-22.js new file mode 100644 index 0000000000..5b66d3c755 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-22.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - boolean primitive can be used as thisArg +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this.valueOf() === false; +} + +var newArr = [11].filter(callbackfn, false); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-23.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-23.js new file mode 100644 index 0000000000..cc9a5e62e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-23.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - number primitive can be used as thisArg +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this.valueOf() === 101; +} + +var newArr = [11].filter(callbackfn, 101); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-24.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-24.js new file mode 100644 index 0000000000..4b8f2b9eb0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-24.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - string primitive can be used as thisArg +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this.valueOf() === "abc"; +} + +var newArr = [11].filter(callbackfn, "abc"); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-27.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-27.js new file mode 100644 index 0000000000..f53147f35e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-27.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - Array.isArray(arg) returns true when arg + is the returned array +---*/ + +var newArr = [11].filter(function() {}); + +assert(Array.isArray(newArr), 'Array.isArray(newArr) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-28.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-28.js new file mode 100644 index 0000000000..e1aad658de --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-28.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - the returned array is instanceof Array +---*/ + +var newArr = [11].filter(function() {}); + +assert(newArr instanceof Array, 'newArr instanceof Array !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-29.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-29.js new file mode 100644 index 0000000000..2c8a19cbac --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-29.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - returns an array whose length is 0 +---*/ + +var newArr = [11].filter(function() {}); + +assert.sameValue(newArr.length, 0, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-3.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-3.js new file mode 100644 index 0000000000..591e1e0c88 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-3.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - thisArg is Array +---*/ + +var res = false; +var a = new Array(); +a.res = true; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +var srcArr = [1]; +var resArr = srcArr.filter(callbackfn, a); + +assert.sameValue(resArr.length, 1, 'resArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-30.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-30.js new file mode 100644 index 0000000000..135964229e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-30.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - thisArg not passed +flags: [noStrict] +---*/ + +function innerObj() { + this._15_4_4_20_5_30 = true; + var _15_4_4_20_5_30 = false; + + function callbackfn(val, idx, obj) { + return this._15_4_4_20_5_30; + } + var srcArr = [1]; + var resArr = srcArr.filter(callbackfn); + this.retVal = resArr.length === 0; +} + +assert(new innerObj().retVal, 'new innerObj().retVal !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-4.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-4.js new file mode 100644 index 0000000000..e46344834a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-4.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-5-4 +description: > + Array.prototype.filter - thisArg is object from object + template(prototype) +---*/ + +var res = false; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +function foo() {} +foo.prototype.res = true; +var f = new foo(); + +var srcArr = [1]; +var resArr = srcArr.filter(callbackfn, f); + +assert.sameValue(resArr.length, 1, 'resArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-5.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-5.js new file mode 100644 index 0000000000..1e18d25e06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-5.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-5-5 +description: Array.prototype.filter - thisArg is object from object template +---*/ + +var res = false; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +function foo() {} +var f = new foo(); +f.res = true; + +var srcArr = [1]; +var resArr = srcArr.filter(callbackfn, f); + +assert.sameValue(resArr.length, 1, 'resArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-6.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-6.js new file mode 100644 index 0000000000..2784f54252 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-6.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-5-6 +description: Array.prototype.filter - thisArg is function +---*/ + +var res = false; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +function foo() {} +foo.res = true; + +var srcArr = [1]; +var resArr = srcArr.filter(callbackfn, foo); + +assert.sameValue(resArr.length, 1, 'resArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-7.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-7.js new file mode 100644 index 0000000000..76f7b0161a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-7.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-5-7 +description: Array.prototype.filter - built-in functions can be used as thisArg +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return this === eval; +} + +var newArr = [11].filter(callbackfn, eval); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-9.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-9.js new file mode 100644 index 0000000000..f2be4d947a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-5-9.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-5-9 +description: Array.prototype.filter - Function Object can be used as thisArg +---*/ + +var accessed = false; +var objFunction = function() {}; + +function callbackfn(val, idx, obj) { + accessed = true; + return this === objFunction; +} + +var newArr = [11].filter(callbackfn, objFunction); + +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-1.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-1.js new file mode 100644 index 0000000000..b37bd42001 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-1.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-1 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (empty array) +---*/ + +function cb() {} +var a = [].filter(cb); + +assert(Array.isArray(a), 'Array.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-2.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-2.js new file mode 100644 index 0000000000..babc443f62 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-2.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-2 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (subclassed Array, length overridden to null (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = null; + +function cb() {} +var a = f.filter(cb); + + +assert(Array.isArray(a), 'Array.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-3.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-3.js new file mode 100644 index 0000000000..fa85fb3e6d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-3.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-3 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (subclassed Array, length overridden to false (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = false; + +function cb() {} +var a = f.filter(cb); + + +assert(Array.isArray(a), 'Array.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-4.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-4.js new file mode 100644 index 0000000000..da5b339473 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-4.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-4 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (subclassed Array, length overridden to 0 (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 0; + +function cb() {} +var a = f.filter(cb); + + +assert(Array.isArray(a), 'Array.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-5.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-5.js new file mode 100644 index 0000000000..2c163c61c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-5.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-5 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (subclassed Array, length overridden to '0' (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = '0'; + +function cb() {} +var a = f.filter(cb); + + +assert(Array.isArray(a), 'Array.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-6.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-6.js new file mode 100644 index 0000000000..9284917cb5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-6.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-6 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (subclassed Array, length overridden with obj with valueOf) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; + +function cb() {} +var a = f.filter(cb); + + +assert(Array.isArray(a), 'Array.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-7.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-7.js new file mode 100644 index 0000000000..3197dd19e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-7.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-7 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (subclassed Array, length overridden with obj w/o valueOf + (toString)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. + +function cb() {} +var a = f.filter(cb); + + +assert(Array.isArray(a), 'Array.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-8.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-8.js new file mode 100644 index 0000000000..08cd6176e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-6-8.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-8 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (subclassed Array, length overridden with [] +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +f.length = []; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. + +function cb() {} +var a = f.filter(cb); + + +assert(Array.isArray(a), 'Array.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-1.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-1.js new file mode 100644 index 0000000000..005f390cc4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-1.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-1 +description: > + Array.prototype.filter doesn't consider new elements added to + array after it is called +---*/ + +function callbackfn(val, idx, obj) { + srcArr[2] = 3; + srcArr[5] = 6; + return true; +} + +var srcArr = [1, 2, , 4, 5]; +var resArr = srcArr.filter(callbackfn); + +assert.sameValue(resArr.length, 5, 'resArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-2.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-2.js new file mode 100644 index 0000000000..3814a7614f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-2.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-2 +description: > + Array.prototype.filter considers new value of elements in array + after it is called +---*/ + +function callbackfn(val, idx, obj) +{ + srcArr[2] = -1; + srcArr[4] = -1; + if (val > 0) + return true; + else + return false; +} + +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.filter(callbackfn); + +assert.sameValue(resArr.length, 3, 'resArr.length'); +assert.sameValue(resArr[0], 1, 'resArr[0]'); +assert.sameValue(resArr[2], 4, 'resArr[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-3.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-3.js new file mode 100644 index 0000000000..a793631f50 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-3.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-3 +description: > + Array.prototype.filter doesn't visit deleted elements in array + after the call +---*/ + +function callbackfn(val, idx, obj) +{ + delete srcArr[2]; + delete srcArr[4]; + if (val > 0) + return true; + else + return false; +} + +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.filter(callbackfn); + +// two elements deleted +assert.sameValue(resArr.length, 3, 'resArr.length'); +assert.sameValue(resArr[0], 1, 'resArr[0]'); +assert.sameValue(resArr[2], 4, 'resArr[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-4.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-4.js new file mode 100644 index 0000000000..84f7a666c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-4.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-4 +description: > + Array.prototype.filter doesn't visit deleted elements when + Array.length is decreased +---*/ + +function callbackfn(val, idx, obj) +{ + srcArr.length = 2; + return true; +} + +var srcArr = [1, 2, 3, 4, 6]; +var resArr = srcArr.filter(callbackfn); + +assert.sameValue(resArr.length, 2, 'resArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-5.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-5.js new file mode 100644 index 0000000000..4b29c8d726 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-5.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-5 +description: > + Array.prototype.filter doesn't consider newly added elements in + sparse array +---*/ + +function callbackfn(val, idx, obj) +{ + srcArr[1000] = 3; + return true; +} + +var srcArr = new Array(10); +srcArr[1] = 1; +srcArr[2] = 2; +var resArr = srcArr.filter(callbackfn); + +assert.sameValue(resArr.length, 2, 'resArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-6.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-6.js new file mode 100644 index 0000000000..4086e87b1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-6.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-6 +description: > + Array.prototype.filter visits deleted element in array after the + call when same index is also present in prototype +---*/ + +function callbackfn(val, idx, obj) +{ + delete srcArr[2]; + delete srcArr[4]; + if (val > 0) + return true; + else + return false; +} + +Array.prototype[4] = 5; +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.filter(callbackfn); +delete Array.prototype[4]; + +// only one element deleted +assert.sameValue(resArr.length, 4, 'resArr.length'); +assert.sameValue(resArr[0], 1, 'resArr[0]'); +assert.sameValue(resArr[3], 5, 'resArr[3]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-7.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-7.js new file mode 100644 index 0000000000..911b7bf0a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-7.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-7 +description: > + Array.prototype.filter stops calling callbackfn once the array is + deleted during the call +---*/ + +var o = new Object(); +o.srcArr = [1, 2, 3, 4, 5]; + +function callbackfn(val, idx, obj) { + delete o.srcArr; + if (val > 0) + return true; + else + return false; +} + +var resArr = o.srcArr.filter(callbackfn); + +assert.sameValue(resArr.length, 5, 'resArr.length'); +assert.sameValue(typeof o.srcArr, "undefined", 'typeof o.srcArr'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-8.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-8.js new file mode 100644 index 0000000000..36cd0cd218 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-8.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-8 +description: Array.prototype.filter - no observable effects occur if len is 0 +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + 1: 12, + length: 0 +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(obj.length, 0, 'obj.length'); +assert.sameValue(newArr.length, 0, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-9.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-9.js new file mode 100644 index 0000000000..199c15d30e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-9.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-9 +description: > + Array.prototype.filter - modifications to length don't change + number of iterations +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + return true; +} + +var obj = { + 1: 12, + 2: 9, + length: 2 +}; + +Object.defineProperty(obj, "0", { + get: function() { + obj.length = 3; + return 11; + }, + configurable: true +}); + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-1.js new file mode 100644 index 0000000000..dce5fdae23 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-1.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-1 +description: > + Array.prototype.filter - callbackfn not called for indexes never + been assigned values +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + callCnt++; + return false; +} + +var srcArr = new Array(10); +srcArr[1] = undefined; //explicitly assigning a value +var resArr = srcArr.filter(callbackfn); + +assert.sameValue(resArr.length, 0, 'resArr.length'); +assert.sameValue(callCnt, 1, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-10.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-10.js new file mode 100644 index 0000000000..bbd0c85461 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-10.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-10 +description: > + Array.prototype.filter - deleting property of prototype causes + prototype index property not to be visited on an Array-like Object +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 2: 2, + length: 20 +}; + +Object.defineProperty(obj, "0", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.notSameValue(newArr[1], 1, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-11.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-11.js new file mode 100644 index 0000000000..5b16c7f308 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-11.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-11 +description: > + Array.prototype.filter - deleting property of prototype causes + prototype index property not to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + delete Array.prototype[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.notSameValue(newArr[1], 1, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-12.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-12.js new file mode 100644 index 0000000000..5474b0e6f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-12.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-12 +description: > + Array.prototype.filter - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 0: 0, + 1: 111, + 2: 2, + length: 10 +}; + +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[1], 1, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-13.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-13.js new file mode 100644 index 0000000000..bd91c8bf50 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-13.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-13 +description: > + Array.prototype.filter - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + return val < 3 ? true : false; +} +var arr = [0, 111, 2]; + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[1], 1, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-14.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-14.js new file mode 100644 index 0000000000..3d1136e563 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-14.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-14 +description: > + Array.prototype.filter - decreasing length of array causes index + property not to be visited +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var arr = [0, 1, 2, "last"]; + +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); + +var newArr = arr.filter(callbackfn); + + +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[2], 2, 'newArr[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-15.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-15.js new file mode 100644 index 0000000000..9869b600ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-15.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-15 +description: > + Array.prototype.filter - decreasing length of array with prototype + property causes prototype index property to be visited +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var arr = [0, 1, 2]; + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[2], "prototype", 'newArr[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-16.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-16.js new file mode 100644 index 0000000000..8c47a71c1f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-16.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-16 +description: > + Array.prototype.filter - decreasing length of array does not + delete non-configurable properties +flags: [noStrict] +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var arr = [0, 1, 2]; + +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); + +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[2], "unconfigurable", 'newArr[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-2.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-2.js new file mode 100644 index 0000000000..051659aa81 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-2.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-2 +description: > + Array.prototype.filter - added properties in step 2 are visible + here +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + obj[2] = "length"; + return 3; + }, + configurable: true +}); + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], "length", 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-3.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-3.js new file mode 100644 index 0000000000..b9261879dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-3.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-3 +description: > + Array.prototype.filter - deleted properties in step 2 are visible + here +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 2: 6.99, + 8: 19 +}; + +Object.defineProperty(obj, "length", { + get: function() { + delete obj[2]; + return 10; + }, + configurable: true +}); + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.notSameValue(newArr[0], 6.99, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-4.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-4.js new file mode 100644 index 0000000000..e2af2fac14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-4.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-4 +description: > + Array.prototype.filter - properties added into own object after + current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.sameValue(newArr[1], 6.99, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-5.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-5.js new file mode 100644 index 0000000000..0095c888a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-5.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-5 +description: > + Array.prototype.filter - properties added into own object after + current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[1], 6.99, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-6.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-6.js new file mode 100644 index 0000000000..acc9dfcb04 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-6.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-6 +description: > + Array.prototype.filter - properties can be added to prototype + after current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.sameValue(Array[1], 6.99, 'Array[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-7.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-7.js new file mode 100644 index 0000000000..60f19c3b63 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-7.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-7 +description: > + Array.prototype.filter - properties can be added to prototype + after current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(Array.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[1], 6.99, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-8.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-8.js new file mode 100644 index 0000000000..08b65a302d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-8.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-8 +description: > + Array.prototype.filter - deleting own property causes index + property not to be visited on an Array-like object +---*/ + +var accessed = false; +var obj = { + length: 2 +}; + +function callbackfn(val, idx, o) { + accessed = true; + return true; +} + +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); + +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 0, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-9.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-9.js new file mode 100644 index 0000000000..2e88dde503 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-b-9.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-9 +description: > + Array.prototype.filter - deleting own property causes index + property not to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var arr = [1, 2]; + +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 0, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-1.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-1.js new file mode 100644 index 0000000000..8fae59879c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-1.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-c-i-1 +description: > + Array.prototype.filter - element to be retrieved is own data + property on an Array-like object +---*/ + +var kValue = {}; + +function callbackfn(val, idx, obj) { + return (idx === 5) && (val === kValue); +} + +var obj = { + 5: kValue, + length: 100 +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], kValue, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-10.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-10.js new file mode 100644 index 0000000000..2407566e84 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-10.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-c-i-10 +description: > + Array.prototype.filter - element to be retrieved is own accessor + property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return idx === 2 && val === 12; +} + +var arr = []; + +Object.defineProperty(arr, "2", { + get: function() { + return 12; + }, + configurable: true +}); +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 12, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-11.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-11.js new file mode 100644 index 0000000000..2d36debda2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-11.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-c-i-11 +description: > + Array.prototype.filter - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return idx === 0 && val === 11; +} + +var proto = { + 0: 5, + 1: 6 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 10; + +Object.defineProperty(child, "0", { + get: function() { + return 11; + }, + configurable: true +}); +var newArr = Array.prototype.filter.call(child, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-12.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-12.js new file mode 100644 index 0000000000..b6fcffc65a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-12.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-c-i-12 +description: > + Array.prototype.filter - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return val === 111 && idx === 0; +} + +var arr = []; + +Array.prototype[0] = 10; + +Object.defineProperty(arr, "0", { + get: function() { + return 111; + }, + configurable: true +}); +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 111, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-13.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-13.js new file mode 100644 index 0000000000..ce0d6d9343 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-13.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-c-i-13 +description: > + Array.prototype.filter - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return idx === 1 && val === 12; +} + +var proto = {}; + +Object.defineProperty(proto, "1", { + get: function() { + return 6; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 10; + +Object.defineProperty(child, "1", { + get: function() { + return 12; + }, + configurable: true +}); +var newArr = Array.prototype.filter.call(child, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 12, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-14.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-14.js new file mode 100644 index 0000000000..47fd5d8a2d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-14.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-c-i-14 +description: > + Array.prototype.filter - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return idx === 0 && val === 11; +} + +var arr = []; + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 5; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + return 11; + }, + configurable: true +}); +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-15.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-15.js new file mode 100644 index 0000000000..7f0b850f12 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-15.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return val === 11 && idx === 1; +} + +var proto = {}; + +Object.defineProperty(proto, "1", { + get: function() { + return 11; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 20; +var newArr = Array.prototype.filter.call(child, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-16.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-16.js new file mode 100644 index 0000000000..81290ab570 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-16.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is inherited + accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return idx === 0 && val === 11; +} + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 11; + }, + configurable: true +}); +var newArr = [, , , ].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-17.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-17.js new file mode 100644 index 0000000000..2245f7fffb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-17.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return undefined === val && idx === 1; +} + +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-18.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-18.js new file mode 100644 index 0000000000..d874ccc003 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-18.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +function callbackfn(val, idx, obj) { + return undefined === val && idx === 0; +} + +var arr = []; + +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-19.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-19.js new file mode 100644 index 0000000000..3c72bb4730 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-19.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return undefined === val && idx === 1; +} + +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); + +Object.prototype[1] = 10; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-2.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-2.js new file mode 100644 index 0000000000..d1653a9ee5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-2.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own data + property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-20.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-20.js new file mode 100644 index 0000000000..ed21997766 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-20.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return undefined === val && idx === 0; +} + +var arr = []; + +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +Array.prototype[0] = 100; +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-21.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-21.js new file mode 100644 index 0000000000..b666378c92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-21.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return val === undefined && idx === 1; +} + +var proto = {}; +Object.defineProperty(proto, "1", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +var newArr = Array.prototype.filter.call(child, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-22.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-22.js new file mode 100644 index 0000000000..e18f313a42 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-22.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +function callbackfn(val, idx, obj) { + return undefined === val && idx === 0; +} + +Object.defineProperty(Array.prototype, "0", { + set: function() {}, + configurable: true +}); +var newArr = [, ].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-25.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-25.js new file mode 100644 index 0000000000..718dfda7fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-25.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - This object is the Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +function callbackfn(val, idx, obj) { + return val === 11 && idx === 0; +} + +var func = function(a, b) { + return Array.prototype.filter.call(arguments, callbackfn); +}; + +var newArr = func(11); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-26.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-26.js new file mode 100644 index 0000000000..e76d51b46d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-26.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - This object is the Arguments object which + implements its own property get method (number of arguments equals + number of parameters) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } else if (idx === 1) { + return val === 9; + } else { + return false; + } +} + +var func = function(a, b) { + return Array.prototype.filter.call(arguments, callbackfn); +}; +var newArr = func(11, 9); + +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert.sameValue(newArr[1], 9, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-27.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-27.js new file mode 100644 index 0000000000..5da6560806 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-27.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - This object is the Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } else if (idx === 1) { + return val === 12; + } else if (idx === 2) { + return val === 9; + } else { + return false; + } +} + +var func = function(a, b) { + return Array.prototype.filter.call(arguments, callbackfn); +}; +var newArr = func(11, 12, 9); + +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert.sameValue(newArr[1], 12, 'newArr[1]'); +assert.sameValue(newArr[2], 9, 'newArr[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-28.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-28.js new file mode 100644 index 0000000000..03f0b1b1b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-28.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element changed by getter on previous + iterations is observed on an Array +---*/ + +var preIterVisible = false; +var arr = []; + +function callbackfn(val, idx, obj) { + return idx === 1 && val === 9; +} + +Object.defineProperty(arr, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 11; + } + }, + configurable: true +}); +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 9, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-29.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-29.js new file mode 100644 index 0000000000..9acdb8dae0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-29.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element changed by getter on previous + iterations is observed on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return val === 9 && idx === 1; +} + +var preIterVisible = false; +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 13; + } + }, + configurable: true +}); +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 9, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-3.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-3.js new file mode 100644 index 0000000000..ce8a21e6c7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-3.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return (idx === 5) && (val === "abc"); +} + +var proto = { + 0: 11, + 5: 100 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[5] = "abc"; +child.length = 10; + +var newArr = Array.prototype.filter.call(child, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], "abc", 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-30.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-30.js new file mode 100644 index 0000000000..6e85b19ef7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-30.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - unnhandled exceptions happened in getter + terminate iteration on an Array-like object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } + return true; +} + +var obj = { + 0: 11, + 5: 10, + 10: 8, + length: 20 +}; +Object.defineProperty(obj, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + Array.prototype.filter.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-31.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-31.js new file mode 100644 index 0000000000..d4ca7989db --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-31.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - unnhandled exceptions happened in getter + terminate iteration on an Array +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } + return true; +} + +var arr = []; +arr[5] = 10; +arr[10] = 100; + +Object.defineProperty(arr, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.filter(callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-4.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-4.js new file mode 100644 index 0000000000..5cf957322c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-4.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return (idx === 0) && (val === 12); +} + +Array.prototype[0] = 11; +var newArr = [12].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 12, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-5.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-5.js new file mode 100644 index 0000000000..3bc9704ed2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-5.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return idx === 0 && val === 11; +} + +var proto = {}; + +Object.defineProperty(proto, "0", { + get: function() { + return 5; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +Object.defineProperty(child, "0", { + value: 11, + configurable: true +}); +child[1] = 12; + +var newArr = Array.prototype.filter.call(child, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-6.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-6.js new file mode 100644 index 0000000000..b71fded79d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-6.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return val === 11; +} + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 9; + }, + configurable: true +}); +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-7.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-7.js new file mode 100644 index 0000000000..b0bcff3e14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-7.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is inherited data + property on an Array-like object +---*/ + +var kValue = 'abc'; + +function callbackfn(val, idx, obj) { + return (idx === 5) && (val === kValue); +} + +var proto = { + 5: kValue +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 10; + +var newArr = Array.prototype.filter.call(child, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], kValue, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-8.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-8.js new file mode 100644 index 0000000000..26edd8cf3f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-8.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is inherited data + property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return (idx === 1) && (val === 13); +} + +Array.prototype[1] = 13; +var newArr = [, , , ].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 13, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-9.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-9.js new file mode 100644 index 0000000000..33563fe84b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-i-9.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own accessor + property on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return (idx === 0) && (val === 11); +} + +var obj = { + 10: 10, + length: 20 +}; + +Object.defineProperty(obj, "0", { + get: function() { + return 11; + }, + configurable: true +}); + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-1.js new file mode 100644 index 0000000000..fe654e1055 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-1.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - callbackfn called with correct parameters +---*/ + +var bPar = true; +var bCalled = false; + +function callbackfn(val, idx, obj) +{ + bCalled = true; + if (obj[idx] !== val) + bPar = false; +} + +var srcArr = [0, 1, true, null, new Object(), "five"]; +srcArr[999999] = -6.6; +var resArr = srcArr.filter(callbackfn); + + +assert.sameValue(bCalled, true, 'bCalled'); +assert.sameValue(bPar, true, 'bPar'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-10.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-10.js new file mode 100644 index 0000000000..b1256bd8f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-10.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn is called with 1 formal + parameter +---*/ + +function callbackfn(val) { + return val > 10; +} +var newArr = [12].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 12, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-11.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-11.js new file mode 100644 index 0000000000..c698738aa1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-11.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn is called with 2 formal + parameter +---*/ + +function callbackfn(val, idx) { + return val > 10 && arguments[2][idx] === val; +} +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-12.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-12.js new file mode 100644 index 0000000000..6eab263f20 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-12.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn is called with 3 formal + parameter +---*/ + +function callbackfn(val, idx, obj) { + return val > 10 && obj[idx] === val; +} +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-13.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-13.js new file mode 100644 index 0000000000..c1c273a5f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-13.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn that uses arguments object to + get parameter value +---*/ + +function callbackfn() { + return arguments[2][arguments[1]] === arguments[0]; +} +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-16.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-16.js new file mode 100644 index 0000000000..a5037a7db3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-16.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'this' of 'callbackfn' is a Boolean + object when T is not an object (T is a boolean) +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === false; +} + +var obj = { + 0: 11, + length: 2 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn, false); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-17.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-17.js new file mode 100644 index 0000000000..a31e0c995d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-17.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter -'this' of 'callbackfn' is a Number object + when T is not an object (T is a number) +---*/ + +function callbackfn(val, idx, o) { + return 5 === this.valueOf(); +} + +var obj = { + 0: 11, + length: 2 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn, 5); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-18.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-18.js new file mode 100644 index 0000000000..c3d0237bf2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-18.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'this' of 'callbackfn' is an String + object when T is not an object (T is a string) +---*/ + +function callbackfn(val, idx, obj) { + return 'hello' === this.valueOf(); +} + +var obj = { + 0: 11, + length: 2 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn, "hello"); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-19.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-19.js new file mode 100644 index 0000000000..caf9d7c13e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-19.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - non-indexed properties are not called +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val === 8; +} + +var obj = { + 0: 11, + non_index_property: 8, + 2: 5, + length: 20 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-2.js new file mode 100644 index 0000000000..4165794019 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-2.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - callbackfn takes 3 arguments +---*/ + +var parCnt = 3; +var bCalled = false + +function callbackfn(val, idx, obj) +{ + bCalled = true; + if (arguments.length !== 3) + parCnt = arguments.length; //verify if callbackfn was called with 3 parameters +} + +var srcArr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +var resArr = srcArr.filter(callbackfn); + +assert.sameValue(bCalled, true, 'bCalled'); +assert.sameValue(parCnt, 3, 'parCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-20.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-20.js new file mode 100644 index 0000000000..922371250c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-20.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn called with correct parameters + (thisArg is correct) +---*/ + +var thisArg = { + threshold: 10 +}; + +function callbackfn(val, idx, obj) { + return this === thisArg; +} + +var obj = { + 0: 11, + length: 1 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn, thisArg); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-21.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-21.js new file mode 100644 index 0000000000..866144fbd2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-21.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn called with correct parameters + (kValue is correct) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } + + if (idx === 1) { + return val === 12; + } + + return false; +} + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert.sameValue(newArr[1], 12, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-22.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-22.js new file mode 100644 index 0000000000..38c78e20af --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-22.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn called with correct parameters + (the index k is correct) +---*/ + +function callbackfn(val, idx, obj) { + if (val === 11) { + return idx === 0; + } + + if (val === 12) { + return idx === 1; + } + + return false; +} + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert.sameValue(newArr[1], 12, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-23.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-23.js new file mode 100644 index 0000000000..2bc0f778f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-23.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn called with correct parameters + (this object O is correct) +---*/ + +var obj = { + 0: 11, + length: 2 +}; + +function callbackfn(val, idx, o) { + return obj === o; +} + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-4.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-4.js new file mode 100644 index 0000000000..7244da2879 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-4.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - k values are passed in ascending numeric + order +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +var lastIdx = 0; +var called = 0; + +function callbackfn(val, idx, o) { + called++; + if (lastIdx !== idx) { + return false; + } else { + lastIdx++; + return true; + } +} +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, called, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-5.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-5.js new file mode 100644 index 0000000000..277c5acf61 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-5.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - k values are accessed during each + iteration and not prior to starting the loop on an Array +---*/ + +var kIndex = []; +var called = 0; + +//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(val, idx, obj) { + called++; + //Each position should be visited one time, which means k is accessed one time during iterations. + if (kIndex[idx] === undefined) { + //when current position is visited, its previous index should has been visited. + if (idx !== 0 && kIndex[idx - 1] === undefined) { + return true; + } + kIndex[idx] = 1; + return false; + } else { + return true; + } +} +var newArr = [11, 12, 13, 14].filter(callbackfn, undefined); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(called, 4, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-6.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-6.js new file mode 100644 index 0000000000..d2df7c598b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-6.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - arguments to callbackfn are self + consistent +---*/ + +var obj = { + 0: 11, + length: 1 +}; +var thisArg = {}; + +function callbackfn() { + return this === thisArg && + arguments[0] === 11 && + arguments[1] === 0 && + arguments[2] === obj; +} + +var newArr = Array.prototype.filter.call(obj, callbackfn, thisArg); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-7.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-7.js new file mode 100644 index 0000000000..825c76941d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-7.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - unhandled exceptions happened in + callbackfn terminate iteration +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + if (called === 1) { + throw new Error("Exception occurred in callbackfn"); + } + return true; +} + +var obj = { + 0: 11, + 4: 10, + 10: 8, + length: 20 +}; +assert.throws(Error, function() { + Array.prototype.filter.call(obj, callbackfn); +}); +assert.sameValue(called, 1, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-8.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-8.js new file mode 100644 index 0000000000..15741a6d34 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-8.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element changed by callbackfn on previous + iterations is observed +---*/ + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +function callbackfn(val, idx, o) { + if (idx === 0) { + obj[idx + 1] = 8; + } + return val > 10; +} + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-9.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-9.js new file mode 100644 index 0000000000..11c144921f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-ii-9.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn is called with 0 formal + parameter +---*/ + +function callbackfn() { + return true; +} +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-1.js new file mode 100644 index 0000000000..a7f966813a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-1.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of returned array element equals to + 'kValue' +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr[0], obj[0], 'newArr[0]'); +assert.sameValue(newArr[1], obj[1], 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-2.js new file mode 100644 index 0000000000..6dfdc285d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-2.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of returned array element can be + overwritten +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +var tempVal = newArr[1]; +newArr[1] += 1; + +assert.notSameValue(newArr[1], tempVal, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-3.js new file mode 100644 index 0000000000..6b66f5f114 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-3.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of returned array element can be + enumerated +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 0: 11, + length: 2 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +var prop; +var enumerable = false; +for (prop in newArr) { + if (newArr.hasOwnProperty(prop)) { + if (prop === "0") { + enumerable = true; + } + } +} + +assert(enumerable, 'enumerable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-4.js new file mode 100644 index 0000000000..df599b8bfa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-4.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of returned array element can be + changed or deleted +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +var newArr = Array.prototype.filter.call(obj, callbackfn); + +var tempVal = newArr[1]; +delete newArr[1]; + +assert.notSameValue(tempVal, undefined, 'tempVal'); +assert.sameValue(newArr[1], undefined, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-5.js new file mode 100644 index 0000000000..3bd6dcc5cb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-5.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - values of 'to' are passed in acending + numeric order +---*/ + +var arr = [0, 1, 2, 3, 4]; +var lastToIdx = 0; +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + if (lastToIdx !== idx) { + return false; + } else { + lastToIdx++; + return true; + } +} +var newArr = arr.filter(callbackfn); + +assert.sameValue(newArr.length, 5, 'newArr.length'); +assert.sameValue(called, 5, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-6.js new file mode 100644 index 0000000000..1ff610ed7f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1-6.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - values of 'to' are accessed during each + iteration when 'selected' is converted to true and not prior to + starting the loop +---*/ + +var toIndex = []; +var called = 0; + +//By below way, we could verify that 'to' would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(val, idx, obj) { + called++; + //Each position should be visited one time, which means 'to' is accessed one time during iterations. + if (toIndex[idx] === undefined) { + //when current position is visited, its previous index should has been visited. + if (idx !== 0 && toIndex[idx - 1] === undefined) { + return false; + } + toIndex[idx] = 1; + return true; + } else { + return false; + } +} +var newArr = [11, 12, 13, 14].filter(callbackfn, undefined); + +assert.sameValue(newArr.length, 4, 'newArr.length'); +assert.sameValue(called, 4, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1.js new file mode 100644 index 0000000000..b50fe6d2f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - getOwnPropertyDescriptor(all true) of + returned array element +---*/ + +function callbackfn(val, idx, obj) { + if (val % 2) + return true; + else + return false; +} +var srcArr = [0, 1, 2, 3, 4]; +var resArr = srcArr.filter(callbackfn); + +assert(resArr.length > 0, 'resArr.length > 0'); + +var desc = Object.getOwnPropertyDescriptor(resArr, 1); + +assert.sameValue(desc.value, 3, 'desc.value'); //srcArr[1] = true +assert.sameValue(desc.writable, true, 'desc.writable'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-10.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-10.js new file mode 100644 index 0000000000..b45947f805 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-10.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a number + (value is negative number) +---*/ + +function callbackfn(val, idx, obj) { + return -5; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-11.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-11.js new file mode 100644 index 0000000000..31c26199c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-11.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a number + (value is Infinity) +---*/ + +function callbackfn(val, idx, obj) { + return Infinity; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-12.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-12.js new file mode 100644 index 0000000000..8fd6b71d46 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-12.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a number + (value is -Infinity) +---*/ + +function callbackfn(val, idx, obj) { + return -Infinity; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-13.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-13.js new file mode 100644 index 0000000000..93770cfb67 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-13.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a number + (value is NaN) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return NaN; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-14.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-14.js new file mode 100644 index 0000000000..36884f363c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-14.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is an empty + string +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return ""; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-15.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-15.js new file mode 100644 index 0000000000..dd791bbe27 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-15.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a non-empty + string +---*/ + +function callbackfn(val, idx, obj) { + return "non-empty string"; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-16.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-16.js new file mode 100644 index 0000000000..cde900a1d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-16.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a Function + object +---*/ + +function callbackfn(val, idx, obj) { + return function() {}; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-17.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-17.js new file mode 100644 index 0000000000..7555efa70c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-17.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is an Array + object +---*/ + +function callbackfn(val, idx, obj) { + return new Array(10); +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-18.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-18.js new file mode 100644 index 0000000000..8240f69cfc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-18.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a String + object +---*/ + +function callbackfn(val, idx, obj) { + return new String(); +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-19.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-19.js new file mode 100644 index 0000000000..cb47321ea4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-19.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a Boolean + object +---*/ + +function callbackfn(val, idx, obj) { + return new Boolean(); +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-2.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-2.js new file mode 100644 index 0000000000..9a6f784bf2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-2.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - return value of callbackfn is undefined +---*/ + +var accessed = false; + +function callbackfn(val, idx, o) { + accessed = true; + return undefined; +} + +var obj = { + 0: 11, + length: 1 +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-20.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-20.js new file mode 100644 index 0000000000..09a90a5db9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-20.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a Number + object +---*/ + +function callbackfn(val, idx, obj) { + return new Number(); +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-21.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-21.js new file mode 100644 index 0000000000..222219ecd3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-21.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is the Math + object +---*/ + +function callbackfn(val, idx, obj) { + return Math; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-22.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-22.js new file mode 100644 index 0000000000..d935e2d12f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-22.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a Date + object +---*/ + +function callbackfn(val, idx, obj) { + return new Date(); +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-23.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-23.js new file mode 100644 index 0000000000..7ddcfd05c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-23.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a RegExp + object +---*/ + +function callbackfn(val, idx, obj) { + return new RegExp(); +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-24.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-24.js new file mode 100644 index 0000000000..99df34f35a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-24.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is the JSON + object +---*/ + +function callbackfn(val, idx, obj) { + return JSON; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-25.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-25.js new file mode 100644 index 0000000000..7d83be14e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-25.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is an Error + object +---*/ + +function callbackfn(val, idx, obj) { + return new EvalError(); +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-26.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-26.js new file mode 100644 index 0000000000..bcbd116e10 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-26.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is the + Arguments object +---*/ + +function callbackfn(val, idx, obj) { + return arguments; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-28.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-28.js new file mode 100644 index 0000000000..990d93dfe2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-28.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is the global + object +---*/ + +var global = this; + +function callbackfn(val, idx, obj) { + return global; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-29.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-29.js new file mode 100644 index 0000000000..a07954a33f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-29.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - false prevents element added to output + Array +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + return val > 10; +} + +var obj = { + 0: 11, + 1: 8, + length: 20 +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.notSameValue(newArr[0], 8, 'newArr[0]'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-3.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-3.js new file mode 100644 index 0000000000..5899132312 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-3.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - return value of callbackfn is null +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return null; +} + +var obj = { + 0: 11, + length: 1 +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-30.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-30.js new file mode 100644 index 0000000000..ba0497c761 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-30.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value (new Boolean(false)) of + callbackfn is treated as true value +---*/ + +function callbackfn(val, idx, obj) { + return new Boolean(false); +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-4.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-4.js new file mode 100644 index 0000000000..eaf48e0554 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-4.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a boolean + (value is false) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return false; +} + +var obj = { + 0: 11, + length: 1 +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-5.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-5.js new file mode 100644 index 0000000000..e80422ec13 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-5.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a boolean + (value is true) +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 0: 11, + length: 1 +}; + +var newArr = Array.prototype.filter.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-6.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-6.js new file mode 100644 index 0000000000..47e984643e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-6.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a number + (value is 0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return 0; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-7.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-7.js new file mode 100644 index 0000000000..c5d81dc4e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-7.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a number + (value is +0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return +0; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-8.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-8.js new file mode 100644 index 0000000000..603f47378f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-8.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a nunmber + (value is -0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return -0; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-9.js b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-9.js new file mode 100644 index 0000000000..759f76f46b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-9.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a number + (value is positive number) +---*/ + +function callbackfn(val, idx, obj) { + return 5; +} + +var newArr = [11].filter(callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/browser.js b/js/src/tests/test262/built-ins/Array/prototype/filter/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/filter/call-with-boolean.js new file mode 100644 index 0000000000..cc9590aa33 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/call-with-boolean.js @@ -0,0 +1,21 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to boolean primitive +includes: [compareArray.js] +---*/ + +assert.compareArray( + Array.prototype.filter.call(true, () => {}), + [], + 'Array.prototype.filter.call(true, () => {}) must return []' +); +assert.compareArray( + Array.prototype.filter.call(false, () => {}), + [], + 'Array.prototype.filter.call(false, () => {}) must return []' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/filter/callbackfn-resize-arraybuffer.js new file mode 100644 index 0000000000..ef7612695d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/callbackfn-resize-arraybuffer.js @@ -0,0 +1,74 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.filter +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.filter.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return true; + }); + + assert.compareArray(elements, expectedElements, 'elements (shrink)'); + assert.compareArray(indices, expectedIndices, 'indices (shrink)'); + assert.compareArray(arrays, expectedArrays, 'arrays (shrink)'); + assert.compareArray(result, expectedElements, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.filter.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return true; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.compareArray(result, expectedElements, 'result (grow)'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/create-ctor-non-object.js b/js/src/tests/test262/built-ins/Array/prototype/filter/create-ctor-non-object.js new file mode 100644 index 0000000000..afab7f214f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/create-ctor-non-object.js @@ -0,0 +1,53 @@ +// 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-array.prototype.filter +description: > + Behavior when `constructor` property is neither an Object nor undefined +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 9. If IsConstructor(C) is false, throw a TypeError exception. +---*/ + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 0; +}; + +a.constructor = null; +assert.throws(TypeError, function() { + a.filter(cb); +}, 'null value'); +assert.sameValue(callCount, 0, 'callback not invoked (null value)'); + +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.filter(cb); +}, 'number value'); +assert.sameValue(callCount, 0, 'callback not invoked (number value)'); + +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.filter(cb); +}, 'string value'); +assert.sameValue(callCount, 0, 'callback not invoked (string value)'); + +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.filter(cb); +}, 'boolean value'); +assert.sameValue(callCount, 0, 'callback not invoked (boolean value)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/create-ctor-poisoned.js b/js/src/tests/test262/built-ins/Array/prototype/filter/create-ctor-poisoned.js new file mode 100644 index 0000000000..77290e1cdd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/create-ctor-poisoned.js @@ -0,0 +1,34 @@ +// 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-array.prototype.filter +description: Abrupt completion from `constructor` property access +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). +---*/ + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 1; +}; + +Object.defineProperty(a, 'constructor', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + a.filter(cb); +}); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/create-non-array.js b/js/src/tests/test262/built-ins/Array/prototype/filter/create-non-array.js new file mode 100644 index 0000000000..1c95704270 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/create-non-array.js @@ -0,0 +1,36 @@ +// 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-array.prototype.filter +description: Constructor is ignored for non-Array values +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). +---*/ + +var obj = { + length: 0 +}; +var callCount = 0; +var result; +Object.defineProperty(obj, 'constructor', { + get: function() { + callCount += 1; + } +}); + +result = Array.prototype.filter.call(obj, function() {}); + +assert.sameValue(callCount, 0, '`constructor` property not accessed'); +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert(Array.isArray(result), 'result is an Array exotic object'); +assert.sameValue(result.length, 0, 'array created with appropriate length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/create-proto-from-ctor-realm-array.js b/js/src/tests/test262/built-ins/Array/prototype/filter/create-proto-from-ctor-realm-array.js new file mode 100644 index 0000000000..fe8d6ce281 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/create-proto-from-ctor-realm-array.js @@ -0,0 +1,45 @@ +// 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-array.prototype.filter +description: Prefer Array constructor of current realm record +info: | + 1. Let O be ? ToObject(this value). + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C + be undefined. + [...] +features: [cross-realm, Symbol.species] +---*/ + +var array = []; +var callCount = 0; +var OArray = $262.createRealm().global.Array; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OArray; + +Object.defineProperty(Array, Symbol.species, speciesDesc); +Object.defineProperty(OArray, Symbol.species, speciesDesc); + +result = array.filter(function() {}); + +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert.sameValue(callCount, 0, 'Species constructor is not referenced'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/create-proto-from-ctor-realm-non-array.js b/js/src/tests/test262/built-ins/Array/prototype/filter/create-proto-from-ctor-realm-non-array.js new file mode 100644 index 0000000000..9909bf2d2f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/create-proto-from-ctor-realm-non-array.js @@ -0,0 +1,46 @@ +// 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-array.prototype.filter +description: Accept non-Array constructors from other realms +info: | + 1. Let O be ? ToObject(this value). + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C + be undefined. + [...] +features: [cross-realm, Symbol.species] +---*/ + +var array = []; +var callCount = 0; +var CustomCtor = function() {}; +var OObject = $262.createRealm().global.Object; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OObject; +OObject[Symbol.species] = CustomCtor; + +Object.defineProperty(Array, Symbol.species, speciesDesc); + +result = array.filter(function() {}); + +assert.sameValue(Object.getPrototypeOf(result), CustomCtor.prototype); +assert.sameValue(callCount, 0, 'Array species constructor is not referenced'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/create-proxy.js b/js/src/tests/test262/built-ins/Array/prototype/filter/create-proxy.js new file mode 100644 index 0000000000..53fdf04bc0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/create-proxy.js @@ -0,0 +1,41 @@ +// 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-array.prototype.filter +description: Species constructor of a Proxy object whose target is an array +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + 9. Return A. + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + + 7.2.2 IsArray + + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is + null, throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy, Symbol.species] +---*/ + +var array = []; +var proxy = new Proxy(new Proxy(array, {}), {}); +var Ctor = function() {}; +var result; + +array.constructor = function() {}; +array.constructor[Symbol.species] = Ctor; + +result = Array.prototype.filter.call(proxy, function() {}); + +assert.sameValue(Object.getPrototypeOf(result), Ctor.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/create-revoked-proxy.js b/js/src/tests/test262/built-ins/Array/prototype/filter/create-revoked-proxy.js new file mode 100644 index 0000000000..e49abe2f44 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/create-revoked-proxy.js @@ -0,0 +1,46 @@ +// 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-array.prototype.filter +description: Abrupt completion from constructor that is a revoked Proxy object +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + + 7.2.2 IsArray + + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is + null, throw a TypeError exception. +features: [Proxy] +---*/ + +var o = Proxy.revocable([], {}); +var ctorCount = 0; +var cbCount = 0; +var cb = function() { + cbCount += 1; +}; + +Object.defineProperty(o.proxy, 'constructor', { + get: function() { + ctorCount += 1; + } +}); +o.revoke(); + +assert.throws(TypeError, function() { + Array.prototype.filter.call(o.proxy, cb); +}); + +assert.sameValue(ctorCount, 0, '`constructor` property not accessed'); +assert.sameValue(cbCount, 0, 'callback not invoked'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-abrupt.js b/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-abrupt.js new file mode 100644 index 0000000000..1380003108 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-abrupt.js @@ -0,0 +1,40 @@ +// 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-array.prototype.filter +description: Species constructor returns an abrupt completion +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var Ctor = function() { + throw new Test262Error(); +}; +var callCount = 0; +var cb = function() { + callCount += 1; +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; + +assert.throws(Test262Error, function() { + a.filter(cb); +}); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-non-ctor.js b/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-non-ctor.js new file mode 100644 index 0000000000..fff049a2c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-non-ctor.js @@ -0,0 +1,46 @@ +// 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-array.prototype.filter +description: > + Behavior when the @@species attribute is a non-constructor object +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 9. If IsConstructor(C) is false, throw a TypeError exception. +includes: [isConstructor.js] +features: [Symbol.species, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(parseInt), + false, + 'precondition: isConstructor(parseInt) must return false' +); + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 1; +}; + +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; + +assert.throws(TypeError, function() { + a.filter(cb); +}, 'a.filter(cb) throws a TypeError exception'); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-null.js b/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-null.js new file mode 100644 index 0000000000..a1cf95abff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-null.js @@ -0,0 +1,35 @@ +// 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-array.prototype.filter +description: > + A null value for the @@species constructor is interpreted as `undefined` +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). +features: [Symbol.species] +---*/ + +var a = []; +var result; + +a.constructor = {}; +a.constructor[Symbol.species] = null; + +result = a.filter(function() {}); + +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert(Array.isArray(result), 'result is an Array exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-poisoned.js b/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-poisoned.js new file mode 100644 index 0000000000..dbab47d6ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-poisoned.js @@ -0,0 +1,39 @@ +// 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-array.prototype.filter +description: Abrupt completion from `@@species` property access +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). +features: [Symbol.species] +---*/ + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 1; +}; +a.constructor = {}; + +Object.defineProperty(a.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + a.filter(cb); +}); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-undef.js b/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-undef.js new file mode 100644 index 0000000000..ec36822363 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-undef.js @@ -0,0 +1,36 @@ +// 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-array.prototype.filter +description: > + An undefined value for the @@species constructor triggers the creation of + an Array exotic object +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). +features: [Symbol.species] +---*/ + +var a = []; +var result; + +a.constructor = {}; +a.constructor[Symbol.species] = undefined; + +result = a.filter(function() {}); + +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert(Array.isArray(result), 'result is an Array exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/create-species.js b/js/src/tests/test262/built-ins/Array/prototype/filter/create-species.js new file mode 100644 index 0000000000..82eadd41e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/create-species.js @@ -0,0 +1,45 @@ +// 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-array.prototype.filter +description: Species constructor is used to create a new instance +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var thisValue, args, result; +var callCount = 0; +var instance = []; +var Ctor = function() { + callCount += 1; + thisValue = this; + args = arguments; + return instance; +}; +var a = [1, 2, 3, 4, 5, 6, 7]; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; + +result = a.filter(function() {}); + +assert.sameValue(callCount, 1, 'Constructor invoked exactly once'); +assert.sameValue(Object.getPrototypeOf(thisValue), Ctor.prototype); +assert.sameValue(args.length, 1, 'Constructor invoked with a single argument'); +assert.sameValue(args[0], 0); +assert.sameValue(result, instance); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/length.js b/js/src/tests/test262/built-ins/Array/prototype/filter/length.js new file mode 100644 index 0000000000..06c9cf9762 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + The "length" property of Array.prototype.filter +info: | + 22.1.3.7 Array.prototype.filter ( callbackfn [ , thisArg ] ) + + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.filter.length, 1); + +verifyNotEnumerable(Array.prototype.filter, 'length'); +verifyNotWritable(Array.prototype.filter, 'length'); +verifyConfigurable(Array.prototype.filter, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/name.js b/js/src/tests/test262/built-ins/Array/prototype/filter/name.js new file mode 100644 index 0000000000..4fbfcefd92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter.name is "filter". +info: | + Array.prototype.filter ( callbackfn [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.filter.name, "filter"); + +verifyNotEnumerable(Array.prototype.filter, "name"); +verifyNotWritable(Array.prototype.filter, "name"); +verifyConfigurable(Array.prototype.filter, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/filter/not-a-constructor.js new file mode 100644 index 0000000000..f9b011ced5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/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: > + Array.prototype.filter 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.filter), + false, + 'isConstructor(Array.prototype.filter) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.filter(() => {}); +}, '`new Array.prototype.filter(() => {})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/filter/prop-desc.js new file mode 100644 index 0000000000..2f7d688805 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + "filter" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.filter, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "filter"); +verifyWritable(Array.prototype, "filter"); +verifyConfigurable(Array.prototype, "filter"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/shell.js b/js/src/tests/test262/built-ins/Array/prototype/filter/shell.js new file mode 100644 index 0000000000..05fecd6ef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/shell.js @@ -0,0 +1,161 @@ +// GENERATED, DO NOT EDIT +// file: testTypedArray.js +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - floatArrayConstructors + - nonClampedIntArrayConstructors + - intArrayConstructors + - typedArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - nonAtomicsFriendlyTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +var floatArrayConstructors = [ + Float64Array, + Float32Array +]; + +var nonClampedIntArrayConstructors = [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array +]; + +var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]); + +// Float16Array is a newer feature +// adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it +if (typeof Float16Array !== 'undefined') { + floatArrayConstructors.push(Float16Array); +} + +/** + * Array containing every non-bigint typed array constructor. + */ + +var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]); +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} + +/** + * Checks if the given argument is one of the float-based TypedArray constructors. + * + * @param {constructor} ctor - the value to check + * @returns {boolean} + */ +function isFloatTypedArrayConstructor(arg) { + return floatArrayConstructors.indexOf(arg) !== -1; +} + +/** + * Determines the precision of the given float-based TypedArray constructor. + * + * @param {constructor} ctor - the value to check + * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively. + */ +function floatTypedArrayConstructorPrecision(FA) { + if (typeof Float16Array !== "undefined" && FA === Float16Array) { + return "half"; + } else if (FA === Float32Array) { + return "single"; + } else if (FA === Float64Array) { + return "double"; + } else { + throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray"); + } +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/target-array-non-extensible.js b/js/src/tests/test262/built-ins/Array/prototype/filter/target-array-non-extensible.js new file mode 100644 index 0000000000..e7f4d9e56b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/target-array-non-extensible.js @@ -0,0 +1,44 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible) +info: | + Array.prototype.filter ( callbackfn [ , thisArg ] ) + + [...] + 7. Repeat, while k < len + [...] + c. If kPresent is true, then + [...] + iii. If selected is true, then + 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; + +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.filter(function() { + return true; + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/target-array-with-non-configurable-property.js b/js/src/tests/test262/built-ins/Array/prototype/filter/target-array-with-non-configurable-property.js new file mode 100644 index 0000000000..2ee21a69ab --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/target-array-with-non-configurable-property.js @@ -0,0 +1,46 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable) +info: | + Array.prototype.filter ( callbackfn [ , thisArg ] ) + + [...] + 7. Repeat, while k < len + [...] + c. If kPresent is true, then + [...] + iii. If selected is true, then + 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + writable: true, + configurable: false, + }); +}; + +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.filter(function() { + return true; + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/target-array-with-non-writable-property.js b/js/src/tests/test262/built-ins/Array/prototype/filter/target-array-with-non-writable-property.js new file mode 100644 index 0000000000..f158da2e74 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/target-array-with-non-writable-property.js @@ -0,0 +1,39 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Non-writable properties are overwritten by CreateDataPropertyOrThrow. +info: | + 22.1.3.7 Array.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + iii. If selected is true, then + 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue). + ... +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var a = [1]; +a.constructor = {}; +a.constructor[Symbol.species] = function(len) { + var q = new Array(0); + Object.defineProperty(q, 0, { + value: 0, writable: false, configurable: true, enumerable: false, + }); + return q; +}; + +var r = a.filter(function(){ return true; }); + +verifyProperty(r, 0, { + value: 1, writable: true, configurable: true, enumerable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/array-altered-during-loop.js b/js/src/tests/test262/built-ins/Array/prototype/find/array-altered-during-loop.js new file mode 100644 index 0000000000..4cedb36f08 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/array-altered-during-loop.js @@ -0,0 +1,49 @@ +// 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-array.prototype.find +description: > + The range of elements processed is set before the first call to `predicate`. +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 6. If thisArg was supplied, let T be thisArg; else let T be undefined. + 7. Let k be 0. + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + ... +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var results = []; + +arr.find(function(kValue) { + if (results.length === 0) { + arr.splice(1, 1); + } + results.push(kValue); +}); + +assert.sameValue(results.length, 3, 'predicate called three times'); +assert.sameValue(results[0], 'Shoes'); +assert.sameValue(results[1], 'Bike'); +assert.sameValue(results[2], undefined); + +results = []; +arr = ['Skateboard', 'Barefoot']; +arr.find(function(kValue) { + if (results.length === 0) { + arr.push('Motorcycle'); + arr[1] = 'Magic Carpet'; + } + + results.push(kValue); +}); + +assert.sameValue(results.length, 2, 'predicate called twice'); +assert.sameValue(results[0], 'Skateboard'); +assert.sameValue(results[1], 'Magic Carpet'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/browser.js b/js/src/tests/test262/built-ins/Array/prototype/find/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/find/call-with-boolean.js new file mode 100644 index 0000000000..4ac4e5fa42 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/call-with-boolean.js @@ -0,0 +1,20 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.find +description: Array.prototype.find applied to boolean primitive +---*/ + +assert.sameValue( + Array.prototype.find.call(true, () => {}), + undefined, + 'Array.prototype.find.call(true, () => {}) must return undefined' +); +assert.sameValue( + Array.prototype.find.call(false, () => {}), + undefined, + 'Array.prototype.find.call(false, () => {}) must return undefined' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/find/callbackfn-resize-arraybuffer.js new file mode 100644 index 0000000000..31a7b55750 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/callbackfn-resize-arraybuffer.js @@ -0,0 +1,76 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.find +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var finalElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.find.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + finalElement = undefined; + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + finalElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)'); + assert.compareArray(indices, [0, 1, 2], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, undefined, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.find.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, undefined, 'result (grow)'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/length.js b/js/src/tests/test262/built-ins/Array/prototype/find/length.js new file mode 100644 index 0000000000..2522319483 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/length.js @@ -0,0 +1,20 @@ +// 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-array.prototype.find +description: Array.prototype.find.length value and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.find.length, 1, + 'The value of `Array.prototype.find.length` is `1`' +); + +verifyNotEnumerable(Array.prototype.find, 'length'); +verifyNotWritable(Array.prototype.find, 'length'); +verifyConfigurable(Array.prototype.find, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/name.js b/js/src/tests/test262/built-ins/Array/prototype/find/name.js new file mode 100644 index 0000000000..8a4c21fe67 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/name.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-array.prototype.find +description: > + Array.prototype.find.name value and descriptor. +info: | + 22.1.3.8 Array.prototype.find ( predicate [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.find.name, 'find', + 'The value of `Array.prototype.find.name` is `"find"`' +); + +verifyNotEnumerable(Array.prototype.find, 'name'); +verifyNotWritable(Array.prototype.find, 'name'); +verifyConfigurable(Array.prototype.find, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/find/not-a-constructor.js new file mode 100644 index 0000000000..8e2d17caff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/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: > + Array.prototype.find 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, arrow-function] +---*/ + +assert.sameValue(isConstructor(Array.prototype.find), false, 'isConstructor(Array.prototype.find) must return false'); + +assert.throws(TypeError, () => { + new Array.prototype.find(() => {}); +}, '`new Array.prototype.find(() => {})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/predicate-call-parameters.js b/js/src/tests/test262/built-ins/Array/prototype/find/predicate-call-parameters.js new file mode 100644 index 0000000000..aa9483c656 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/predicate-call-parameters.js @@ -0,0 +1,48 @@ +// 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-array.prototype.find +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 6. If thisArg was supplied, let T be thisArg; else let T be undefined. + 7. Let k be 0. + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + e. ReturnIfAbrupt(testResult). + ... +---*/ + +var arr = ['Mike', 'Rick', 'Leo']; + +var results = []; + +arr.find(function(kValue, k, O) { + results.push(arguments); +}); + +assert.sameValue(results.length, 3); + +var result = results[0]; +assert.sameValue(result[0], 'Mike'); +assert.sameValue(result[1], 0); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); + +result = results[1]; +assert.sameValue(result[0], 'Rick'); +assert.sameValue(result[1], 1); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); + +result = results[2]; +assert.sameValue(result[0], 'Leo'); +assert.sameValue(result[1], 2); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/Array/prototype/find/predicate-call-this-non-strict.js new file mode 100644 index 0000000000..b9b1827fb0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/predicate-call-this-non-strict.js @@ -0,0 +1,34 @@ +// 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-array.prototype.find +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + e. ReturnIfAbrupt(testResult). + ... +flags: [noStrict] +---*/ + +var result; + +[1].find(function(kValue, k, O) { + result = this; +}); + +assert.sameValue(result, this); + +var o = {}; +[1].find(function() { + result = this; +}, o); + +assert.sameValue(result, o); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/Array/prototype/find/predicate-call-this-strict-strict.js new file mode 100644 index 0000000000..4ed3a65b04 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/predicate-call-this-strict-strict.js @@ -0,0 +1,35 @@ +'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-array.prototype.find +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + e. ReturnIfAbrupt(testResult). + ... +flags: [onlyStrict] +---*/ + +var result; + +[1].find(function(kValue, k, O) { + result = this; +}); + +assert.sameValue(result, undefined); + +var o = {}; +[1].find(function() { + result = this; +}, o); + +assert.sameValue(result, o); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/predicate-called-for-each-array-property.js b/js/src/tests/test262/built-ins/Array/prototype/find/predicate-called-for-each-array-property.js new file mode 100644 index 0000000000..6e42134880 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/predicate-called-for-each-array-property.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-array.prototype.find +description: > + Predicate is called for each array property. +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 6. If thisArg was supplied, let T be thisArg; else let T be undefined. + 7. Let k be 0. + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + ... +---*/ + +var arr = [undefined, , , 'foo']; +var called = 0; + +arr.find(function() { + called++; +}); + +assert.sameValue(called, 4); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/Array/prototype/find/predicate-is-not-callable-throws.js new file mode 100644 index 0000000000..09266c14a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/predicate-is-not-callable-throws.js @@ -0,0 +1,51 @@ +// 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-array.prototype.find +description: > + Throws a TypeError exception if predicate is not callable. +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 5. If IsCallable(predicate) is false, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + [].find({}); +}); + +assert.throws(TypeError, function() { + [].find(null); +}); + +assert.throws(TypeError, function() { + [].find(undefined); +}); + +assert.throws(TypeError, function() { + [].find(true); +}); + +assert.throws(TypeError, function() { + [].find(1); +}); + +assert.throws(TypeError, function() { + [].find(''); +}); + +assert.throws(TypeError, function() { + [].find(1); +}); + +assert.throws(TypeError, function() { + [].find([]); +}); + +assert.throws(TypeError, function() { + [].find(/./); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/Array/prototype/find/predicate-not-called-on-empty-array.js new file mode 100644 index 0000000000..115e03774a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/predicate-not-called-on-empty-array.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-array.prototype.find +description: > + Predicate is only called if this.length is > 0. +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 7. Let k be 0. + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + ... + 9. Return undefined. +---*/ + +var called = false; + +var predicate = function() { + called = true; + return true; +}; + +var result = [].find(predicate); + +assert.sameValue(called, false, '[].find(predicate) does not call predicate'); +assert.sameValue(result, undefined, '[].find(predicate) returned undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/find/prop-desc.js new file mode 100644 index 0000000000..1e36c8a92f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/prop-desc.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-array.prototype.find +description: Property type and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Array.prototype.find, + 'function', + '`typeof Array.prototype.find` is `function`' +); + +verifyNotEnumerable(Array.prototype, 'find'); +verifyWritable(Array.prototype, 'find'); +verifyConfigurable(Array.prototype, 'find'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-predicate-call.js new file mode 100644 index 0000000000..d12cc87369 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-predicate-call.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-array.prototype.find +description: > + Return abrupt from predicate call. +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 7. Let k be 0. + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + e. ReturnIfAbrupt(testResult). + ... +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + [1].find(predicate); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-property.js b/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-property.js new file mode 100644 index 0000000000..27d0bd6870 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-property.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-array.prototype.find +description: > + Returns abrupt from getting property value from `this`. +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 7. Let k be 0. + 8. Repeat, while k < len + a. Let Pk be ToString(k). + b. Let kValue be Get(O, Pk). + c. ReturnIfAbrupt(kValue). + ... +---*/ + +var o = { + length: 1 +}; + +Object.defineProperty(o, 0, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + [].find.call(o, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-this-length-as-symbol.js b/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-this-length-as-symbol.js new file mode 100644 index 0000000000..25fc55d79f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-this-length-as-symbol.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-array.prototype.find +description: > + Return abrupt from ToLength(Get(O, "length")) where length is a Symbol. +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let len be ToLength(Get(O, "length")). + 4. ReturnIfAbrupt(len). +features: [Symbol] +---*/ + +var o = {}; + +o.length = Symbol(1); + +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + [].find.call(o, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-this-length.js b/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-this-length.js new file mode 100644 index 0000000000..0063384230 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-this-length.js @@ -0,0 +1,40 @@ +// 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-array.prototype.find +description: > + Return abrupt from ToLength(Get(O, "length")). +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let len be ToLength(Get(O, "length")). + 4. ReturnIfAbrupt(len). +---*/ + +var o1 = {}; + +Object.defineProperty(o1, 'length', { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + [].find.call(o1); +}); + +var o2 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; +assert.throws(Test262Error, function() { + [].find.call(o2); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-this.js new file mode 100644 index 0000000000..4be965cd8f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/return-abrupt-from-this.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-array.prototype.find +description: > + Return abrupt from ToObject(this value). +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + Array.prototype.find.call(undefined, function() {}); +}); + +assert.throws(TypeError, function() { + Array.prototype.find.call(null, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/return-found-value-predicate-result-is-true.js b/js/src/tests/test262/built-ins/Array/prototype/find/return-found-value-predicate-result-is-true.js new file mode 100644 index 0000000000..bde5b7c13c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/return-found-value-predicate-result-is-true.js @@ -0,0 +1,65 @@ +// 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-array.prototype.find +description: > + Return found value if predicate return a boolean true value. +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + e. ReturnIfAbrupt(testResult). + f. If testResult is true, return kValue. + ... +features: [Symbol] +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; + +var result = arr.find(function(val) { + called++; + return true; +}); + +assert.sameValue(result, 'Shoes'); +assert.sameValue(called, 1, 'predicate was called once'); + +called = 0; +result = arr.find(function(val) { + called++; + return val === 'Bike'; +}); + +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, 'Bike'); + +result = arr.find(function(val) { + return 'string'; +}); +assert.sameValue(result, 'Shoes', 'coerced string'); + +result = arr.find(function(val) { + return {}; +}); +assert.sameValue(result, 'Shoes', 'coerced object'); + +result = arr.find(function(val) { + return Symbol(''); +}); +assert.sameValue(result, 'Shoes', 'coerced Symbol'); + +result = arr.find(function(val) { + return 1; +}); +assert.sameValue(result, 'Shoes', 'coerced number'); + +result = arr.find(function(val) { + return -1; +}); +assert.sameValue(result, 'Shoes', 'coerced negative number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/return-undefined-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/Array/prototype/find/return-undefined-if-predicate-returns-false-value.js new file mode 100644 index 0000000000..51a8d9aa20 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/return-undefined-if-predicate-returns-false-value.js @@ -0,0 +1,55 @@ +// 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-array.prototype.find +description: > + Return undefined if predicate always returns a boolean false value. +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + ... + 9. Return undefined. +features: [Symbol] +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; + +var result = arr.find(function(val) { + called++; + return false; +}); + +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, undefined); + +result = arr.find(function(val) { + return ''; +}); +assert.sameValue(result, undefined, 'coerced string'); + +result = arr.find(function(val) { + return undefined; +}); +assert.sameValue(result, undefined, 'coerced undefined'); + +result = arr.find(function(val) { + return null; +}); +assert.sameValue(result, undefined, 'coerced null'); + +result = arr.find(function(val) { + return 0; +}); +assert.sameValue(result, undefined, 'coerced 0'); + +result = arr.find(function(val) { + return NaN; +}); +assert.sameValue(result, undefined, 'coerced NaN'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/shell.js b/js/src/tests/test262/built-ins/Array/prototype/find/shell.js new file mode 100644 index 0000000000..05fecd6ef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/find/shell.js @@ -0,0 +1,161 @@ +// GENERATED, DO NOT EDIT +// file: testTypedArray.js +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - floatArrayConstructors + - nonClampedIntArrayConstructors + - intArrayConstructors + - typedArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - nonAtomicsFriendlyTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +var floatArrayConstructors = [ + Float64Array, + Float32Array +]; + +var nonClampedIntArrayConstructors = [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array +]; + +var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]); + +// Float16Array is a newer feature +// adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it +if (typeof Float16Array !== 'undefined') { + floatArrayConstructors.push(Float16Array); +} + +/** + * Array containing every non-bigint typed array constructor. + */ + +var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]); +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} + +/** + * Checks if the given argument is one of the float-based TypedArray constructors. + * + * @param {constructor} ctor - the value to check + * @returns {boolean} + */ +function isFloatTypedArrayConstructor(arg) { + return floatArrayConstructors.indexOf(arg) !== -1; +} + +/** + * Determines the precision of the given float-based TypedArray constructor. + * + * @param {constructor} ctor - the value to check + * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively. + */ +function floatTypedArrayConstructorPrecision(FA) { + if (typeof Float16Array !== "undefined" && FA === Float16Array) { + return "half"; + } else if (FA === Float32Array) { + return "single"; + } else if (FA === Float64Array) { + return "double"; + } else { + throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray"); + } +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/array-altered-during-loop.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/array-altered-during-loop.js new file mode 100644 index 0000000000..0a51a82754 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/array-altered-during-loop.js @@ -0,0 +1,49 @@ +// 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-array.prototype.findindex +description: > + The range of elements processed is set before the first call to `predicate`. +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 6. If thisArg was supplied, let T be thisArg; else let T be undefined. + 7. Let k be 0. + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + ... +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var results = []; + +arr.findIndex(function(kValue) { + if (results.length === 0) { + arr.splice(1, 1); + } + results.push(kValue); +}); + +assert.sameValue(results.length, 3, 'predicate called three times'); +assert.sameValue(results[0], 'Shoes'); +assert.sameValue(results[1], 'Bike'); +assert.sameValue(results[2], undefined); + +results = []; +arr = ['Skateboard', 'Barefoot']; +arr.findIndex(function(kValue) { + if (results.length === 0) { + arr.push('Motorcycle'); + arr[1] = 'Magic Carpet'; + } + + results.push(kValue); +}); + +assert.sameValue(results.length, 2, 'predicate called twice'); +assert.sameValue(results[0], 'Skateboard'); +assert.sameValue(results[1], 'Magic Carpet'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/browser.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/call-with-boolean.js new file mode 100644 index 0000000000..fe775ec2f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/call-with-boolean.js @@ -0,0 +1,20 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.findIndex +description: Array.prototype.findIndex applied to boolean primitive +---*/ + +assert.sameValue( + Array.prototype.findIndex.call(true, () => {}), + -1, + 'Array.prototype.findIndex.call(true, () => {}) must return -1' +); +assert.sameValue( + Array.prototype.findIndex.call(false, () => {}), + -1, + 'Array.prototype.findIndex.call(false, () => {}) must return -1' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/callbackfn-resize-arraybuffer.js new file mode 100644 index 0000000000..dbd5c88d63 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/callbackfn-resize-arraybuffer.js @@ -0,0 +1,76 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findindex +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var finalElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.findIndex.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + finalElement = undefined; + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + finalElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)'); + assert.compareArray(indices, [0, 1, 2], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, -1, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.findIndex.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, -1, 'result (grow)'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/length.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/length.js new file mode 100644 index 0000000000..dafeb333b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/length.js @@ -0,0 +1,20 @@ +// 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-array.prototype.findindex +description: Array.prototype.findIndex.length value and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.findIndex.length, 1, + 'The value of `Array.prototype.findIndex.length` is `1`' +); + +verifyNotEnumerable(Array.prototype.findIndex, 'length'); +verifyNotWritable(Array.prototype.findIndex, 'length'); +verifyConfigurable(Array.prototype.findIndex, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/name.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/name.js new file mode 100644 index 0000000000..ad6b6d5a28 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/name.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-array.prototype.findindex +description: > + Array.prototype.findIndex.name value and descriptor. +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.findIndex.name, 'findIndex', + 'The value of `Array.prototype.findIndex.name` is `"findIndex"`' +); + +verifyNotEnumerable(Array.prototype.findIndex, 'name'); +verifyNotWritable(Array.prototype.findIndex, 'name'); +verifyConfigurable(Array.prototype.findIndex, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/not-a-constructor.js new file mode 100644 index 0000000000..ce4d52002d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/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: > + Array.prototype.findIndex 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.findIndex), + false, + 'isConstructor(Array.prototype.findIndex) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.findIndex(() => {}); +}, '`new Array.prototype.findIndex(() => {})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-call-parameters.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-call-parameters.js new file mode 100644 index 0000000000..cb5505f555 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-call-parameters.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-array.prototype.findindex +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 6. If thisArg was supplied, let T be thisArg; else let T be undefined. + 7. Let k be 0. + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + ... +---*/ + +var arr = ['Mike', 'Rick', 'Leo']; + +var results = []; + +arr.findIndex(function(kValue, k, O) { + results.push(arguments); +}); + +assert.sameValue(results.length, 3); + +var result = results[0]; +assert.sameValue(result[0], 'Mike'); +assert.sameValue(result[1], 0); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); + +result = results[1]; +assert.sameValue(result[0], 'Rick'); +assert.sameValue(result[1], 1); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); + +result = results[2]; +assert.sameValue(result[0], 'Leo'); +assert.sameValue(result[1], 2); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-call-this-non-strict.js new file mode 100644 index 0000000000..9399052631 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-call-this-non-strict.js @@ -0,0 +1,34 @@ +// 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-array.prototype.findindex +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + e. ReturnIfAbrupt(testResult). + ... +flags: [noStrict] +---*/ + +var result; + +[1].find(function(kValue, k, O) { + result = this; +}); + +assert.sameValue(result, this); + +var o = {}; +[1].find(function() { + result = this; +}, o); + +assert.sameValue(result, o); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-call-this-strict-strict.js new file mode 100644 index 0000000000..5d1029f8da --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-call-this-strict-strict.js @@ -0,0 +1,35 @@ +'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-array.prototype.findindex +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + e. ReturnIfAbrupt(testResult). + ... +flags: [onlyStrict] +---*/ + +var result; + +[1].find(function(kValue, k, O) { + result = this; +}); + +assert.sameValue(result, undefined); + +var o = {}; +[1].find(function() { + result = this; +}, o); + +assert.sameValue(result, o); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-called-for-each-array-property.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-called-for-each-array-property.js new file mode 100644 index 0000000000..b343af598d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-called-for-each-array-property.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-array.prototype.findindex +description: > + Predicate is called for each array property. +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 6. If thisArg was supplied, let T be thisArg; else let T be undefined. + 7. Let k be 0. + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + ... +---*/ + +var arr = [undefined, , , 'foo']; +var called = 0; + +arr.findIndex(function() { + called++; +}); + +assert.sameValue(called, 4); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-is-not-callable-throws.js new file mode 100644 index 0000000000..f985fa0aee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-is-not-callable-throws.js @@ -0,0 +1,51 @@ +// 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-array.prototype.findindex +description: > + Throws a TypeError exception if predicate is not callable. +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 5. If IsCallable(predicate) is false, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + [].findIndex({}); +}); + +assert.throws(TypeError, function() { + [].findIndex(null); +}); + +assert.throws(TypeError, function() { + [].findIndex(undefined); +}); + +assert.throws(TypeError, function() { + [].findIndex(true); +}); + +assert.throws(TypeError, function() { + [].findIndex(1); +}); + +assert.throws(TypeError, function() { + [].findIndex(''); +}); + +assert.throws(TypeError, function() { + [].findIndex(1); +}); + +assert.throws(TypeError, function() { + [].findIndex([]); +}); + +assert.throws(TypeError, function() { + [].findIndex(/./); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-not-called-on-empty-array.js new file mode 100644 index 0000000000..c3bd339896 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/predicate-not-called-on-empty-array.js @@ -0,0 +1,37 @@ +// 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-array.prototype.findindex +description: > + Predicate is only called if this.length is > 0. +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 7. Let k be 0. + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + ... + 9. Return -1. +---*/ + +var called = false; + +var predicate = function() { + called = true; + return true; +}; + +var result = [].findIndex(predicate); + +assert.sameValue( + called, false, + '[].findIndex(predicate) does not call predicate' +); +assert.sameValue( + result, -1, + '[].findIndex(predicate) returned undefined' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/prop-desc.js new file mode 100644 index 0000000000..c894ccf968 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/prop-desc.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-array.prototype.findindex +description: Property type and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Array.prototype.findIndex, + 'function', + '`typeof Array.prototype.findIndex` is `function`' +); + +verifyNotEnumerable(Array.prototype, 'findIndex'); +verifyWritable(Array.prototype, 'findIndex'); +verifyConfigurable(Array.prototype, 'findIndex'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-predicate-call.js new file mode 100644 index 0000000000..41e0b25bd5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-predicate-call.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-array.prototype.findindex +description: > + Return abrupt from predicate call. +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 7. Let k be 0. + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + e. ReturnIfAbrupt(testResult). + ... +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + [1].findIndex(predicate); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-property.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-property.js new file mode 100644 index 0000000000..641f324b13 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-property.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-array.prototype.findindex +description: > + Returns abrupt from getting property value from `this`. +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 7. Let k be 0. + 8. Repeat, while k < len + a. Let Pk be ToString(k). + b. Let kValue be Get(O, Pk). + c. ReturnIfAbrupt(kValue). + ... +---*/ + +var o = { + length: 1 +}; + +Object.defineProperty(o, 0, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + [].findIndex.call(o, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-this-length-as-symbol.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-this-length-as-symbol.js new file mode 100644 index 0000000000..3884770242 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-this-length-as-symbol.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-array.prototype.findindex +description: > + Return abrupt from ToLength(Get(O, "length")) where length is a Symbol. +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let len be ToLength(Get(O, "length")). + 4. ReturnIfAbrupt(len). + ... +features: [Symbol] +---*/ + +var o = {}; + +o.length = Symbol(1); + +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + [].findIndex.call(o, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-this-length.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-this-length.js new file mode 100644 index 0000000000..152e05756b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-this-length.js @@ -0,0 +1,40 @@ +// 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-array.prototype.findindex +description: > + Return abrupt from ToLength(Get(O, "length")). +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let len be ToLength(Get(O, "length")). + 4. ReturnIfAbrupt(len). +---*/ + +var o1 = {}; + +Object.defineProperty(o1, 'length', { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +// predicate fn is given to avoid false positives +assert.throws(Test262Error, function() { + [].findIndex.call(o1, function() {}); +}); + +var o2 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; +assert.throws(Test262Error, function() { + [].findIndex.call(o2, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-this.js new file mode 100644 index 0000000000..88e0ca0b38 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-abrupt-from-this.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-array.prototype.findindex +description: > + Return abrupt from ToObject(this value). +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + Array.prototype.findIndex.call(undefined, function() {}); +}); + +assert.throws(TypeError, function() { + Array.prototype.findIndex.call(null, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-index-predicate-result-is-true.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-index-predicate-result-is-true.js new file mode 100644 index 0000000000..a327f75137 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-index-predicate-result-is-true.js @@ -0,0 +1,65 @@ +// 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-array.prototype.findindex +description: > + Return index if predicate return a boolean true value. +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + e. ReturnIfAbrupt(testResult). + f. If testResult is true, return k. + ... +features: [Symbol] +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; + +var result = arr.findIndex(function(val) { + called++; + return true; +}); + +assert.sameValue(result, 0); +assert.sameValue(called, 1, 'predicate was called once'); + +called = 0; +result = arr.findIndex(function(val) { + called++; + return val === 'Bike'; +}); + +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, 2); + +result = arr.findIndex(function(val) { + return 'string'; +}); +assert.sameValue(result, 0, 'coerced string'); + +result = arr.findIndex(function(val) { + return {}; +}); +assert.sameValue(result, 0, 'coerced object'); + +result = arr.findIndex(function(val) { + return Symbol(''); +}); +assert.sameValue(result, 0, 'coerced Symbol'); + +result = arr.findIndex(function(val) { + return 1; +}); +assert.sameValue(result, 0, 'coerced number'); + +result = arr.findIndex(function(val) { + return -1; +}); +assert.sameValue(result, 0, 'coerced negative number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js new file mode 100644 index 0000000000..419ec5ccce --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js @@ -0,0 +1,55 @@ +// 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-array.prototype.findindex +description: > + Return -1 if predicate always returns a boolean false value. +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 8. Repeat, while k < len + ... + d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)). + ... + 9. Return -1. +features: [Symbol] +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; + +var result = arr.findIndex(function(val) { + called++; + return false; +}); + +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, -1); + +result = arr.findIndex(function(val) { + return ''; +}); +assert.sameValue(result, -1, 'coerced string'); + +result = arr.findIndex(function(val) { + return undefined; +}); +assert.sameValue(result, -1, 'coerced undefined'); + +result = arr.findIndex(function(val) { + return null; +}); +assert.sameValue(result, -1, 'coerced null'); + +result = arr.findIndex(function(val) { + return 0; +}); +assert.sameValue(result, -1, 'coerced 0'); + +result = arr.findIndex(function(val) { + return NaN; +}); +assert.sameValue(result, -1, 'coerced NaN'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/shell.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/shell.js new file mode 100644 index 0000000000..05fecd6ef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/shell.js @@ -0,0 +1,161 @@ +// GENERATED, DO NOT EDIT +// file: testTypedArray.js +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - floatArrayConstructors + - nonClampedIntArrayConstructors + - intArrayConstructors + - typedArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - nonAtomicsFriendlyTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +var floatArrayConstructors = [ + Float64Array, + Float32Array +]; + +var nonClampedIntArrayConstructors = [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array +]; + +var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]); + +// Float16Array is a newer feature +// adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it +if (typeof Float16Array !== 'undefined') { + floatArrayConstructors.push(Float16Array); +} + +/** + * Array containing every non-bigint typed array constructor. + */ + +var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]); +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} + +/** + * Checks if the given argument is one of the float-based TypedArray constructors. + * + * @param {constructor} ctor - the value to check + * @returns {boolean} + */ +function isFloatTypedArrayConstructor(arg) { + return floatArrayConstructors.indexOf(arg) !== -1; +} + +/** + * Determines the precision of the given float-based TypedArray constructor. + * + * @param {constructor} ctor - the value to check + * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively. + */ +function floatTypedArrayConstructorPrecision(FA) { + if (typeof Float16Array !== "undefined" && FA === Float16Array) { + return "half"; + } else if (FA === Float32Array) { + return "single"; + } else if (FA === Float64Array) { + return "double"; + } else { + throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray"); + } +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/array-altered-during-loop.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/array-altered-during-loop.js new file mode 100644 index 0000000000..99746b971a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/array-altered-during-loop.js @@ -0,0 +1,49 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + The range of elements processed is set before the first call to `predicate`. +info: | + Array.prototype.findLast ( predicate[ , thisArg ] ) + + ... + 4. Let k be len - 1. + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +features: [array-find-from-last] +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var results = []; + +arr.findLast(function(kValue) { + if (results.length === 0) { + arr.splice(1, 1); + } + results.push(kValue); +}); + +assert.sameValue(results.length, 3, 'predicate called three times'); +assert.sameValue(results[0], 'Bike'); +assert.sameValue(results[1], 'Bike'); +assert.sameValue(results[2], 'Shoes'); + +results = []; +arr = ['Skateboard', 'Barefoot']; +arr.findLast(function(kValue) { + if (results.length === 0) { + arr.push('Motorcycle'); + arr[0] = 'Magic Carpet'; + } + + results.push(kValue); +}); + +assert.sameValue(results.length, 2, 'predicate called twice'); +assert.sameValue(results[0], 'Barefoot'); +assert.sameValue(results[1], 'Magic Carpet'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/browser.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/call-with-boolean.js new file mode 100644 index 0000000000..7f7a75ac7c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/call-with-boolean.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.findlast +description: Array.prototype.findLast applied to boolean primitive. +features: [array-find-from-last] +---*/ + +assert.sameValue( + Array.prototype.findLast.call(true, () => {}), + undefined, + 'Array.prototype.findLast.call(true, () => {}) must return undefined' +); +assert.sameValue( + Array.prototype.findLast.call(false, () => {}), + undefined, + 'Array.prototype.findLast.call(false, () => {}) must return undefined' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/callbackfn-resize-arraybuffer.js new file mode 100644 index 0000000000..1f029bde80 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/callbackfn-resize-arraybuffer.js @@ -0,0 +1,76 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var secondElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.findLast.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(BPE); + secondElement = undefined; + expectedElements = [0]; + expectedIndices = [0]; + expectedArrays = [sample]; + } catch (_) { + secondElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [2, 1, 0]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, [0, secondElement, 0], 'elements (shrink)'); + assert.compareArray(indices, [2, 1, 0], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, undefined, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.findLast.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, undefined, 'result (grow)'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/length.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/length.js new file mode 100644 index 0000000000..772d631d06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/length.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: Array.prototype.findLast.length value and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [array-find-from-last] +---*/ + +assert.sameValue( + Array.prototype.findLast.length, 1, + 'The value of `Array.prototype.findLast.length` is `1`' +); + +verifyProperty(Array.prototype.findLast, "length", { + enumerable: false, + writable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/maximum-index.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/maximum-index.js new file mode 100644 index 0000000000..32259c3a62 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/maximum-index.js @@ -0,0 +1,38 @@ +// Copyright (C) 2023 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Support the maximum valid integer index. +info: | + Array.prototype.findLast ( predicate [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + + LengthOfArrayLike ( obj ) + + 1. Return ℝ(? ToLength(? Get(obj, "length"))). + + ToLength ( argument ) + + 1. Let len be ? ToIntegerOrInfinity(argument). + 2. If len ≤ 0, return +0𝔽. + 3. Return 𝔽(min(len, 2**53 - 1)). +features: [array-find-from-last] +---*/ + +var tooBigLength = Number.MAX_VALUE; +var maxExpectedIndex = 9007199254740990; +var arrayLike = { length: tooBigLength }; +var calledWithIndex = []; + +Array.prototype.findLast.call(arrayLike, function(_value, index) { + calledWithIndex.push(index); + return true; +}); + +assert.sameValue(calledWithIndex.length, 1, 'predicate invoked once'); +assert.sameValue(calledWithIndex[0], maxExpectedIndex); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/name.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/name.js new file mode 100644 index 0000000000..4188b3d7f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/name.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Array.prototype.findLast.name value and descriptor. +info: | + Array.prototype.findLast ( predicate [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [array-find-from-last] +---*/ + +assert.sameValue( + Array.prototype.findLast.name, 'findLast', + 'The value of `Array.prototype.findLast.name` is `"findLast"`' +); + +verifyProperty(Array.prototype.findLast, "name", { + enumerable: false, + writable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/not-a-constructor.js new file mode 100644 index 0000000000..9b2316f054 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.findLast 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, arrow-function, array-find-from-last] +---*/ + +assert.sameValue(isConstructor(Array.prototype.findLast), false, 'isConstructor(Array.prototype.findLast) must return false'); + +assert.throws(TypeError, () => { + new Array.prototype.findLast(() => {}); +}, '`new Array.prototype.findLast(() => {})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-call-parameters.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-call-parameters.js new file mode 100644 index 0000000000..7165a68110 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-call-parameters.js @@ -0,0 +1,48 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + Array.prototype.findLast ( predicate[ , thisArg ] ) + + ... + 4. Let k be len - 1. + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + d. If testResult is true, return kValue. + ... +features: [array-find-from-last] +---*/ + +var arr = ['Mike', 'Rick', 'Leo']; + +var results = []; + +arr.findLast(function() { + results.push(arguments); +}); + +assert.sameValue(results.length, 3); + +var result = results[0]; +assert.sameValue(result[0], 'Leo'); +assert.sameValue(result[1], 2); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); + +result = results[1]; +assert.sameValue(result[0], 'Rick'); +assert.sameValue(result[1], 1); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); + +result = results[2]; +assert.sameValue(result[0], 'Mike'); +assert.sameValue(result[1], 0); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-call-this-non-strict.js new file mode 100644 index 0000000000..6b0fa08b5c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-call-this-non-strict.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + Array.prototype.findLast ( predicate[ , thisArg ] ) + + ... + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + d. If testResult is true, return kValue. + ... +flags: [noStrict] +features: [array-find-from-last] +---*/ + +var result; + +[1].findLast(function() { + result = this; +}); + +assert.sameValue(result, this); + +var o = {}; +[1].findLast(function() { + result = this; +}, o); + +assert.sameValue(result, o); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-call-this-strict-strict.js new file mode 100644 index 0000000000..53f118c7d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-call-this-strict-strict.js @@ -0,0 +1,36 @@ +'use strict'; +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + Array.prototype.findLast ( predicate[ , thisArg ] ) + + ... + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + d. If testResult is true, return kValue. + ... +flags: [onlyStrict] +features: [array-find-from-last] +---*/ + +var result; + +[1].findLast(function() { + result = this; +}); + +assert.sameValue(result, undefined); + +var o = {}; +[1].findLast(function() { + result = this; +}, o); + +assert.sameValue(result, o); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-called-for-each-array-property.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-called-for-each-array-property.js new file mode 100644 index 0000000000..08233f5110 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-called-for-each-array-property.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Predicate is called for each array property. +info: | + Array.prototype.findLast ( predicate[ , thisArg ] ) + + ... + 4. Let k be len - 1. + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +features: [array-find-from-last] +---*/ + +var arr = [undefined, , , 'foo']; +var called = 0; + +arr.findLast(function() { + called++; +}); + +assert.sameValue(called, 4); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-is-not-callable-throws.js new file mode 100644 index 0000000000..fd8e7d0f98 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-is-not-callable-throws.js @@ -0,0 +1,52 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Throws a TypeError exception if predicate is not callable. +info: | + Array.prototype.findLast ( predicate[ , thisArg ] ) + + ... + 3. If IsCallable(predicate) is false, throw a TypeError exception. + ... +features: [array-find-from-last] +---*/ + +assert.throws(TypeError, function() { + [].findLast({}); +}); + +assert.throws(TypeError, function() { + [].findLast(null); +}); + +assert.throws(TypeError, function() { + [].findLast(undefined); +}); + +assert.throws(TypeError, function() { + [].findLast(true); +}); + +assert.throws(TypeError, function() { + [].findLast(1); +}); + +assert.throws(TypeError, function() { + [].findLast(''); +}); + +assert.throws(TypeError, function() { + [].findLast(1); +}); + +assert.throws(TypeError, function() { + [].findLast([]); +}); + +assert.throws(TypeError, function() { + [].findLast(/./); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-not-called-on-empty-array.js new file mode 100644 index 0000000000..c922025e33 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/predicate-not-called-on-empty-array.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Predicate is only called if this.length is > 0. +info: | + Array.prototype.findLast ( predicate[ , thisArg ] ) + + ... + 4. Let k be len - 1. + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... + 6. Return undefined. +features: [array-find-from-last] +---*/ + +var called = false; + +var predicate = function() { + called = true; + return true; +}; + +var result = [].findLast(predicate); + +assert.sameValue(called, false, '[].findLast(predicate) does not call predicate'); +assert.sameValue(result, undefined, '[].findLast(predicate) returned undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/prop-desc.js new file mode 100644 index 0000000000..3f66568608 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/prop-desc.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: Property type and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [array-find-from-last] +---*/ + +assert.sameValue( + typeof Array.prototype.findLast, + 'function', + '`typeof Array.prototype.findLast` is `function`' +); + +verifyProperty(Array.prototype, "findLast", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-predicate-call.js new file mode 100644 index 0000000000..e6d38f74f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-predicate-call.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Return abrupt from predicate call. +info: | + Array.prototype.findLast ( predicate[ , thisArg ] ) + + ... + 4. Let k be len - 1. + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + d. If testResult is true, return kValue. + ... +features: [array-find-from-last] +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + [1].findLast(predicate); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-property.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-property.js new file mode 100644 index 0000000000..0462681378 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-property.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Returns abrupt from getting property value from `this`. +info: | + Array.prototype.findLast ( predicate[ , thisArg ] ) + + ... + 4. Let k be len - 1. + 5. Repeat, while k ≥ 0, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + ... + d. If testResult is true, return kValue. + ... +features: [array-find-from-last] +---*/ + +var o = { + length: 1 +}; + +Object.defineProperty(o, 0, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + [].findLast.call(o, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-this-length-as-symbol.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-this-length-as-symbol.js new file mode 100644 index 0000000000..3c38d59c0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-this-length-as-symbol.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Return abrupt from ToLength(Get(O, "length")) where length is a Symbol. +info: | + Array.prototype.findLast ( predicate[ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + +features: [Symbol, array-find-from-last] +---*/ + +var o = {}; + +o.length = Symbol(1); + +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + [].findLast.call(o, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-this-length.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-this-length.js new file mode 100644 index 0000000000..6c2cd24a37 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-this-length.js @@ -0,0 +1,39 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Return abrupt from ToLength(Get(O, "length")). +info: | + Array.prototype.findLast ( predicate[ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). +features: [array-find-from-last] +---*/ + +var o1 = {}; + +Object.defineProperty(o1, 'length', { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + [].findLast.call(o1); +}); + +var o2 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; +assert.throws(Test262Error, function() { + [].findLast.call(o2); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-this.js new file mode 100644 index 0000000000..a24b873282 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/return-abrupt-from-this.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Return abrupt from ToObject(this value). +info: | + Array.prototype.findLast ( predicate[ , thisArg ] ) + + 1. Let O be ? ToObject(this value). +features: [array-find-from-last] +---*/ + +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + Array.prototype.findLast.call(undefined, function() {}); +}); + +assert.throws(TypeError, function() { + Array.prototype.findLast.call(null, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/return-found-value-predicate-result-is-true.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/return-found-value-predicate-result-is-true.js new file mode 100644 index 0000000000..c9026b01ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/return-found-value-predicate-result-is-true.js @@ -0,0 +1,64 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Return found value if predicate return a boolean true value. +info: | + Array.prototype.findLast ( predicate[ , thisArg ] ) + + ... + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + d. If testResult is true, return kValue. + ... +features: [Symbol, array-find-from-last] +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; + +var result = arr.findLast(function() { + called++; + return true; +}); + +assert.sameValue(result, 'Bike'); +assert.sameValue(called, 1, 'predicate was called once'); + +called = 0; +result = arr.findLast(function(val) { + called++; + return val === 'Shoes'; +}); + +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, 'Shoes'); + +result = arr.findLast(function() { + return 'string'; +}); +assert.sameValue(result, 'Bike', 'coerced string'); + +result = arr.findLast(function() { + return {}; +}); +assert.sameValue(result, 'Bike', 'coerced object'); + +result = arr.findLast(function() { + return Symbol(''); +}); +assert.sameValue(result, 'Bike', 'coerced Symbol'); + +result = arr.findLast(function() { + return 1; +}); +assert.sameValue(result, 'Bike', 'coerced number'); + +result = arr.findLast(function() { + return -1; +}); +assert.sameValue(result, 'Bike', 'coerced negative number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/return-undefined-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/return-undefined-if-predicate-returns-false-value.js new file mode 100644 index 0000000000..6ce25bdaef --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/return-undefined-if-predicate-returns-false-value.js @@ -0,0 +1,55 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlast +description: > + Return undefined if predicate always returns a boolean false value. +info: | + Array.prototype.findLast ( predicate[ , thisArg ] ) + + ... + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... + 6. Return undefined. +features: [Symbol, array-find-from-last] +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; + +var result = arr.findLast(function() { + called++; + return false; +}); + +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, undefined); + +result = arr.findLast(function() { + return ''; +}); +assert.sameValue(result, undefined, 'coerced string'); + +result = arr.findLast(function() { + return undefined; +}); +assert.sameValue(result, undefined, 'coerced undefined'); + +result = arr.findLast(function() { + return null; +}); +assert.sameValue(result, undefined, 'coerced null'); + +result = arr.findLast(function() { + return 0; +}); +assert.sameValue(result, undefined, 'coerced 0'); + +result = arr.findLast(function() { + return NaN; +}); +assert.sameValue(result, undefined, 'coerced NaN'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/shell.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/shell.js new file mode 100644 index 0000000000..05fecd6ef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/shell.js @@ -0,0 +1,161 @@ +// GENERATED, DO NOT EDIT +// file: testTypedArray.js +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - floatArrayConstructors + - nonClampedIntArrayConstructors + - intArrayConstructors + - typedArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - nonAtomicsFriendlyTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +var floatArrayConstructors = [ + Float64Array, + Float32Array +]; + +var nonClampedIntArrayConstructors = [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array +]; + +var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]); + +// Float16Array is a newer feature +// adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it +if (typeof Float16Array !== 'undefined') { + floatArrayConstructors.push(Float16Array); +} + +/** + * Array containing every non-bigint typed array constructor. + */ + +var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]); +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} + +/** + * Checks if the given argument is one of the float-based TypedArray constructors. + * + * @param {constructor} ctor - the value to check + * @returns {boolean} + */ +function isFloatTypedArrayConstructor(arg) { + return floatArrayConstructors.indexOf(arg) !== -1; +} + +/** + * Determines the precision of the given float-based TypedArray constructor. + * + * @param {constructor} ctor - the value to check + * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively. + */ +function floatTypedArrayConstructorPrecision(FA) { + if (typeof Float16Array !== "undefined" && FA === Float16Array) { + return "half"; + } else if (FA === Float32Array) { + return "single"; + } else if (FA === Float64Array) { + return "double"; + } else { + throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray"); + } +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/array-altered-during-loop.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/array-altered-during-loop.js new file mode 100644 index 0000000000..eac5ed5374 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/array-altered-during-loop.js @@ -0,0 +1,49 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + The range of elements processed is set before the first call to `predicate`. +info: | + Array.prototype.findLastIndex ( predicate[ , thisArg ] ) + + ... + 4. Let k be len - 1. + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +features: [array-find-from-last] +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var results = []; + +arr.findLastIndex(function(kValue) { + if (results.length === 0) { + arr.splice(1, 1); + } + results.push(kValue); +}); + +assert.sameValue(results.length, 3, 'predicate called three times'); +assert.sameValue(results[0], 'Bike'); +assert.sameValue(results[1], 'Bike'); +assert.sameValue(results[2], 'Shoes'); + +results = []; +arr = ['Skateboard', 'Barefoot']; +arr.findLastIndex(function(kValue) { + if (results.length === 0) { + arr.push('Motorcycle'); + arr[0] = 'Magic Carpet'; + } + + results.push(kValue); +}); + +assert.sameValue(results.length, 2, 'predicate called twice'); +assert.sameValue(results[0], 'Barefoot'); +assert.sameValue(results[1], 'Magic Carpet'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/browser.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/call-with-boolean.js new file mode 100644 index 0000000000..d9565b5641 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/call-with-boolean.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.findlastindex +description: Array.prototype.findLastIndex applied to boolean primitive. +features: [array-find-from-last] +---*/ + +assert.sameValue( + Array.prototype.findLastIndex.call(true, () => {}), + -1, + 'Array.prototype.findLastIndex.call(true, () => {}) must return -1' +); +assert.sameValue( + Array.prototype.findLastIndex.call(false, () => {}), + -1, + 'Array.prototype.findLastIndex.call(false, () => {}) must return -1' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/callbackfn-resize-arraybuffer.js new file mode 100644 index 0000000000..3d90fa7f17 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/callbackfn-resize-arraybuffer.js @@ -0,0 +1,76 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var secondElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.findLastIndex.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(BPE); + secondElement = undefined; + expectedElements = [0]; + expectedIndices = [0]; + expectedArrays = [sample]; + } catch (_) { + secondElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [2, 1, 0]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, [0, secondElement, 0], 'elements (shrink)'); + assert.compareArray(indices, [2, 1, 0], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, -1, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.findLastIndex.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, -1, 'result (grow)'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/length.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/length.js new file mode 100644 index 0000000000..f5f3f78354 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/length.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: Array.prototype.findLastIndex.length value and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [array-find-from-last] +---*/ + +assert.sameValue( + Array.prototype.findLastIndex.length, 1, + 'The value of `Array.prototype.findLastIndex.length` is `1`' +); + +verifyProperty(Array.prototype.findLastIndex, "length", { + enumerable: false, + writable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/maximum-index.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/maximum-index.js new file mode 100644 index 0000000000..27489250fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/maximum-index.js @@ -0,0 +1,38 @@ +// Copyright (C) 2023 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Support the maximum valid integer index. +info: | + Array.prototype.findLastIndex ( predicate [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + + LengthOfArrayLike ( obj ) + + 1. Return ℝ(? ToLength(? Get(obj, "length"))). + + ToLength ( argument ) + + 1. Let len be ? ToIntegerOrInfinity(argument). + 2. If len ≤ 0, return +0𝔽. + 3. Return 𝔽(min(len, 2**53 - 1)). +features: [array-find-from-last] +---*/ + +var tooBigLength = Number.MAX_VALUE; +var maxExpectedIndex = 9007199254740990; +var arrayLike = { length: tooBigLength }; +var calledWithIndex = []; + +Array.prototype.findLastIndex.call(arrayLike, function(_value, index) { + calledWithIndex.push(index); + return true; +}); + +assert.sameValue(calledWithIndex.length, 1, 'predicate invoked once'); +assert.sameValue(calledWithIndex[0], maxExpectedIndex); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/name.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/name.js new file mode 100644 index 0000000000..9307eb0374 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/name.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Array.prototype.findLastIndex.name value and descriptor. +info: | + Array.prototype.findLastIndex ( predicate [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [array-find-from-last] +---*/ + +assert.sameValue( + Array.prototype.findLastIndex.name, 'findLastIndex', + 'The value of `Array.prototype.findLastIndex.name` is `"findLastIndex"`' +); + +verifyProperty(Array.prototype.findLastIndex, "name", { + enumerable: false, + writable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/not-a-constructor.js new file mode 100644 index 0000000000..8c6000eea2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.findLastIndex 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, arrow-function, array-find-from-last] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.findLastIndex), + false, + 'isConstructor(Array.prototype.findLastIndex) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.findLastIndex(() => {}); +}, '`new Array.prototype.findLastIndex(() => {})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-call-parameters.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-call-parameters.js new file mode 100644 index 0000000000..02bd2f9182 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-call-parameters.js @@ -0,0 +1,47 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + Array.prototype.findLastIndex ( predicate[ , thisArg ] ) + + ... + 4. Let k be len - 1. + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +features: [array-find-from-last] +---*/ + +var arr = ['Mike', 'Rick', 'Leo']; + +var results = []; + +arr.findLastIndex(function() { + results.push(arguments); +}); + +assert.sameValue(results.length, 3); + +var result = results[0]; +assert.sameValue(result[0], 'Leo'); +assert.sameValue(result[1], 2); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); + +result = results[1]; +assert.sameValue(result[0], 'Rick'); +assert.sameValue(result[1], 1); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); + +result = results[2]; +assert.sameValue(result[0], 'Mike'); +assert.sameValue(result[1], 0); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-call-this-non-strict.js new file mode 100644 index 0000000000..0179b05f3b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-call-this-non-strict.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + Array.prototype.findLastIndex ( predicate[ , thisArg ] ) + + ... + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + d. If testResult is true, return 𝔽(k). + ... +flags: [noStrict] +features: [array-find-from-last] +---*/ + +var result; + +[1].findLastIndex(function() { + result = this; +}); + +assert.sameValue(result, this); + +var o = {}; +[1].findLastIndex(function() { + result = this; +}, o); + +assert.sameValue(result, o); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-call-this-strict-strict.js new file mode 100644 index 0000000000..3de65dfc2d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-call-this-strict-strict.js @@ -0,0 +1,36 @@ +'use strict'; +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + Array.prototype.findLastIndex ( predicate[ , thisArg ] ) + + ... + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + d. If testResult is true, return 𝔽(k). + ... +flags: [onlyStrict] +features: [array-find-from-last] +---*/ + +var result; + +[1].findLastIndex(function() { + result = this; +}); + +assert.sameValue(result, undefined); + +var o = {}; +[1].findLastIndex(function() { + result = this; +}, o); + +assert.sameValue(result, o); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-called-for-each-array-property.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-called-for-each-array-property.js new file mode 100644 index 0000000000..487719742b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-called-for-each-array-property.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Predicate is called for each array property. +info: | + Array.prototype.findLastIndex ( predicate[ , thisArg ] ) + + ... + 4. Let k be len - 1. + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +features: [array-find-from-last] +---*/ + +var arr = [undefined, , , 'foo']; +var called = 0; + +arr.findLastIndex(function() { + called++; +}); + +assert.sameValue(called, 4); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-is-not-callable-throws.js new file mode 100644 index 0000000000..f45b659578 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-is-not-callable-throws.js @@ -0,0 +1,52 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Throws a TypeError exception if predicate is not callable. +info: | + Array.prototype.findLastIndex ( predicate[ , thisArg ] ) + + ... + 3. If IsCallable(predicate) is false, throw a TypeError exception. + ... +features: [array-find-from-last] +---*/ + +assert.throws(TypeError, function() { + [].findLastIndex({}); +}); + +assert.throws(TypeError, function() { + [].findLastIndex(null); +}); + +assert.throws(TypeError, function() { + [].findLastIndex(undefined); +}); + +assert.throws(TypeError, function() { + [].findLastIndex(true); +}); + +assert.throws(TypeError, function() { + [].findLastIndex(1); +}); + +assert.throws(TypeError, function() { + [].findLastIndex(''); +}); + +assert.throws(TypeError, function() { + [].findLastIndex(1); +}); + +assert.throws(TypeError, function() { + [].findLastIndex([]); +}); + +assert.throws(TypeError, function() { + [].findLastIndex(/./); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-not-called-on-empty-array.js new file mode 100644 index 0000000000..a68e8420b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/predicate-not-called-on-empty-array.js @@ -0,0 +1,37 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Predicate is only called if this.length is > 0. +info: | + Array.prototype.findLastIndex ( predicate[ , thisArg ] ) + + ... + 4. Let k be len - 1. + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + 6. Return -1. +features: [array-find-from-last] +---*/ + +var called = false; + +var predicate = function() { + called = true; + return true; +}; + +var result = [].findLastIndex(predicate); + +assert.sameValue( + called, false, + '[].findLastIndex(predicate) does not call predicate' +); +assert.sameValue( + result, -1, + '[].findLastIndex(predicate) returned undefined' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/prop-desc.js new file mode 100644 index 0000000000..6959d25183 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/prop-desc.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: Property type and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [array-find-from-last] +---*/ + +assert.sameValue( + typeof Array.prototype.findLastIndex, + 'function', + '`typeof Array.prototype.findLastIndex` is `function`' +); + +verifyProperty(Array.prototype, "findLastIndex", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-predicate-call.js new file mode 100644 index 0000000000..295cd21b8a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-predicate-call.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Return abrupt from predicate call. +info: | + Array.prototype.findLastIndex ( predicate[ , thisArg ] ) + + ... + 4. Let k be len - 1. + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + d. If testResult is true, return 𝔽(k). + ... +features: [array-find-from-last] +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + [1].findLastIndex(predicate); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-property.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-property.js new file mode 100644 index 0000000000..e92c86e212 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-property.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Returns abrupt from getting property value from `this`. +info: | + Array.prototype.findLastIndex ( predicate[ , thisArg ] ) + + ... + 4. Let k be len - 1. + 5. Repeat, while k ≥ 0, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + ... +features: [array-find-from-last] +---*/ + +var o = { + length: 1 +}; + +Object.defineProperty(o, 0, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + [].findLastIndex.call(o, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-this-length-as-symbol.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-this-length-as-symbol.js new file mode 100644 index 0000000000..f3b1275072 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-this-length-as-symbol.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Return abrupt from ToLength(Get(O, "length")) where length is a Symbol. +info: | + Array.prototype.findLastIndex ( predicate[ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [Symbol, array-find-from-last] +---*/ + +var o = {}; + +o.length = Symbol(1); + +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + [].findLastIndex.call(o, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-this-length.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-this-length.js new file mode 100644 index 0000000000..d1e98dc134 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-this-length.js @@ -0,0 +1,39 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Return abrupt from ToLength(Get(O, "length")). +info: | + Array.prototype.findLastIndex ( predicate[ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). +features: [array-find-from-last] +---*/ + +var o1 = {}; + +Object.defineProperty(o1, 'length', { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +// predicate fn is given to avoid false positives +assert.throws(Test262Error, function() { + [].findLastIndex.call(o1, function() {}); +}); + +var o2 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; +assert.throws(Test262Error, function() { + [].findLastIndex.call(o2, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-this.js new file mode 100644 index 0000000000..6d756c040f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-abrupt-from-this.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Return abrupt from ToObject(this value). +info: | + Array.prototype.findLastIndex ( predicate[ , thisArg ] ) + + 1. Let O be ? ToObject(this value). +features: [array-find-from-last] +---*/ + +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + Array.prototype.findLastIndex.call(undefined, function() {}); +}); + +assert.throws(TypeError, function() { + Array.prototype.findLastIndex.call(null, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-index-predicate-result-is-true.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-index-predicate-result-is-true.js new file mode 100644 index 0000000000..9df93fb9e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-index-predicate-result-is-true.js @@ -0,0 +1,64 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Return index if predicate return a boolean true value. +info: | + Array.prototype.findLastIndex ( predicate[ , thisArg ] ) + + ... + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + d. If testResult is true, return 𝔽(k). + ... +features: [Symbol, array-find-from-last] +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; + +var result = arr.findLastIndex(function() { + called++; + return true; +}); + +assert.sameValue(result, 2); +assert.sameValue(called, 1, 'predicate was called once'); + +called = 0; +result = arr.findLastIndex(function(val) { + called++; + return val === 'Shoes'; +}); + +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, 0); + +result = arr.findLastIndex(function() { + return 'string'; +}); +assert.sameValue(result, 2, 'coerced string'); + +result = arr.findLastIndex(function() { + return {}; +}); +assert.sameValue(result, 2, 'coerced object'); + +result = arr.findLastIndex(function() { + return Symbol(''); +}); +assert.sameValue(result, 2, 'coerced Symbol'); + +result = arr.findLastIndex(function() { + return 1; +}); +assert.sameValue(result, 2, 'coerced number'); + +result = arr.findLastIndex(function() { + return -1; +}); +assert.sameValue(result, 2, 'coerced negative number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js new file mode 100644 index 0000000000..594091f81d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js @@ -0,0 +1,55 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.findlastindex +description: > + Return -1 if predicate always returns a boolean false value. +info: | + Array.prototype.findLastIndex ( predicate[ , thisArg ] ) + + ... + 5. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... + 6. Return -1. +features: [Symbol, array-find-from-last] +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; + +var result = arr.findLastIndex(function() { + called++; + return false; +}); + +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, -1); + +result = arr.findLastIndex(function() { + return ''; +}); +assert.sameValue(result, -1, 'coerced string'); + +result = arr.findLastIndex(function() { + return undefined; +}); +assert.sameValue(result, -1, 'coerced undefined'); + +result = arr.findLastIndex(function() { + return null; +}); +assert.sameValue(result, -1, 'coerced null'); + +result = arr.findLastIndex(function() { + return 0; +}); +assert.sameValue(result, -1, 'coerced 0'); + +result = arr.findLastIndex(function() { + return NaN; +}); +assert.sameValue(result, -1, 'coerced NaN'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/shell.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/shell.js new file mode 100644 index 0000000000..05fecd6ef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/shell.js @@ -0,0 +1,161 @@ +// GENERATED, DO NOT EDIT +// file: testTypedArray.js +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - floatArrayConstructors + - nonClampedIntArrayConstructors + - intArrayConstructors + - typedArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - nonAtomicsFriendlyTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +var floatArrayConstructors = [ + Float64Array, + Float32Array +]; + +var nonClampedIntArrayConstructors = [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array +]; + +var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]); + +// Float16Array is a newer feature +// adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it +if (typeof Float16Array !== 'undefined') { + floatArrayConstructors.push(Float16Array); +} + +/** + * Array containing every non-bigint typed array constructor. + */ + +var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]); +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} + +/** + * Checks if the given argument is one of the float-based TypedArray constructors. + * + * @param {constructor} ctor - the value to check + * @returns {boolean} + */ +function isFloatTypedArrayConstructor(arg) { + return floatArrayConstructors.indexOf(arg) !== -1; +} + +/** + * Determines the precision of the given float-based TypedArray constructor. + * + * @param {constructor} ctor - the value to check + * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively. + */ +function floatTypedArrayConstructorPrecision(FA) { + if (typeof Float16Array !== "undefined" && FA === Float16Array) { + return "half"; + } else if (FA === Float32Array) { + return "single"; + } else if (FA === Float64Array) { + return "double"; + } else { + throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray"); + } +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/array-like-objects.js b/js/src/tests/test262/built-ins/Array/prototype/flat/array-like-objects.js new file mode 100644 index 0000000000..e89bbd22b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/array-like-objects.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: > + array-like objects can be flattened +includes: [compareArray.js] +features: [Array.prototype.flat] +---*/ + +function getArgumentsObject() { + return arguments; +} + +var a = getArgumentsObject([1], [2]); +var actual = [].flat.call(a); +assert.compareArray(actual, [1, 2], 'The value of actual is expected to be [1, 2]'); + +a = { + length: 1, + 0: [1], +}; +actual = [].flat.call(a); +assert.compareArray(actual, [1], 'The value of actual is expected to be [1]'); + +a = { + length: undefined, + 0: [1], +}; +actual = [].flat.call(a); +assert.compareArray(actual, [], 'The value of actual is expected to be []'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/bound-function-call.js b/js/src/tests/test262/built-ins/Array/prototype/flat/bound-function-call.js new file mode 100644 index 0000000000..374507b8f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/bound-function-call.js @@ -0,0 +1,19 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: > + using bound functions +includes: [compareArray.js] +features: [Array.prototype.flat] +---*/ + +var a = [ + [0], + [1] +]; +var actual = [].flat.bind(a)(); + +assert.compareArray(actual, [0, 1], 'The value of actual is expected to be [0, 1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/browser.js b/js/src/tests/test262/built-ins/Array/prototype/flat/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/flat/call-with-boolean.js new file mode 100644 index 0000000000..e5edec6120 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/call-with-boolean.js @@ -0,0 +1,13 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flat +description: Array.prototype.flat applied to boolean primitive +includes: [compareArray.js] +---*/ + +assert.compareArray(Array.prototype.flat.call(true), [], 'Array.prototype.flat.call(true) must return []'); +assert.compareArray(Array.prototype.flat.call(false), [], 'Array.prototype.flat.call(false) must return []'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/empty-array-elements.js b/js/src/tests/test262/built-ins/Array/prototype/flat/empty-array-elements.js new file mode 100644 index 0000000000..a8472974c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/empty-array-elements.js @@ -0,0 +1,26 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: > + arrays with empty arrays elements +includes: [compareArray.js] +features: [Array.prototype.flat] +---*/ + +var a = {}; +assert.compareArray([].flat(), [], '[].flat() must return []'); +assert.compareArray([ + [], + [] +].flat(), [], '[ [], [] ].flat() must return []'); +assert.compareArray([ + [], + [1] +].flat(), [1], '[ [], [1] ].flat() must return [1]'); +assert.compareArray([ + [], + [1, a] +].flat(), [1, a], '[ [], [1, a] ].flat() must return [1, a]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/empty-object-elements.js b/js/src/tests/test262/built-ins/Array/prototype/flat/empty-object-elements.js new file mode 100644 index 0000000000..29b707fd1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/empty-object-elements.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: > + arrays with empty object elements +includes: [compareArray.js] +features: [Array.prototype.flat] +---*/ + +var a = {}, + b = {}; + +assert.compareArray([a].flat(), [a], '[a].flat() must return [a]'); +assert.compareArray([a, [b]].flat(), [a, b], '[a, [b]].flat() must return [a, b]'); +assert.compareArray([ + [a], b +].flat(), [a, b], '[ [a], b ].flat() must return [a, b]'); +assert.compareArray([ + [a], + [b] +].flat(), [a, b], '[ [a], [b] ].flat() must return [a, b]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/length.js b/js/src/tests/test262/built-ins/Array/prototype/flat/length.js new file mode 100644 index 0000000000..0978244cc0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/length.js @@ -0,0 +1,23 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: Array.prototype.flat.length value and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [Array.prototype.flat] +---*/ + +assert.sameValue( + Array.prototype.flat.length, 0, + 'The value of `Array.prototype.flat.length` is `0`' +); + +verifyProperty(Array.prototype.flat, 'length', { + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/name.js b/js/src/tests/test262/built-ins/Array/prototype/flat/name.js new file mode 100644 index 0000000000..45af8402de --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: > + Array.prototype.flat.name value and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [Array.prototype.flat] +---*/ + +assert.sameValue( + Array.prototype.flat.name, 'flat', + 'The value of `Array.prototype.flat.name` is `"flat"`' +); + +verifyProperty(Array.prototype.flat, 'name', { + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/non-numeric-depth-should-not-throw.js b/js/src/tests/test262/built-ins/Array/prototype/flat/non-numeric-depth-should-not-throw.js new file mode 100644 index 0000000000..fb86d87595 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/non-numeric-depth-should-not-throw.js @@ -0,0 +1,45 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: > + if the argument is a string or object, the depthNum is 0 +includes: [compareArray.js] +features: [Array.prototype.flat] +---*/ + +var a = [1, [2]]; +var expected = a; + +// non integral string depthNum is converted to 0 +var depthNum = 'TestString'; +var actual = a.flat(depthNum); +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); + +// object type depthNum is converted to 0 +depthNum = {}; +actual = a.flat(depthNum); +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); + +// negative infinity depthNum is converted to 0 +depthNum = Number.NEGATIVE_INFINITY; +actual = a.flat(depthNum); +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); + +// positive zero depthNum is converted to 0 +depthNum = +0; +actual = a.flat(depthNum); +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); + +// negative zero depthNum is converted to 0 +depthNum = -0; +actual = a.flat(depthNum); +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); + +// integral string depthNum is converted to an integer +depthNum = '1'; +actual = a.flat(depthNum); +expected = [1, 2] +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/non-object-ctor-throws.js b/js/src/tests/test262/built-ins/Array/prototype/flat/non-object-ctor-throws.js new file mode 100644 index 0000000000..fe6886dcc1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/non-object-ctor-throws.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: > + Behavior when `constructor` property is neither an Object nor undefined + - if IsConstructor(C) is false, throw a TypeError exception. +features: [Array.prototype.flat] +---*/ + +assert.sameValue(typeof Array.prototype.flat, 'function'); + +var a = []; +a.constructor = null; +assert.throws(TypeError, function() { + a.flat(); +}, 'null value'); + +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.flat(); +}, 'number value'); + +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.flat(); +}, 'string value'); + +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.flat(); +}, 'boolean value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/flat/not-a-constructor.js new file mode 100644 index 0000000000..5f9c2c1401 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/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: > + Array.prototype.flat 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, arrow-function] +---*/ + +assert.sameValue(isConstructor(Array.prototype.flat), false, 'isConstructor(Array.prototype.flat) must return false'); + +assert.throws(TypeError, () => { + new Array.prototype.flat(); +}, '`new Array.prototype.flat()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/null-undefined-elements.js b/js/src/tests/test262/built-ins/Array/prototype/flat/null-undefined-elements.js new file mode 100644 index 0000000000..8bbf6a4ffa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/null-undefined-elements.js @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: > + arrays with null, and undefined +includes: [compareArray.js] +features: [Array.prototype.flat] +---*/ + +var a = [void 0]; + +assert.compareArray( + [1, null, void 0].flat(), + [1, null, undefined], + '[1, null, void 0].flat() must return [1, null, undefined]' +); +assert.compareArray( + [1, [null, void 0]].flat(), + [1, null, undefined], + '[1, [null, void 0]].flat() must return [1, null, undefined]' +); +assert.compareArray([ + [null, void 0], + [null, void 0] +].flat(), [null, undefined, null, undefined], '[ [null, void 0], [null, void 0] ].flat() must return [null, undefined, null, undefined]'); +assert.compareArray([1, [null, a]].flat(1), [1, null, a], '[1, [null, a]].flat(1) must return [1, null, a]'); +assert.compareArray( + [1, [null, a]].flat(2), + [1, null, undefined], + '[1, [null, a]].flat(2) must return [1, null, undefined]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/null-undefined-input-throws.js b/js/src/tests/test262/built-ins/Array/prototype/flat/null-undefined-input-throws.js new file mode 100644 index 0000000000..aac2ff3346 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/null-undefined-input-throws.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: > + null or undefined should throw TypeError Exception +features: [Array.prototype.flat] +---*/ + +assert.sameValue(typeof Array.prototype.flat, 'function'); + +assert.throws(TypeError, function() { + [].flat.call(null); +}, 'null value'); + +assert.throws(TypeError, function() { + [].flat.call(); +}, 'missing'); + +assert.throws(TypeError, function() { + [].flat.call(void 0); +}, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/positive-infinity.js b/js/src/tests/test262/built-ins/Array/prototype/flat/positive-infinity.js new file mode 100644 index 0000000000..7725c595c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/positive-infinity.js @@ -0,0 +1,14 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: > + if the argument is a positive infinity, the depthNum is max depth of the array +includes: [compareArray.js] +features: [Array.prototype.flat] +---*/ + +var a = [1, [2, [3, [4]]]] +assert.compareArray(a.flat(Number.POSITIVE_INFINITY), [1, 2, 3, 4], 'a.flat(Number.POSITIVE_INFINITY) must return [1, 2, 3, 4]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/flat/prop-desc.js new file mode 100644 index 0000000000..b7eff99b5b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/prop-desc.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: Property type and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [Array.prototype.flat] +---*/ + +assert.sameValue( + typeof Array.prototype.flat, + 'function', + '`typeof Array.prototype.flat` is `function`' +); + +verifyProperty(Array.prototype, 'flat', { + enumerable: false, + writable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/proxy-access-count.js b/js/src/tests/test262/built-ins/Array/prototype/flat/proxy-access-count.js new file mode 100644 index 0000000000..3100f4ecc8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/proxy-access-count.js @@ -0,0 +1,38 @@ +// Copyright (C) 2018 Richard Lawrence. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: > + properties are accessed correct number of times by .flat +info: | + Array.prototype.flat( [ depth ] ) + + ... + 6. Perform ? FlattenIntoArray(A, O, sourceLen, 0, depthNum). + + FlattenIntoArray (target, source, sourceLen, start, depth [ , mapperFunction, thisArg ]) + + 3. Repeat, while sourceIndex < sourceLen + a. Let P be ! ToString(sourceIndex). + b. Let exists be ? HasProperty(source, P). + c. If exists is true, then + i. Let element be ? Get(source, P). +features: [Array.prototype.flat] +includes: [compareArray.js] +---*/ + +const getCalls = [], hasCalls = []; +const handler = { + get : function (t, p, r) { getCalls.push(p); return Reflect.get(t, p, r); }, + has : function (t, p, r) { hasCalls.push(p); return Reflect.has(t, p, r); } +} + +const tier2 = new Proxy([4, 3], handler); +const tier1 = new Proxy([2, [3, [4, 2], 2], 5, tier2, 6], handler); + +Array.prototype.flat.call(tier1, 3); + +assert.compareArray(getCalls, ["length", "constructor", "0", "1", "2", "3", "length", "0", "1", "4"], 'The value of getCalls is expected to be ["length", "constructor", "0", "1", "2", "3", "length", "0", "1", "4"]'); +assert.compareArray(hasCalls, ["0", "1", "2", "3", "0", "1", "4"], 'The value of hasCalls is expected to be ["0", "1", "2", "3", "0", "1", "4"]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/shell.js b/js/src/tests/test262/built-ins/Array/prototype/flat/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/symbol-object-create-null-depth-throws.js b/js/src/tests/test262/built-ins/Array/prototype/flat/symbol-object-create-null-depth-throws.js new file mode 100644 index 0000000000..a84a154d6a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/symbol-object-create-null-depth-throws.js @@ -0,0 +1,20 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: > + if the argument is a Symbol or Object null, it throws exception +features: [Array.prototype.flat] +---*/ + +assert.sameValue(typeof Array.prototype.flat, 'function'); + +assert.throws(TypeError, function() { + [].flat(Symbol()); +}, 'symbol value'); + +assert.throws(TypeError, function() { + [].flat(Object.create(null)); +}, 'object create null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/target-array-non-extensible.js b/js/src/tests/test262/built-ins/Array/prototype/flat/target-array-non-extensible.js new file mode 100644 index 0000000000..2ac7bf6c1c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/target-array-non-extensible.js @@ -0,0 +1,50 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flat +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible, source array is not flattened) +info: | + Array.prototype.flat ( [ depth ] ) + + [...] + 6. Perform ? FlattenIntoArray(A, O, sourceLen, 0, depthNum). + + FlattenIntoArray ( target, source, sourceLen, start, depth [ , mapperFunction, thisArg ] ) + + [...] + 9. Repeat, while sourceIndex < sourceLen + [...] + c. If exists is true, then + [...] + v. If shouldFlatten is true, then + [...] + vi. Else, + [...] + 2. Perform ? CreateDataPropertyOrThrow(target, ! ToString(targetIndex), element). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; + +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.flat(1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/target-array-with-non-configurable-property.js b/js/src/tests/test262/built-ins/Array/prototype/flat/target-array-with-non-configurable-property.js new file mode 100644 index 0000000000..c5eef83725 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/target-array-with-non-configurable-property.js @@ -0,0 +1,50 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flat +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable, source array gets flattened) +info: | + Array.prototype.flat ( [ depth ] ) + + [...] + 6. Perform ? FlattenIntoArray(A, O, sourceLen, 0, depthNum). + + FlattenIntoArray ( target, source, sourceLen, start, depth [ , mapperFunction, thisArg ] ) + + [...] + 9. Repeat, while sourceIndex < sourceLen + [...] + c. If exists is true, then + [...] + v. If shouldFlatten is true, then + [...] + 2. Set targetIndex to ? FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + set: function(_value) {}, + configurable: false, + }); +}; + +var arr = [[1]]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.flat(1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/target-array-with-non-writable-property.js b/js/src/tests/test262/built-ins/Array/prototype/flat/target-array-with-non-writable-property.js new file mode 100644 index 0000000000..4294babb48 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/target-array-with-non-writable-property.js @@ -0,0 +1,52 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flat +description: > + Non-writable properties are overwritten by CreateDataProperty. + (result object's "0" is non-writable, source array gets flattened) +info: | + Array.prototype.flat ( [ depth ] ) + + [...] + 6. Perform ? FlattenIntoArray(A, O, sourceLen, 0, depthNum). + + FlattenIntoArray ( target, source, sourceLen, start, depth [ , mapperFunction, thisArg ] ) + + [...] + 9. Repeat, while sourceIndex < sourceLen + [...] + c. If exists is true, then + [...] + v. If shouldFlatten is true, then + [...] + 2. Set targetIndex to ? FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1). + [...] +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + value: 1, + writable: false, + enumerable: false, + configurable: true, + }); +}; + +var arr = [[2]]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +var res = arr.flat(1); + +verifyProperty(res, "0", { + value: 2, + writable: true, + enumerable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects-nested.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects-nested.js new file mode 100644 index 0000000000..58152e6c67 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects-nested.js @@ -0,0 +1,74 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + Does not flatten array-like objects nested into the main array +info: | + FlattenIntoArray(target, source, sourceLen, start, depth [ , mapperFunction, thisArg ]) + + 1. Let targetIndex be start. + 2. Let sourceIndex be 0. + 3. Repeat, while sourceIndex < sourceLen + a. Let P be ! ToString(sourceIndex). + b. Let exists be ? HasProperty(source, P). + c. If exists is true, then + i. Let element be ? Get(source, P). + ii. If mapperFunction is present, then + 1. Assert: thisArg is present. + 2. Set element to ? Call(mapperFunction, thisArg , « element, sourceIndex, source »). + iii. Let shouldFlatten be false. + iv. If depth > 0, then + 1. Set shouldFlatten to ? IsArray(element). + v. If shouldFlatten is true, then + 1. Let elementLen be ? ToLength(? Get(element, "length")). + 2. Set targetIndex to ? FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1). + vi. Else, + 1. If targetIndex ≥ 253-1, throw a TypeError exception. + 2. Perform ? CreateDataPropertyOrThrow(target, ! ToString(targetIndex), element). + 3. Increase targetIndex by 1. +includes: [compareArray.js] +features: [Array.prototype.flatMap, Int32Array] +---*/ + +function fn(e) { + return e; +} + +var obj1 = { + length: 1, + 0: 'a', + toString() { return 'obj1'; } +}; + +var obj2 = new Int32Array(2); + +var obj3 = { + get length() { throw "should not even consider the length property" }, + toString() { return 'obj3'; } +}; + +var arr = [obj1, obj2, obj3]; +var actual = arr.flatMap(fn); +assert.compareArray(actual, arr, 'The value of actual is expected to equal the value of arr'); +assert.notSameValue(actual, arr, 'The value of actual is expected to not equal the value of `arr`'); + +var arrLike = { + length: 4, + 0: obj1, + 1: obj2, + 2: obj3, + get 3() { return arrLike }, + toString() { return 'obj4'; } +}; + +actual = [].flatMap.call(arrLike, fn); +assert.compareArray(actual, [obj1, obj2, obj3, arrLike], 'The value of actual is expected to be [obj1, obj2, obj3, arrLike]'); +assert.notSameValue(actual, arrLike, 'The value of actual is expected to not equal the value of `arrLike`'); +assert.sameValue( + Object.getPrototypeOf(actual), + Array.prototype, + 'Object.getPrototypeOf([].flatMap.call(arrLike, fn)") returns Array.prototype' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects-poisoned-length.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects-poisoned-length.js new file mode 100644 index 0000000000..b7a8d20ef4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects-poisoned-length.js @@ -0,0 +1,62 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + Observe abrupt completion in poisoned lengths of array-like objects +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let sourceLen be ? ToLength(? Get(O, "length")). +features: [Array.prototype.flatMap, Symbol.toPrimitive] +---*/ + +assert.sameValue(typeof Array.prototype.flatMap, 'function'); + +function fn(e) { + return e; +} + +var arr = { + length: Symbol(), +}; +assert.throws(TypeError, function() { + [].flatMap.call(arr, fn); +}, 'length is a symbol'); + +arr = { + get length() { throw new Test262Error() } +}; +assert.throws(Test262Error, function() { + [].flatMap.call(arr, fn); +}, 'custom get error'); + +arr = { + length: { + valueOf() { throw new Test262Error() } + } +}; +assert.throws(Test262Error, function() { + [].flatMap.call(arr, fn); +}, 'custom valueOf error'); + +arr = { + length: { + toString() { throw new Test262Error() } + } +}; +assert.throws(Test262Error, function() { + [].flatMap.call(arr, fn); +}, 'custom toString error'); + +arr = { + length: { + [Symbol.toPrimitive]() { throw new Test262Error() } + } +}; +assert.throws(Test262Error, function() { + [].flatMap.call(arr, fn); +}, 'custom Symbol.toPrimitive error'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects-typedarrays.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects-typedarrays.js new file mode 100644 index 0000000000..6215e4d2d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects-typedarrays.js @@ -0,0 +1,52 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + array-like objects can be flattened (typedArrays) +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let sourceLen be ? ToLength(? Get(O, "length")). + ... + 5. Let A be ? ArraySpeciesCreate(O, 0). + ... + + ArraySpeciesCreate ( originalArray, length ) + + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). + 5. Let C be ? Get(originalArray, "constructor"). +includes: [compareArray.js] +features: [Array.prototype.flatMap, Int32Array] +---*/ + +function same(e) { + return e; +} + +var ta; +var actual; + +ta = new Int32Array([1, 0, 42]); + +Object.defineProperty(ta, 'constructor', { + get() { throw "it should not object the typedarray ctor"; } +}); +actual = [].flatMap.call(ta, same); +assert.compareArray(actual, [1, 0, 42], 'The value of actual is expected to be [1, 0, 42]'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype, 'Object.getPrototypeOf([].flatMap.call(ta, same)") returns Array.prototype'); +assert.sameValue(actual instanceof Int32Array, false, 'The result of evaluating (actual instanceof Int32Array) is expected to be false'); + +ta = new Int32Array(0); + +Object.defineProperty(ta, 'constructor', { + get() { throw "it should not object the typedarray ctor"; } +}); +actual = [].flatMap.call(ta, same); +assert.compareArray(actual, [], 'The value of actual is expected to be []'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype, 'Object.getPrototypeOf([].flatMap.call(ta, same)") returns Array.prototype'); +assert.sameValue(actual instanceof Int32Array, false, 'The result of evaluating (actual instanceof Int32Array) is expected to be false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects.js new file mode 100644 index 0000000000..6c5fa28717 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects.js @@ -0,0 +1,87 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + array-like objects can be flattened +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let sourceLen be ? ToLength(? Get(O, "length")). + ... + 5. Let A be ? ArraySpeciesCreate(O, 0). + ... + + ArraySpeciesCreate ( originalArray, length ) + + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). + + FlattenIntoArray(target, source, sourceLen, start, depth [ , mapperFunction, thisArg ]) + + 1. Let targetIndex be start. + 2. Let sourceIndex be 0. + 3. Repeat, while sourceIndex < sourceLen + a. Let P be ! ToString(sourceIndex). + b. Let exists be ? HasProperty(source, P). + c. If exists is true, then + ... + ** Skip if property does not exist ** +includes: [compareArray.js] +features: [Array.prototype.flatMap] +---*/ + +function fn(e) { + return [39, e * 2]; // returns an array to observe it being flattened after +} + +var a; +var actual; + +a = { + length: 3, + 0: 1, + // property 1 will be fully skipped + 2: 21, + get 3() { throw 'it should not get this property'; } +}; +actual = [].flatMap.call(a, fn); +assert.compareArray(actual, [39, 2, 39, 42], 'The value of actual is expected to be [39, 2, 39, 42]'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype, 'Object.getPrototypeOf([].flatMap.call(a, fn)") returns Array.prototype'); + +a = { + length: undefined, + get 0() { throw 'it should not get this property'; }, +}; +actual = [].flatMap.call(a, fn); +assert.compareArray(actual, [], 'The value of actual is expected to be []'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype, 'Object.getPrototypeOf([].flatMap.call(a, fn)") returns Array.prototype'); + +var called = false; +a = { + get length() { + if (!called) { + called = true; + return 2; + } else { + throw 'is should get the length only once'; + } + }, + 0: 21, + 1: 19.5, + get 2() { throw 'it should not get this property'; }, +}; +actual = [].flatMap.call(a, fn); +assert.compareArray(actual, [39, 42, 39, 39], 'The value of actual is expected to be [39, 42, 39, 39]'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype, 'Object.getPrototypeOf([].flatMap.call(a, fn)") returns Array.prototype'); + +a = { + length: 10001, + [10000]: 7, +}; +actual = [].flatMap.call(a, fn); +assert.compareArray(actual, [39, 14], 'The value of actual is expected to be [39, 14]'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype, 'Object.getPrototypeOf([].flatMap.call(a, fn)") returns Array.prototype'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/bound-function-argument.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/bound-function-argument.js new file mode 100644 index 0000000000..e9d9dfb39e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/bound-function-argument.js @@ -0,0 +1,16 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + Behavior when given a bound function +includes: [compareArray.js] +features: [Array.prototype.flatMap] +---*/ + +var a = [0, 0]; +assert.compareArray(a.flatMap(function() { + return this; +}.bind([1, 2])), [1, 2, 1, 2], 'a.flatMap(function() {return this;}.bind([1, 2])) must return [1, 2, 1, 2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/browser.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/call-with-boolean.js new file mode 100644 index 0000000000..8ebd2c8e20 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/call-with-boolean.js @@ -0,0 +1,21 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flatMap +description: Array.prototype.flatMap applied to boolean primitive +includes: [compareArray.js] +---*/ + +assert.compareArray( + Array.prototype.flatMap.call(true, () => {}), + [], + 'Array.prototype.flatMap.call(true, () => {}) must return []' +); +assert.compareArray( + Array.prototype.flatMap.call(false, () => {}), + [], + 'Array.prototype.flatMap.call(false, () => {}) must return []' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/depth-always-one.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/depth-always-one.js new file mode 100644 index 0000000000..b61c26bae4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/depth-always-one.js @@ -0,0 +1,25 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + Behavior when array is depth more than 1 +includes: [compareArray.js] +features: [Array.prototype.flatMap] +---*/ + +assert.compareArray([1, 2].flatMap(function(e) { + return [e, e * 2]; +}), [1, 2, 2, 4], '[1, 2].flatMap(function(e) {return [e, e * 2];}) must return [1, 2, 2, 4]'); + +var result = [1, 2, 3].flatMap(function(ele) { + return [ + [ele * 2] + ]; +}); +assert.sameValue(result.length, 3, 'The value of result.length is expected to be 3'); +assert.compareArray(result[0], [2], 'The value of result[0] is expected to be [2]'); +assert.compareArray(result[1], [4], 'The value of result[1] is expected to be [4]'); +assert.compareArray(result[2], [6], 'The value of result[2] is expected to be [6]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/length.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/length.js new file mode 100644 index 0000000000..c0767be8cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/length.js @@ -0,0 +1,23 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: Array.prototype.flatMap.length value and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [Array.prototype.flatMap] +---*/ + +assert.sameValue( + Array.prototype.flatMap.length, 1, + 'The value of `Array.prototype.flatmap.length` is `1`' +); + +verifyProperty(Array.prototype.flatMap, 'length', { + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/name.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/name.js new file mode 100644 index 0000000000..991c171e78 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/name.js @@ -0,0 +1,23 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatmap +description: Array.prototype.flatmap name value and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [Array.prototype.flatMap] +---*/ + +assert.sameValue( + Array.prototype.flatMap.name, 'flatMap', + 'The value of `Array.prototype.flatMap.name` is `"flatMap"`' +); + +verifyProperty(Array.prototype.flatMap, 'name', { + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/non-callable-argument-throws.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/non-callable-argument-throws.js new file mode 100644 index 0000000000..99fa7e30eb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/non-callable-argument-throws.js @@ -0,0 +1,52 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + non callable argument should throw TypeError Exception +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let sourceLen be ? ToLength(? Get(O, "length")). + 3. If IsCallable(mapperFunction) is false, throw a TypeError exception. + ... +features: [Array.prototype.flatMap, Symbol] +---*/ + +assert.sameValue(typeof Array.prototype.flatMap, "function"); + +assert.throws(TypeError, function() { + [].flatMap({}); +}, 'non callable argument, object'); + +assert.throws(TypeError, function() { + [].flatMap(0); +}, 'non callable argument, number'); + +assert.throws(TypeError, function() { + [].flatMap(); +}, 'non callable argument, implict undefined'); + +assert.throws(TypeError, function() { + [].flatMap(undefined); +}, 'non callable argument, undefined'); + +assert.throws(TypeError, function() { + [].flatMap(null); +}, 'non callable argument, null'); + +assert.throws(TypeError, function() { + [].flatMap(false); +}, 'non callable argument, boolean'); + +assert.throws(TypeError, function() { + [].flatMap(''); +}, 'non callable argument, string'); + +var s = Symbol(); +assert.throws(TypeError, function() { + [].flatMap(s); +}, 'non callable argument, symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/not-a-constructor.js new file mode 100644 index 0000000000..8facbadc1c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/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: > + Array.prototype.flatMap 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, Array.prototype.flatMap, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.flatMap), + false, + 'isConstructor(Array.prototype.flatMap) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.flatMap(() => {}); +}, '`new Array.prototype.flatMap(() => {})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/prop-desc.js new file mode 100644 index 0000000000..59e449ee48 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/prop-desc.js @@ -0,0 +1,29 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flatMap +description: Property type and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [Array.prototype.flatMap] +---*/ + +assert.sameValue( + typeof Array.prototype.flatMap, + 'function', + '`typeof Array.prototype.flatMap` is `function`' +); + +verifyProperty(Array.prototype, 'flatMap', { + enumerable: false, + writable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/proxy-access-count.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/proxy-access-count.js new file mode 100644 index 0000000000..e1693d4ea8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/proxy-access-count.js @@ -0,0 +1,44 @@ +// Copyright (C) 2018 Richard Lawrence. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + properties are accessed correct number of times by .flatMap +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + + ... + 6. Perform ? FlattenIntoArray(A, O, sourceLen, 0, 1, mapperFunction, T). + + FlattenIntoArray (target, source, sourceLen, start, depth [ , mapperFunction, thisArg ]) + + 3. Repeat, while sourceIndex < sourceLen + a. Let P be ! ToString(sourceIndex). + b. Let exists be ? HasProperty(source, P). + c. If exists is true, then + i. Let element be ? Get(source, P). +features: [Array.prototype.flatMap] +includes: [compareArray.js] +---*/ + +assert.sameValue( + typeof Array.prototype.flatMap, + 'function', + 'The value of `typeof Array.prototype.flatMap` is expected to be "function"' +); + +const getCalls = [], hasCalls = []; +const handler = { + get : function (t, p, r) { getCalls.push(p); return Reflect.get(t, p, r); }, + has : function (t, p, r) { hasCalls.push(p); return Reflect.has(t, p, r); } +} + +const tier2 = new Proxy([4, 3], handler); +const tier1 = new Proxy([2, [3, 4, 2, 2], 5, tier2, 6], handler); + +Array.prototype.flatMap.call(tier1, function(a){ return a; }); + +assert.compareArray(getCalls, ["length", "constructor", "0", "1", "2", "3", "length", "0", "1", "4"], 'The value of getCalls is expected to be ["length", "constructor", "0", "1", "2", "3", "length", "0", "1", "4"]'); +assert.compareArray(hasCalls, ["0", "1", "2", "3", "0", "1", "4"], 'The value of hasCalls is expected to be ["0", "1", "2", "3", "0", "1", "4"]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/shell.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/target-array-non-extensible.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/target-array-non-extensible.js new file mode 100644 index 0000000000..b5b17dfe6f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/target-array-non-extensible.js @@ -0,0 +1,50 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flatmap +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible, source array gets flattened) +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + + [...] + 6. Perform ? FlattenIntoArray(A, O, sourceLen, 0, depthNum). + + FlattenIntoArray ( target, source, sourceLen, start, depth [ , mapperFunction, thisArg ] ) + + [...] + 9. Repeat, while sourceIndex < sourceLen + [...] + c. If exists is true, then + [...] + v. If shouldFlatten is true, then + [...] + 2. Set targetIndex to ? FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; + +var arr = [[1]]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.flatMap(function(item) { + return item; + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/target-array-with-non-configurable-property.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/target-array-with-non-configurable-property.js new file mode 100644 index 0000000000..4df2aacac0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/target-array-with-non-configurable-property.js @@ -0,0 +1,54 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flatmap +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable, source array is not flattened) +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + + [...] + 6. Perform ? FlattenIntoArray(A, O, sourceLen, 0, depthNum). + + FlattenIntoArray ( target, source, sourceLen, start, depth [ , mapperFunction, thisArg ] ) + + [...] + 9. Repeat, while sourceIndex < sourceLen + [...] + c. If exists is true, then + [...] + v. If shouldFlatten is true, then + [...] + vi. Else, + [...] + 2. Perform ? CreateDataPropertyOrThrow(target, ! ToString(targetIndex), element). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + writable: true, + configurable: false, + }); +}; + +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.flatMap(function(item) { + return item; + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/target-array-with-non-writable-property.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/target-array-with-non-writable-property.js new file mode 100644 index 0000000000..1ed7aef093 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/target-array-with-non-writable-property.js @@ -0,0 +1,56 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flatmap +description: > + Non-writable properties are overwritten by CreateDataProperty. + (result object's "0" is non-writable, source array is not flattened) +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + + [...] + 6. Perform ? FlattenIntoArray(A, O, sourceLen, 0, depthNum). + + FlattenIntoArray ( target, source, sourceLen, start, depth [ , mapperFunction, thisArg ] ) + + [...] + 9. Repeat, while sourceIndex < sourceLen + [...] + c. If exists is true, then + [...] + v. If shouldFlatten is true, then + [...] + vi. Else, + [...] + 2. Perform ? CreateDataPropertyOrThrow(target, ! ToString(targetIndex), element). + [...] +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + value: 1, + writable: false, + enumerable: false, + configurable: true, + }); +}; + +var arr = [2]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +var res = arr.flatMap(function(item) { + return item; +}); + +verifyProperty(res, "0", { + value: 2, + writable: true, + enumerable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-non-object.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-non-object.js new file mode 100644 index 0000000000..896f1054ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-non-object.js @@ -0,0 +1,84 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + Assert behavior if this value has a custom non-object constructor property +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let sourceLen be ? ToLength(? Get(O, "length")). + ... + 5. Let A be ? ArraySpeciesCreate(O, 0). + ... + + ArraySpeciesCreate ( originalArray, length ) + + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, set C to undefined. + 7. If Type(C) is Object, then + a. Set C to ? Get(C, @@species). + b. If C is null, set C to undefined. + 8. If C is undefined, return ? ArrayCreate(length). + 9. If IsConstructor(C) is false, throw a TypeError exception. +features: [Array.prototype.flatMap, Symbol] +includes: [compareArray.js] +---*/ + +assert.sameValue( + typeof Array.prototype.flatMap, + 'function', + 'The value of `typeof Array.prototype.flatMap` is expected to be "function"' +); + +var a = []; +var mapperFn = function() {}; + +a.constructor = null; +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'a.flatMap(mapperFn) throws a TypeError exception'); + +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'a.flatMap(mapperFn) throws a TypeError exception'); + +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'a.flatMap(mapperFn) throws a TypeError exception'); + +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'a.flatMap(mapperFn) throws a TypeError exception'); + +a = []; +a.constructor = Symbol(); +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'a.flatMap(mapperFn) throws a TypeError exception'); + +a = []; +a.constructor = undefined; +var actual = a.flatMap(mapperFn); +assert.compareArray(actual, [], 'The value of actual is expected to be []'); +assert.sameValue( + Object.getPrototypeOf(actual), + Array.prototype, + 'Object.getPrototypeOf(a.flatMap(mapperFn)) returns Array.prototype' +); +assert.notSameValue(actual, a, 'The value of actual is expected to not equal the value of `a`'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js new file mode 100644 index 0000000000..e7ebabfce3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js @@ -0,0 +1,139 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flatMap +description: > + Assert behavior if this value has a custom object constructor property species +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let sourceLen be ? ToLength(? Get(O, "length")). + ... + 5. Let A be ? ArraySpeciesCreate(O, 0). + ... + + ArraySpeciesCreate ( originalArray, length ) + + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, set C to undefined. + 7. If Type(C) is Object, then + a. Set C to ? Get(C, @@species). + b. If C is null, set C to undefined. + 8. If C is undefined, return ? ArrayCreate(length). + 9. If IsConstructor(C) is false, throw a TypeError exception. + 10. Return ? Construct(C, « length »). +features: [Array.prototype.flatMap, Symbol, Symbol.species] +includes: [compareArray.js] +---*/ + +assert.sameValue( + typeof Array.prototype.flatMap, + 'function', + 'The value of `typeof Array.prototype.flatMap` is expected to be "function"' +); + +var arr = [[42, 1], [42, 2]]; +var mapperFn = function(e) { return e; }; + +arr.constructor = {}; +var actual = arr.flatMap(mapperFn); +assert.compareArray(actual, [42, 1, 42, 2], 'The value of actual is expected to be [42, 1, 42, 2]'); +assert.sameValue( + Object.getPrototypeOf(actual), + Array.prototype, + 'Object.getPrototypeOf(arr.flatMap(mapperFn)) returns Array.prototype' +); + +var called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return 0; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return ''; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return false; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return {}; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return []; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return Symbol(); + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + throw new Test262Error + } +}; +assert.throws(Test262Error, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a Test262Error exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor-poisoned-throws.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor-poisoned-throws.js new file mode 100644 index 0000000000..e3d6cd262e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor-poisoned-throws.js @@ -0,0 +1,60 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flatMap +description: > + Assert behavior if this value has a poisoned custom species constructor +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let sourceLen be ? ToLength(? Get(O, "length")). + ... + 5. Let A be ? ArraySpeciesCreate(O, 0). + 6. Perform ? FlattenIntoArray(A, O, sourceLen, 0, 1, mapperFunction, T). + 7. Return A. + + ArraySpeciesCreate ( originalArray, length ) + + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + ... + 7. If Type(C) is Object, then + a. Set C to ? Get(C, @@species). + b. If C is null, set C to undefined. + 8. If C is undefined, return ? ArrayCreate(length). + 9. If IsConstructor(C) is false, throw a TypeError exception. + 10. Return ? Construct(C, « length »). +features: [Array.prototype.flatMap, Symbol, Symbol.species] +---*/ + +assert.sameValue(typeof Array.prototype.flatMap, 'function'); + +var arr = []; +var mapperFn = function(e) { return e; }; + +var called = 0; +var ctorCalled = 0; +function ctor(len) { + assert.sameValue(new.target, ctor, 'new target is defined'); + assert.sameValue(len, 0, 'first argument is always 0'); + ctorCalled++; + throw new Test262Error(); +} + +arr.constructor = { + get [Symbol.species]() { + called++; + return ctor; + } +}; +assert.throws(Test262Error, function() { + arr.flatMap(mapperFn); +}, 'Return abrupt completion from species custom ctor'); +assert.sameValue(called, 1, 'got species once'); +assert.sameValue(ctorCalled, 1, 'called custom ctor once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor.js new file mode 100644 index 0000000000..1424e57d24 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor.js @@ -0,0 +1,96 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flatMap +description: > + Assert behavior if this value has a custom species constructor +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let sourceLen be ? ToLength(? Get(O, "length")). + ... + 5. Let A be ? ArraySpeciesCreate(O, 0). + 6. Perform ? FlattenIntoArray(A, O, sourceLen, 0, 1, mapperFunction, T). + 7. Return A. + + ArraySpeciesCreate ( originalArray, length ) + + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + ... + 7. If Type(C) is Object, then + a. Set C to ? Get(C, @@species). + b. If C is null, set C to undefined. + 8. If C is undefined, return ? ArrayCreate(length). + 9. If IsConstructor(C) is false, throw a TypeError exception. + 10. Return ? Construct(C, « length »). + + FlattenIntoArray(target, source, sourceLen, start, depth [ , mapperFunction, thisArg ]) + + 3. Repeat, while sourceIndex < sourceLen + a. Let P be ! ToString(sourceIndex). + b. Let exists be ? HasProperty(source, P). + c. If exists is true, then + ... + vi. Else, + ... + 2. Perform ? CreateDataPropertyOrThrow(target, ! ToString(targetIndex), element). +features: [Array.prototype.flatMap, Symbol, Symbol.species] +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.flatMap, 'function'); + +var arr = [[42, 1], [42, 2]]; +var mapperFn = function(e) { return e; }; + +var called = 0; +var ctorCalled = 0; +function ctor(len) { + assert.sameValue(new.target, ctor, 'new target is defined'); + assert.sameValue(len, 0, 'first argument is always 0'); + ctorCalled++; +} + +arr.constructor = { + get [Symbol.species]() { + called++; + return ctor; + } +}; +var actual = arr.flatMap(mapperFn); +assert(actual instanceof ctor, 'returned value is an instance of custom ctor'); +assert.sameValue(called, 1, 'got species once'); +assert.sameValue(ctorCalled, 1, 'called custom ctor once'); + +assert.sameValue(Object.prototype.hasOwnProperty.call(actual, 'length'), false, 'it does not define an own length property'); +verifyProperty(actual, '0', { + configurable: true, + writable: true, + enumerable: true, + value: 42 +}); +verifyProperty(actual, '1', { + configurable: true, + writable: true, + enumerable: true, + value: 1 +}); +verifyProperty(actual, '2', { + configurable: true, + writable: true, + enumerable: true, + value: 42 +}); +verifyProperty(actual, '3', { + configurable: true, + writable: true, + enumerable: true, + value: 2 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species.js new file mode 100644 index 0000000000..25106bdbe2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species.js @@ -0,0 +1,159 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flatMap +description: > + Assert behavior if this value has a custom object constructor property +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let sourceLen be ? ToLength(? Get(O, "length")). + ... + 5. Let A be ? ArraySpeciesCreate(O, 0). + ... + + ArraySpeciesCreate ( originalArray, length ) + + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, set C to undefined. + 7. If Type(C) is Object, then + a. Set C to ? Get(C, @@species). + b. If C is null, set C to undefined. + 8. If C is undefined, return ? ArrayCreate(length). + 9. If IsConstructor(C) is false, throw a TypeError exception. + 10. Return ? Construct(C, « length »). +features: [Array.prototype.flatMap, Symbol, Symbol.species] +includes: [compareArray.js] +---*/ + +assert.sameValue( + typeof Array.prototype.flatMap, + 'function', + 'The value of `typeof Array.prototype.flatMap` is expected to be "function"' +); + +var arr = [[42, 1], [42, 2]]; +var mapperFn = function(e) { return e; }; + +arr.constructor = {}; +var actual = arr.flatMap(mapperFn); +assert.compareArray(actual, [42, 1, 42, 2], 'The value of actual is expected to be [42, 1, 42, 2]'); +assert.sameValue( + Object.getPrototypeOf(actual), + Array.prototype, + 'Object.getPrototypeOf(arr.flatMap(mapperFn)) returns Array.prototype' +); + +var called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return null; + } +}; +actual = arr.flatMap(mapperFn); +assert.compareArray(actual, [42, 1, 42, 2], 'The value of actual is expected to be [42, 1, 42, 2]'); +assert.sameValue( + Object.getPrototypeOf(actual), + Array.prototype, + 'Object.getPrototypeOf(arr.flatMap(mapperFn)) returns Array.prototype' +); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return undefined; + } +}; +actual = arr.flatMap(mapperFn); +assert.compareArray(actual, [42, 1, 42, 2], 'The value of actual is expected to be [42, 1, 42, 2]'); +assert.sameValue( + Object.getPrototypeOf(actual), + Array.prototype, + 'Object.getPrototypeOf(arr.flatMap(mapperFn)) returns Array.prototype' +); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return 0; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return ''; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return false; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return {}; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return []; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return Symbol(); + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-null-undefined-throws.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-null-undefined-throws.js new file mode 100644 index 0000000000..f2b52aeb34 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-null-undefined-throws.js @@ -0,0 +1,27 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + Throw a TypeError if this value is null or undefined +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + ... +features: [Array.prototype.flatMap] +---*/ + +assert.sameValue(typeof Array.prototype.flatMap, 'function'); + +var mapperFn = function() {}; + +assert.throws(TypeError, function() { + [].flatMap.call(null, mapperFn); +}, 'null value'); + +assert.throws(TypeError, function() { + [].flatMap.call(undefined, mapperFn); +}, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/thisArg-argument-strict.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/thisArg-argument-strict.js new file mode 100644 index 0000000000..b2b1ad9347 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/thisArg-argument-strict.js @@ -0,0 +1,48 @@ +'use strict'; +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + Behavior when thisArg is provided + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +flags: [onlyStrict] +includes: [compareArray.js] +features: [Array.prototype.flatMap] +---*/ + +var a = {}; +var actual; + +actual = [1].flatMap(function() { + return [this]; +}, "TestString"); +assert.compareArray(actual, ["TestString"], 'The value of actual is expected to be ["TestString"]'); + +actual = [1].flatMap(function() { + return [this]; +}, 1); +assert.compareArray(actual, [1], 'The value of actual is expected to be [1]'); + +actual = [1].flatMap(function() { + return [this]; +}, null); +assert.compareArray(actual, [null], 'The value of actual is expected to be [null]'); + +actual = [1].flatMap(function() { + return [this]; +}, true); +assert.compareArray(actual, [true], 'The value of actual is expected to be [true]'); + +actual = [1].flatMap(function() { + return [this]; +}, a); +assert.compareArray(actual, [a], 'The value of actual is expected to be [a]'); + +actual = [1].flatMap(function() { + return [this]; +}, void 0); +assert.compareArray(actual, [undefined], 'The value of actual is expected to be [undefined]'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-1.js new file mode 100644 index 0000000000..97ba0e7da3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to undefined +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.forEach.call(undefined); // TypeError is thrown if value is undefined +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-10.js new file mode 100644 index 0000000000..5111e7439e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-10.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to the Math object +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = ('[object Math]' === Object.prototype.toString.call(obj)); +} + +Math.length = 1; +Math[0] = 1; +Array.prototype.forEach.call(Math, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-11.js new file mode 100644 index 0000000000..b4f123e219 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-11.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to Date object +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = obj instanceof Date; +} + +var obj = new Date(); +obj.length = 1; +obj[0] = 1; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-12.js new file mode 100644 index 0000000000..75339e9910 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-12.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to RegExp object +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = obj instanceof RegExp; +} + +var obj = new RegExp(); +obj.length = 1; +obj[0] = 1; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-13.js new file mode 100644 index 0000000000..02a8100a02 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-13.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to the JSON object +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = ('[object JSON]' === Object.prototype.toString.call(obj)); +} + +JSON.length = 1; +JSON[0] = 1; +Array.prototype.forEach.call(JSON, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-14.js new file mode 100644 index 0000000000..df44a2e13d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-14.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to Error object +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = obj instanceof Error; +} + +var obj = new Error(); +obj.length = 1; +obj[0] = 1; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-15.js new file mode 100644 index 0000000000..4a7d180d32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-15.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to the Arguments object +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = ('[object Arguments]' === Object.prototype.toString.call(obj)); +} + +var obj = (function() { + return arguments; +}("a", "b")); + +Array.prototype.forEach.call(obj, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-2.js new file mode 100644 index 0000000000..e098f04e7c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to null +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.forEach.call(null); // TypeError is thrown if value is null +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-3.js new file mode 100644 index 0000000000..dbeae73b60 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-3.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to boolean primitive +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = obj instanceof Boolean; +} + +Boolean.prototype[0] = true; +Boolean.prototype.length = 1; + +Array.prototype.forEach.call(false, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-4.js new file mode 100644 index 0000000000..75a5123bd3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-4.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to Boolean object +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = obj instanceof Boolean; +} + +var obj = new Boolean(true); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-5.js new file mode 100644 index 0000000000..68178afdc4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-5.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to number primitive +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = obj instanceof Number; +} + +Number.prototype[0] = 1; +Number.prototype.length = 1; + +Array.prototype.forEach.call(2.5, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-6.js new file mode 100644 index 0000000000..cc0ce7ab45 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-6.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to Number object +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = obj instanceof Number; +} + +var obj = new Number(-128); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-7.js new file mode 100644 index 0000000000..50d0615659 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-7.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to string primitive +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = obj instanceof String; +} + +Array.prototype.forEach.call("abc", callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-8.js new file mode 100644 index 0000000000..b87705bec5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-8.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to String object +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = obj instanceof String; +} + +var obj = new String("abc"); +Array.prototype.forEach.call(obj, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-9.js new file mode 100644 index 0000000000..5c6a97e425 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-1-9.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to Function object +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = obj instanceof Function; +} + +var obj = function(a, b) { + return a + b; +}; +obj[0] = 11; +obj[1] = 9; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-1.js new file mode 100644 index 0000000000..049761cb71 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-1.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - 'length' is own data property on an + Array-like object +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2 +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-10.js new file mode 100644 index 0000000000..87dd30422d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-10.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Array-like object, 'length' is + an inherited accessor property +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +Array.prototype.forEach.call(child, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-11.js new file mode 100644 index 0000000000..510a7ed21e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-11.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Array-like object, 'length' is + an own accessor property without a get function +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-12.js new file mode 100644 index 0000000000..a8bbd6f1af --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-12.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - 'length' is own accessor property + without a get function that overrides an inherited accessor + property on an Array +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var obj = { + 0: 12, + 1: 11 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-13.js new file mode 100644 index 0000000000..540a8394cf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-13.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to the Array-like object that + 'length' is inherited accessor property without a get function +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 11; +child[1] = 12; + +Array.prototype.forEach.call(child, callbackfn); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-14.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-14.js new file mode 100644 index 0000000000..f0c0721d9c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-14.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to the Array-like object that + 'length' property doesn't exist +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +var obj = { + 0: 11, + 1: 12 +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-17.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-17.js new file mode 100644 index 0000000000..331c567413 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-17.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to the Arguments object, which + implements its own property get method +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} + +var func = function(a, b) { + arguments[2] = 9; + Array.prototype.forEach.call(arguments, callbackfn); + return result; +}; + +assert(func(12, 11), 'func(12, 11) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-18.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-18.js new file mode 100644 index 0000000000..0635558208 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-18.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to String object, which implements + its own property get method +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (obj.length === 3); +} + +var str = new String("012"); + +Array.prototype.forEach.call(str, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-19.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-19.js new file mode 100644 index 0000000000..a18c47d3e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-19.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Function object, which + implements its own property get method +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} + +var fun = function(a, b) { + return a + b; +}; +fun[0] = 12; +fun[1] = 11; +fun[2] = 9; + +Array.prototype.forEach.call(fun, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-2.js new file mode 100644 index 0000000000..9bd8645233 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-2.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - 'length' is own data property on an Array +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} + +[12, 11].forEach(callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-3.js new file mode 100644 index 0000000000..19b2e2c686 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-3.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - 'length' is an own data property that + overrides an inherited data property on an Array-like object +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} + +var proto = { + length: 3 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +child[0] = 12; +child[1] = 11; +child[2] = 9; + +Array.prototype.forEach.call(child, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-4.js new file mode 100644 index 0000000000..bc7c2f0566 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-4.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - 'length' is own data property that + overrides an inherited data property on an Array +---*/ + +var result = false; +var arrProtoLen; + +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} + +arrProtoLen = Array.prototype.length; +Array.prototype.length = 0; +[12, 11].forEach(callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-5.js new file mode 100644 index 0000000000..4b7348b4d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-5.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Array-like object, 'length' is + an own data property that overrides an inherited accessor property +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +Array.prototype.forEach.call(child, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-6.js new file mode 100644 index 0000000000..19a8f05448 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-6.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Array-like object, 'length' is + an inherited data property +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} + +var proto = { + length: 2 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +Array.prototype.forEach.call(child, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-7.js new file mode 100644 index 0000000000..cf5c407755 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-7.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Array-like object, 'length' is + an own accessor property +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +obj[0] = 12; +obj[1] = 11; +obj[2] = 9; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-8.js new file mode 100644 index 0000000000..0cc7d8f8fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-8.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Array-like object, 'length' is + an own accessor property that overrides an inherited data property +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} + +var proto = { + length: 3 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +child[0] = 12; +child[1] = 11; +child[2] = 9; + +Array.prototype.forEach.call(child, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-9.js new file mode 100644 index 0000000000..418e0fd618 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-2-9.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Array-like object, 'length' is + an own accessor property that overrides an inherited accessor + property +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +child[0] = 12; +child[1] = 11; +child[2] = 9; + +Array.prototype.forEach.call(child, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-1.js new file mode 100644 index 0000000000..1ed6f554e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-1.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - value of 'length' is undefined +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +var obj = { + 0: 0, + 1: 1, + length: undefined +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-10.js new file mode 100644 index 0000000000..d55c5ae5a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-10.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - value of 'length' is a number (value is + NaN) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +var obj = { + 0: 9, + length: NaN +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-11.js new file mode 100644 index 0000000000..5f38eed122 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-11.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-11 +description: > + Array.prototype.forEach - 'length' is a string containing a + positive number +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} + +var obj = { + 1: 11, + 2: 9, + length: "2" +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-12.js new file mode 100644 index 0000000000..88182344e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-12.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-12 +description: > + Array.prototype.forEach - 'length' is a string containing a + negative number +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} + +var obj = { + 1: 11, + 2: 9, + length: "-4294967294" +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(testResult, false, 'testResult'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-13.js new file mode 100644 index 0000000000..2e02b153dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-13.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-13 +description: > + Array.prototype.forEach - 'length' is a string containing a + decimal number +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} +var obj = { + 1: 11, + 2: 9, + length: "2.5" +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-14.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-14.js new file mode 100644 index 0000000000..caea1bfe8a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-14.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-14 +description: Array.prototype.forEach - 'length' is a string containing -Infinity +---*/ + +var accessed2 = false; + +function callbackfn2(val, idx, obj) { + accessed2 = true; +} + +var obj2 = { + 0: 9, + length: "-Infinity" +}; + +Array.prototype.forEach.call(obj2, callbackfn2); + +assert.sameValue(accessed2, false, 'accessed2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-15.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-15.js new file mode 100644 index 0000000000..ad9ff226e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-15.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-15 +description: > + Array.prototype.forEach - 'length' is a string containing an + exponential number +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} + +var obj = { + 1: 11, + 2: 9, + length: "2E0" +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-16.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-16.js new file mode 100644 index 0000000000..142e67ae2b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-16.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-16 +description: > + Array.prototype.forEach - 'length' is a string containing a hex + number +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} + +var obj = { + 1: 11, + 2: 9, + length: "0x0002" +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-17.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-17.js new file mode 100644 index 0000000000..02f6f4a92c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-17.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-17 +description: > + Array.prototype.forEach - 'length' is a string containing a number + with leading zeros +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} + +var obj = { + 1: 11, + 2: 9, + length: "0002.00" +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-18.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-18.js new file mode 100644 index 0000000000..e86eadea72 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-18.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-18 +description: > + Array.prototype.forEach - value of 'length' is a string that can't + convert to a number +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +var obj = { + 0: 9, + length: "asdf!_" +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-19.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-19.js new file mode 100644 index 0000000000..eca8094b8c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-19.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-19 +description: > + Array.prototype.forEach - value of 'length' is an Object which has + an own toString method. +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} + +var obj = { + 1: 11, + 2: 9, + length: { + toString: function() { + return '2'; + } + } +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-2.js new file mode 100644 index 0000000000..f4a7dd3612 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-2.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-2 +description: > + Array.prototype.forEach - value of 'length' is a boolean (value is + true) +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} + +var obj = { + 0: 11, + 1: 9, + length: true +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-20.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-20.js new file mode 100644 index 0000000000..a8afca0e75 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-20.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-20 +description: > + Array.prototype.forEach - value of 'length' is an Object which has + an own valueOf method. +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} + +var obj = { + 1: 11, + 2: 9, + length: { + valueOf: function() { + return 2; + } + } +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-21.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-21.js new file mode 100644 index 0000000000..f03f2ac619 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-21.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-21 +description: > + Array.prototype.forEach - 'length' is an object that has an own + valueOf method that returns an object and toString method that + returns a string +---*/ + +var testResult = false; +var firstStepOccured = false; +var secondStepOccured = false; + +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} + +var obj = { + 1: 11, + 2: 9, + length: { + valueOf: function() { + firstStepOccured = true; + return {}; + }, + toString: function() { + secondStepOccured = true; + return '2'; + } + } +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); +assert(firstStepOccured, 'firstStepOccured !== true'); +assert(secondStepOccured, 'secondStepOccured !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-22.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-22.js new file mode 100644 index 0000000000..db0322d283 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-22.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-22 +description: > + Array.prototype.forEach throws TypeError exception when 'length' + is an object with toString and valueOf methods that don�t return + primitive values +---*/ + +var accessed = false; +var firstStepOccured = false; +var secondStepOccured = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +var obj = { + 1: 11, + 2: 12, + + length: { + valueOf: function() { + firstStepOccured = true; + return {}; + }, + toString: function() { + secondStepOccured = true; + return {}; + } + } +}; +assert.throws(TypeError, function() { + Array.prototype.forEach.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-23.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-23.js new file mode 100644 index 0000000000..924f5cf975 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-23.js @@ -0,0 +1,50 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-23 +description: > + Array.prototype.forEach uses inherited valueOf method when + 'length' is an object with an own toString and inherited valueOf + methods +---*/ + +var testResult = false; +var valueOfAccessed = false; +var toStringAccessed = false; + +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} + +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +child.toString = function() { + toStringAccessed = true; + return '1'; +}; + +var obj = { + 1: 11, + 2: 9, + length: child +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-24.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-24.js new file mode 100644 index 0000000000..b0f05c4b35 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-24.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-24 +description: > + Array.prototype.forEach - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} + +var obj = { + 1: 11, + 2: 9, + length: 2.685 +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-25.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-25.js new file mode 100644 index 0000000000..06371424a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-25.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-25 +description: > + Array.prototype.forEach - value of 'length' is a negative + non-integer +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} + +var obj = { + 1: 11, + 2: 9, + length: -4294967294.5 +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(testResult, false, 'testResult'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-3.js new file mode 100644 index 0000000000..19040140b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-3.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-3 +description: > + Array.prototype.forEach - value of 'length' is a number (value is + 0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +var obj = { + 0: 1, + 1: 1, + length: 0 +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-4.js new file mode 100644 index 0000000000..4f57dcd698 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-4.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-4 +description: > + Array.prototype.forEach - value of 'length' is a number (value is + +0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +var obj = { + 0: 11, + length: +0 +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-5.js new file mode 100644 index 0000000000..083c6ae27f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-5.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-5 +description: > + Array.prototype.forEach - value of 'length' is a number (value is + -0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +var obj = { + 0: 11, + length: -0 +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-6.js new file mode 100644 index 0000000000..81758b3626 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-6.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-6 +description: > + Array.prototype.forEach - value of 'length' is a number (value is + positive) +---*/ + +var testResult1 = false; + +function callbackfn(val, idx, obj) { + testResult1 = (val > 10); +} + +var obj = { + 1: 11, + 2: 9, + length: 2 +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult1, 'testResult1 !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-7.js new file mode 100644 index 0000000000..bb62f0389b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-7.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-7 +description: > + Array.prototype.forEach - value of 'length' is a number (value is + negative) +---*/ + +var testResult1 = false; + +function callbackfn(val, idx, obj) { + testResult1 = (val > 10); +} + +var obj = { + 1: 11, + 2: 9, + length: -4294967294 +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(testResult1, false, 'testResult1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-9.js new file mode 100644 index 0000000000..9fb4239a2a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-3-9.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-9 +description: > + Array.prototype.forEach - value of 'length' is a number (value is + -Infinity) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +var obj = { + 0: 9, + length: -Infinity +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-1.js new file mode 100644 index 0000000000..1d2e1adb25 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-1.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-1 +description: Array.prototype.forEach throws TypeError if callbackfn is undefined +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.forEach(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-10.js new file mode 100644 index 0000000000..4cfc18c34a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-10.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-10 +description: > + Array.prototype.forEach - the exception is not thrown if exception + was thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.forEach.call(obj, undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-11.js new file mode 100644 index 0000000000..b1c38f7f26 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-11.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-11 +description: > + Array.prototype.forEach - the exception is not thrown if exception + was thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.forEach.call(obj, undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-12.js new file mode 100644 index 0000000000..7193be7253 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-12.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-12 +description: Array.prototype.forEach - 'callbackfn' is a function +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +[11, 9].forEach(callbackfn); + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-15.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-15.js new file mode 100644 index 0000000000..1f21e7ce32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-15.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-15 +description: > + Array.prototype.forEach - calling with no callbackfn is the same + as passing undefined for callbackfn +---*/ + +var obj = { + 10: 10 +}; +var lengthAccessed = false; +var loopAccessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + lengthAccessed = true; + return 20; + }, + configurable: true +}); + +Object.defineProperty(obj, "0", { + get: function() { + loopAccessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.forEach.call(obj); +}); +assert(lengthAccessed, 'lengthAccessed !== true'); +assert.sameValue(loopAccessed, false, 'loopAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-2.js new file mode 100644 index 0000000000..d2314173b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-2.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-2 +description: > + Array.prototype.forEach throws ReferenceError if callbackfn is + unreferenced +---*/ + +var arr = new Array(10); +assert.throws(ReferenceError, function() { + arr.forEach(foo); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-3.js new file mode 100644 index 0000000000..7ac0d0c314 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-3.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-3 +description: Array.prototype.forEach throws TypeError if callbackfn is null +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.forEach(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-4.js new file mode 100644 index 0000000000..99a096fa93 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-4.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-4 +description: Array.prototype.forEach throws TypeError if callbackfn is boolean +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.forEach(true); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-5.js new file mode 100644 index 0000000000..5a755627e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-5.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-5 +description: Array.prototype.forEach throws TypeError if callbackfn is number +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.forEach(5); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-6.js new file mode 100644 index 0000000000..c4d9f4388f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-6.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-6 +description: Array.prototype.forEach throws TypeError if callbackfn is string +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.forEach("abc"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-7.js new file mode 100644 index 0000000000..300b7b9b13 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-7.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach throws TypeError if callbackfn is Object + without Call internal method +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.forEach(new Object()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-8.js new file mode 100644 index 0000000000..7bec9f84e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-8.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.forEach.call(obj, null); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-9.js new file mode 100644 index 0000000000..4d9a7dc9c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-4-9.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.forEach.call(obj, null); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1-s.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1-s.js new file mode 100644 index 0000000000..8278ff7e27 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1-s.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - thisArg not passed to strict callbackfn +flags: [noStrict] +---*/ + +var innerThisCorrect = false; + +function callbackfn(val, idx, obj) { + "use strict"; + innerThisCorrect = this === undefined; + return true; +} + +[1].forEach(callbackfn); + +assert(innerThisCorrect, 'innerThisCorrect !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1.js new file mode 100644 index 0000000000..51cf3aa3b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-1.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - thisArg is passed +flags: [noStrict] +---*/ + +(function() { + this._15_4_4_18_5_1 = false; + var _15_4_4_18_5_1 = true; + var result; + + function callbackfn(val, idx, obj) { + result = this._15_4_4_18_5_1; + } + var arr = [1]; + arr.forEach(callbackfn) + + assert.sameValue(result, false, 'result'); +})(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-10.js new file mode 100644 index 0000000000..b08d9a9bbf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-10.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - Array Object can be used as thisArg +---*/ + +var result = false; +var objArray = []; + +function callbackfn(val, idx, obj) { + result = (this === objArray); +} + +[11].forEach(callbackfn, objArray); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-11.js new file mode 100644 index 0000000000..d8117261de --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-11.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - String Object can be used as thisArg +---*/ + +var result = false; +var objString = new String(); + +function callbackfn(val, idx, obj) { + result = (this === objString); +} + +[11].forEach(callbackfn, objString); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-12.js new file mode 100644 index 0000000000..e8f8fd0b10 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-12.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - Boolean Object can be used as thisArg +---*/ + +var result = false; +var objBoolean = new Boolean(); + +function callbackfn(val, idx, obj) { + result = (this === objBoolean); +} + +[11].forEach(callbackfn, objBoolean); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-13.js new file mode 100644 index 0000000000..ca75a95c46 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-13.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - Number Object can be used as thisArg +---*/ + +var result = false; +var objNumber = new Number(); + +function callbackfn(val, idx, obj) { + result = (this === objNumber); +} + +[11].forEach(callbackfn, objNumber); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-14.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-14.js new file mode 100644 index 0000000000..1fecc909bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-14.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - the Math object can be used as thisArg +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (this === Math); +} + +[11].forEach(callbackfn, Math); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-15.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-15.js new file mode 100644 index 0000000000..a4d1caf0f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-15.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - Date Object can be used as thisArg +---*/ + +var result = false; +var objDate = new Date(); + +function callbackfn(val, idx, obj) { + result = (this === objDate); +} + +[11].forEach(callbackfn, objDate); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-16.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-16.js new file mode 100644 index 0000000000..76619c117a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-16.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - RegExp Object can be used as thisArg +---*/ + +var result = false; +var objRegExp = new RegExp(); + +function callbackfn(val, idx, obj) { + result = (this === objRegExp); +} + +[11].forEach(callbackfn, objRegExp); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-17.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-17.js new file mode 100644 index 0000000000..5285ac8814 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-17.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - the JSON object can be used as thisArg +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (this === JSON); +} + +[11].forEach(callbackfn, JSON); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-18.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-18.js new file mode 100644 index 0000000000..a0dc54973e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-18.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - Error Object can be used as thisArg +---*/ + +var result = false; +var objError = new RangeError(); + +function callbackfn(val, idx, obj) { + result = (this === objError); +} + +[11].forEach(callbackfn, objError); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-19.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-19.js new file mode 100644 index 0000000000..85a5e1eb73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-19.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - the Arguments object can be used as + thisArg +---*/ + +var result = false; +var arg; + +function callbackfn(val, idx, obj) { + result = (this === arg); +} + +(function fun() { + arg = arguments; +}(1, 2, 3)); + +[11].forEach(callbackfn, arg); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-2.js new file mode 100644 index 0000000000..43b1b871e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-2.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - thisArg is Object +---*/ + +var res = false; +var o = new Object(); +o.res = true; +var result; + +function callbackfn(val, idx, obj) +{ + result = this.res; +} + +var arr = [1]; +arr.forEach(callbackfn, o) + +assert.sameValue(result, true, 'result'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-21.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-21.js new file mode 100644 index 0000000000..6fdb94c24f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-21.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - the global object can be used as thisArg +---*/ + +var global = this; +var result = false; + +function callbackfn(val, idx, obj) { + result = (this === global); +} + +[11].forEach(callbackfn, this); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-22.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-22.js new file mode 100644 index 0000000000..e947218cdb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-22.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - boolean primitive can be used as thisArg +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (this.valueOf() === false); +} + +[11].forEach(callbackfn, false); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-23.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-23.js new file mode 100644 index 0000000000..6a4c52b911 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-23.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - number primitive can be used as thisArg +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (this.valueOf() === 101); +} + +[11].forEach(callbackfn, 101); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-24.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-24.js new file mode 100644 index 0000000000..7888f3042f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-24.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - string primitive can be used as thisArg +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (this.valueOf() === "abc"); +} + +[11].forEach(callbackfn, "abc"); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-25.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-25.js new file mode 100644 index 0000000000..32ab29eaf1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-25.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - thisArg not passed +flags: [noStrict] +---*/ + +function innerObj() { + this._15_4_4_18_5_25 = true; + var _15_4_4_18_5_25 = false; + var result; + + function callbackfn(val, idx, obj) { + result = this._15_4_4_18_5_25; + } + var arr = [1]; + arr.forEach(callbackfn) + this.retVal = !result; +} + +assert(new innerObj().retVal, 'new innerObj().retVal !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-3.js new file mode 100644 index 0000000000..f31bf20aac --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - thisArg is Array +---*/ + +var res = false; +var a = new Array(); +a.res = true; +var result; + +function callbackfn(val, idx, obj) +{ + result = this.res; +} + +var arr = [1]; +arr.forEach(callbackfn, a) + +assert.sameValue(result, true, 'result'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-4.js new file mode 100644 index 0000000000..fe1ed7f8bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-4.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - thisArg is object from object + template(prototype) +---*/ + +var res = false; +var result; + +function callbackfn(val, idx, obj) +{ + result = this.res; +} + +function foo() {} +foo.prototype.res = true; +var f = new foo(); +var arr = [1]; +arr.forEach(callbackfn, f) + +assert.sameValue(result, true, 'result'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-5.js new file mode 100644 index 0000000000..7ebb9bec1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-5.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - thisArg is object from object template +---*/ + +var res = false; +var result; + +function callbackfn(val, idx, obj) +{ + result = this.res; +} + +function foo() {} +var f = new foo(); +f.res = true; + +var arr = [1]; +arr.forEach(callbackfn, f) + +assert.sameValue(result, true, 'result'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-6.js new file mode 100644 index 0000000000..e0d807f48f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-6.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - thisArg is function +---*/ + +var res = false; +var result; + +function callbackfn(val, idx, obj) +{ + result = this.res; +} + +function foo() {} +foo.res = true; + +var arr = [1]; +arr.forEach(callbackfn, foo) + +assert.sameValue(result, true, 'result'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-7.js new file mode 100644 index 0000000000..367fef55bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-7.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - built-in functions can be used as thisArg +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (this === eval); +} + +[11].forEach(callbackfn, eval); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-9.js new file mode 100644 index 0000000000..c5dd67ec2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-5-9.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - Function Object can be used as thisArg +---*/ + +var result = false; +var objString = function() {}; + +function callbackfn(val, idx, obj) { + result = (this === objString); +} + +[11].forEach(callbackfn, objString); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-1.js new file mode 100644 index 0000000000..0c29176657 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-1.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't consider new elements added to + array after the call +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + callCnt++; + arr[2] = 3; + arr[5] = 6; +} + +var arr = [1, 2, , 4, 5]; +arr.forEach(callbackfn); + +assert.sameValue(callCnt, 5, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-2.js new file mode 100644 index 0000000000..1fc9736bf3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-2.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't visit deleted elements in array + after the call +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + if (callCnt == 0) + delete arr[3]; + callCnt++; +} + +var arr = [1, 2, 3, 4, 5]; +arr.forEach(callbackfn) + +assert.sameValue(callCnt, 4, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-3.js new file mode 100644 index 0000000000..a45f1903ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't visit deleted elements when + Array.length is decreased +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + arr.length = 3; + callCnt++; +} + +var arr = [1, 2, 3, 4, 5]; +arr.forEach(callbackfn); + +assert.sameValue(callCnt, 3, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-4.js new file mode 100644 index 0000000000..28e8d05102 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-4.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't consider newly added elements in + sparse array +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + arr[1000] = 3; + callCnt++; +} + +var arr = new Array(10); +arr[1] = 1; +arr[2] = 2; +arr.forEach(callbackfn); + +assert.sameValue(callCnt, 2, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-5.js new file mode 100644 index 0000000000..aa7a3a8904 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-5.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach visits deleted element in array after the + call when same index is also present in prototype +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + delete arr[4]; + callCnt++; +} + +Array.prototype[4] = 5; + +var arr = [1, 2, 3, 4, 5]; +arr.forEach(callbackfn) +delete Array.prototype[4]; + +assert.sameValue(callCnt, 5, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-7.js new file mode 100644 index 0000000000..18acb0f63f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-7.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - considers new value of elements in array + after the call +---*/ + +var result = false; +var arr = [1, 2, 3, 4, 5]; + +function callbackfn(val, Idx, obj) { + arr[4] = 6; + if (val >= 6) { + result = true; + } +} + +arr.forEach(callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-8.js new file mode 100644 index 0000000000..f51e436e8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-8.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - no observable effects occur if len is 0 +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +var obj = { + 0: 11, + 1: 12, + length: 0 +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-9.js new file mode 100644 index 0000000000..ea7e1ad1be --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-9.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - modifications to length don't change + number of iterations +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; +} + +var obj = { + 1: 12, + 2: 9, + length: 2 +}; + +Object.defineProperty(obj, "0", { + get: function() { + obj.length = 3; + return 11; + }, + configurable: true +}); + +Array.prototype.forEach.call(obj, callbackfn); + +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-1.js new file mode 100644 index 0000000000..70ea37fdaf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-1.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn not called for indexes never + been assigned values +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + callCnt++; +} + +var arr = new Array(10); +arr[1] = undefined; +arr.forEach(callbackfn); + +assert.sameValue(callCnt, 1, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-10.js new file mode 100644 index 0000000000..ac9a9d81d3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-10.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - deleting property of prototype causes + prototype index property not to be visited on an Array-like Object +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(val, idx, obj) { + accessed = true; + if (idx === 3) { + testResult = false; + } +} + +var obj = { + 2: 2, + length: 20 +}; + +Object.defineProperty(obj, "0", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-11.js new file mode 100644 index 0000000000..e0d9dfd150 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-11.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - deleting property of prototype causes + prototype index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var arr = [0, , ]; + +Object.defineProperty(arr, "0", { + get: function() { + delete Array.prototype[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; +arr.forEach(callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-12.js new file mode 100644 index 0000000000..38910365bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-12.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} + +var obj = { + 0: 0, + 1: 111, + length: 10 +}; + +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-13.js new file mode 100644 index 0000000000..cf28d94eba --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-13.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} +var arr = [0, 111]; + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; +arr.forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-14.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-14.js new file mode 100644 index 0000000000..d2f5569cd6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-14.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - decreasing length of array causes index + property not to be visited +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(val, idx, obj) { + accessed = true; + if (idx === 3) { + testResult = false; + } +} + +var arr = [0, 1, 2, "last"]; + +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); + +arr.forEach(callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-15.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-15.js new file mode 100644 index 0000000000..f62b2ac9ad --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-15.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - decreasing length of array with + prototype property causes prototype index property to be visited +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "prototype") { + testResult = true; + } +} +var arr = [0, 1, 2]; + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +arr.forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-16.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-16.js new file mode 100644 index 0000000000..f29cfd513a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-16.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - decreasing length of array does not + delete non-configurable properties +flags: [noStrict] +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "unconfigurable") { + testResult = true; + } +} + +var arr = [0, 1, 2]; + +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); + +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +arr.forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-2.js new file mode 100644 index 0000000000..abf2a576a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-2.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - added properties in step 2 are visible + here +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "length") { + testResult = true; + } +} + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + obj[2] = "length"; + return 3; + }, + configurable: true +}); + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-3.js new file mode 100644 index 0000000000..8e0f1cc5f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-3.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - deleted properties in step 2 are visible + here +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(val, idx, obj) { + accessed = true; + if (idx === 8) { + testResult = false; + } +} +var obj = { + 2: 6.99, + 8: 19 +}; + +Object.defineProperty(obj, "length", { + get: function() { + delete obj[8]; + return 10; + }, + configurable: true +}); + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-4.js new file mode 100644 index 0000000000..adcf620909 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-4.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - properties added into own object after + current position are visited on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} + +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(obj, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-5.js new file mode 100644 index 0000000000..d655dd4446 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-5.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - properties added into own object after + current position are visited on an Array +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +arr.forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-6.js new file mode 100644 index 0000000000..1d2e41de3d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-6.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - properties can be added to prototype + after current position are visited on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + testResult = true; + } +} + +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-7.js new file mode 100644 index 0000000000..7763aba2ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-7.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - properties can be added to prototype + after current position are visited on an Array +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + testResult = true; + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(Array.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +arr.forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-8.js new file mode 100644 index 0000000000..9a9280f206 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-8.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - deleting own property causes index + property not to be visited on an Array-like object +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); + +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-9.js new file mode 100644 index 0000000000..87215222d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-b-9.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - deleting own property causes index + property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var arr = [1, 2]; + +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +arr.forEach(callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-1.js new file mode 100644 index 0000000000..2429652961 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own data + property on an Array-like object +---*/ + +var kValue = {}; +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 5) { + testResult = (val === kValue); + } +} + +var obj = { + 5: kValue, + length: 100 +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-10.js new file mode 100644 index 0000000000..bb272475be --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-10.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property on an Array +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 2) { + testResult = (val === 12); + } +} + +var arr = []; + +Object.defineProperty(arr, "2", { + get: function() { + return 12; + }, + configurable: true +}); + +arr.forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-11.js new file mode 100644 index 0000000000..18dc9af824 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-11.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} + +var proto = { + 0: 5 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 10; + +Object.defineProperty(child, "0", { + get: function() { + return 11; + }, + configurable: true +}); + +Array.prototype.forEach.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-12.js new file mode 100644 index 0000000000..5b34577fdf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-12.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 111); + } +} + +var arr = []; + +Array.prototype[0] = 10; + +Object.defineProperty(arr, "0", { + get: function() { + return 111; + }, + configurable: true +}); + +arr.forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-13.js new file mode 100644 index 0000000000..7fb479567f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-13.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (val === 12); + } +} + +var proto = {}; + +Object.defineProperty(proto, "1", { + get: function() { + return 6; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 10; + +Object.defineProperty(child, "1", { + get: function() { + return 12; + }, + configurable: true +}); + + +Array.prototype.forEach.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-14.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-14.js new file mode 100644 index 0000000000..080e5935e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-14.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} + +var arr = []; + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 5; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + return 11; + }, + configurable: true +}); + +arr.forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-15.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-15.js new file mode 100644 index 0000000000..5740ee349d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-15.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (val === 11); + } +} + +var proto = {}; + +Object.defineProperty(proto, "1", { + get: function() { + return 11; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 20; + +Array.prototype.forEach.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-16.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-16.js new file mode 100644 index 0000000000..ea98a4d6b0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-16.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is inherited + accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 11; + }, + configurable: true +}); + +[, , , ].forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-17.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-17.js new file mode 100644 index 0000000000..d9bf6b0a33 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-17.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (typeof val === "undefined"); + } +} + +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-18.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-18.js new file mode 100644 index 0000000000..88a693c4cf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-18.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (typeof val === "undefined"); + } +} + +var arr = []; + +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +arr.forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-19.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-19.js new file mode 100644 index 0000000000..9f1fef59e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-19.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (typeof val === "undefined"); + } +} + +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); + +Object.defineProperty(Object.prototype, "1", { + get: function() { + return 10; + }, + configurable: true +}); + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-2.js new file mode 100644 index 0000000000..c4e3437176 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-2.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own data + property on an Array +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} + +[11].forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-20.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-20.js new file mode 100644 index 0000000000..bc7eece0d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-20.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (typeof val === "undefined"); + } +} + +var arr = []; + +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 100; + }, + configurable: true +}); + +arr.forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-21.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-21.js new file mode 100644 index 0000000000..65b1578f4b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-21.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (typeof val === "undefined"); + } +} + +var proto = {}; +Object.defineProperty(proto, "1", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; + +Array.prototype.forEach.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-22.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-22.js new file mode 100644 index 0000000000..030984b6ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-22.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (typeof val === "undefined"); + } +} + +Object.defineProperty(Array.prototype, "0", { + set: function() {}, + configurable: true +}); + +[, 1].forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-25.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-25.js new file mode 100644 index 0000000000..4bc4a559d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-25.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - This object is the Arguments object + which implements its own property get method (number of arguments + is less than number of parameters) +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} + +var func = function(a, b) { + return Array.prototype.forEach.call(arguments, callbackfn); +}; + +func(11); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-26.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-26.js new file mode 100644 index 0000000000..ad057763a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-26.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - This object is the Arguments object + which implements its own property get method (number of arguments + equals number of parameters) +---*/ + +var called = 0; +var testResult = false; + +function callbackfn(val, idx, obj) { + called++; + if (called !== 1 && !testResult) { + return; + } + if (idx === 0) { + testResult = (val === 11); + } else if (idx === 1) { + testResult = (val === 9); + } else { + testResult = false; + } +} + +var func = function(a, b) { + Array.prototype.forEach.call(arguments, callbackfn); +}; + +func(11, 9); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-27.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-27.js new file mode 100644 index 0000000000..df73d8e952 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-27.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - This object is the Arguments object + which implements its own property get method (number of arguments + is greater than number of parameters) +---*/ + +var called = 0; +var testResult = false; + +function callbackfn(val, idx, obj) { + called++; + if (called !== 1 && !testResult) { + return; + } + if (idx === 0) { + testResult = (val === 11); + } else if (idx === 1) { + testResult = (val === 12); + } else if (idx === 2) { + testResult = (val === 9); + } else { + testResult = false; + } +} + +var func = function(a, b) { + return Array.prototype.forEach.call(arguments, callbackfn); +}; + +func(11, 12, 9); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-28.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-28.js new file mode 100644 index 0000000000..abc425cba1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-28.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element changed by getter on previous + iterations is observed on an Array +---*/ + +var preIterVisible = false; +var arr = []; +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (val === 9); + } +} + +Object.defineProperty(arr, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 13; + } + }, + configurable: true +}); + +arr.forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-29.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-29.js new file mode 100644 index 0000000000..9305183494 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-29.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element changed by getter on previous + iterations is observed on an Array-like object +---*/ + +var preIterVisible = false; +var obj = { + length: 2 +}; +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (val === 9); + } +} + +Object.defineProperty(obj, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 13; + } + }, + configurable: true +}); + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-3.js new file mode 100644 index 0000000000..452169dd64 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-3.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var kValue = "abc"; +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 5) { + testResult = (val === kValue); + } +} + +var proto = { + 5: 100 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[5] = kValue; +child.length = 10; + +Array.prototype.forEach.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-30.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-30.js new file mode 100644 index 0000000000..a5f13d4a8f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-30.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - unnhandled exceptions happened in getter + terminate iteration on an Array-like object +---*/ + +var obj = { + 0: 11, + 5: 10, + 10: 8, + length: 20 +}; +var accessed = false; + +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } +} + +Object.defineProperty(obj, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); + +Object.defineProperty(obj, "2", { + get: function() { + accessed = true; + return 100; + }, + configurable: true +}); +assert.throws(RangeError, function() { + Array.prototype.forEach.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-31.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-31.js new file mode 100644 index 0000000000..ff02a77f42 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-31.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - unnhandled exceptions happened in getter + terminate iteration on an Array-like object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } +} + +var arr = []; +arr[5] = 10; +arr[10] = 100; + +Object.defineProperty(arr, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); + +Object.defineProperty(arr, "2", { + get: function() { + accessed = true; + return 100; + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.forEach(callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-4.js new file mode 100644 index 0000000000..77723a140d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-4.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 12); + } +} + +Array.prototype[0] = 11; + +[12].forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-5.js new file mode 100644 index 0000000000..28cd165e2f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-5.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} + +var proto = {}; + +Object.defineProperty(proto, "0", { + get: function() { + return 5; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +Object.defineProperty(child, "0", { + value: 11, + configurable: true +}); + +Array.prototype.forEach.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-6.js new file mode 100644 index 0000000000..ac934eb873 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-6.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 9; + }, + configurable: true +}); + +[11].forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-7.js new file mode 100644 index 0000000000..0305cacd69 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-7.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is inherited + data property on an Array-like object +---*/ + +var kValue = 'abc'; +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 5) { + testResult = (val === kValue); + } +} + +var proto = { + 5: kValue +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 10; + +Array.prototype.forEach.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-8.js new file mode 100644 index 0000000000..dc0ec1d057 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-8.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is inherited + data property on an Array +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (val === 13); + } +} + +Array.prototype[1] = 13; + +[, , , ].forEach(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-9.js new file mode 100644 index 0000000000..9d1965e41e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-9.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} + +var obj = { + 10: 10, + length: 20 +}; + +Object.defineProperty(obj, "0", { + get: function() { + return 11; + }, + configurable: true +}); + +Array.prototype.forEach.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-1.js new file mode 100644 index 0000000000..1f3b53eb79 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-1.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - callbackfn called with correct parameters +---*/ + +var bPar = true; +var bCalled = false; + +function callbackfn(val, idx, obj) +{ + bCalled = true; + if (obj[idx] !== val) + bPar = false; +} + +var arr = [0, 1, true, null, new Object(), "five"]; +arr[999999] = -6.6; +arr.forEach(callbackfn); + +assert.sameValue(bCalled, true, 'bCalled'); +assert.sameValue(bPar, true, 'bPar'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-10.js new file mode 100644 index 0000000000..99217f9bf4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-10.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn is called with 1 formal + parameter +---*/ + +var result = false; + +function callbackfn(val) { + result = (val > 10); +} + +[11].forEach(callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-11.js new file mode 100644 index 0000000000..a1a127ca15 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-11.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn is called with 2 formal + parameter +---*/ + +var result = false; + +function callbackfn(val, idx) { + result = (val > 10 && arguments[2][idx] === val); +} + +[11].forEach(callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-12.js new file mode 100644 index 0000000000..fb47d7acd2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-12.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn is called with 3 formal + parameter +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (val > 10 && obj[idx] === val); +} + +[11].forEach(callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-13.js new file mode 100644 index 0000000000..086f238342 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-13.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - callbackfn that uses arguments +---*/ + +var result = false; + +function callbackfn() { + result = (arguments[2][arguments[1]] === arguments[0]); +} + +[11].forEach(callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-16.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-16.js new file mode 100644 index 0000000000..a7c21f463c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-16.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - 'this' of 'callbackfn' is a Boolean + object when T is not an object (T is a boolean) +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (this.valueOf() !== false); +} + +var obj = { + 0: 11, + length: 2 +}; + +Array.prototype.forEach.call(obj, callbackfn, false); + +assert.sameValue(result, false, 'result'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-17.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-17.js new file mode 100644 index 0000000000..2e7607e51c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-17.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - 'this' of 'callbackfn' is a Number + object when T is not an object (T is a number) +---*/ + +var result = false; + +function callbackfn(val, idx, o) { + result = (5 === this.valueOf()); +} + +var obj = { + 0: 11, + length: 2 +}; + +Array.prototype.forEach.call(obj, callbackfn, 5); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-18.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-18.js new file mode 100644 index 0000000000..cf17e5b042 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-18.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - 'this' of 'callbackfn' is an String + object when T is not an object (T is a string) +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = ('hello' === this.valueOf()); +} + +var obj = { + 0: 11, + length: 2 +}; + +Array.prototype.forEach.call(obj, callbackfn, "hello"); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-19.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-19.js new file mode 100644 index 0000000000..245fc6dace --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-19.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - non-indexed properties are not called +---*/ + +var accessed = false; +var result = true; + +function callbackfn(val, idx, obj) { + accessed = true; + if (val === 8) { + result = false; + } +} + +var obj = { + 0: 11, + 10: 12, + non_index_property: 8, + length: 20 +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(result, 'result !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-2.js new file mode 100644 index 0000000000..2e5856e588 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-2.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - callbackfn takes 3 arguments +---*/ + +var parCnt = 3; +var bCalled = false + +function callbackfn(val, idx, obj) +{ + bCalled = true; + if (arguments.length !== 3) + parCnt = arguments.length; //verify if callbackfn was called with 3 parameters +} + +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +arr.forEach(callbackfn); + +assert.sameValue(bCalled, true, 'bCalled'); +assert.sameValue(parCnt, 3, 'parCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-20.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-20.js new file mode 100644 index 0000000000..e496519e96 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-20.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn called with correct + parameters (thisArg is correct) +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + result = (10 === this.threshold); +} + +var thisArg = { + threshold: 10 +}; + +var obj = { + 0: 11, + length: 1 +}; + +Array.prototype.forEach.call(obj, callbackfn, thisArg); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-21.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-21.js new file mode 100644 index 0000000000..3db90a4e84 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-21.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn called with correct + parameters (kValue is correct) +---*/ + +var resultOne = false; +var resultTwo = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + resultOne = (val === 11); + } + + if (idx === 1) { + resultTwo = (val === 12); + } + +} + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(resultOne, 'resultOne !== true'); +assert(resultTwo, 'resultTwo !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-22.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-22.js new file mode 100644 index 0000000000..5d985427a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-22.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn called with correct + parameters (the index k is correct) +---*/ + +var resultOne = false; +var resultTwo = false; + +function callbackfn(val, idx, obj) { + if (val === 11) { + resultOne = (idx === 0); + } + + if (val === 12) { + resultTwo = (idx === 1); + } + +} + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +Array.prototype.forEach.call(obj, callbackfn); + +assert(resultOne, 'resultOne !== true'); +assert(resultTwo, 'resultTwo !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-23.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-23.js new file mode 100644 index 0000000000..1a4e848648 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-23.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn called with correct + parameters (this object O is correct) +---*/ + +var result = false; +var obj = { + 0: 11, + length: 2 +}; + +function callbackfn(val, idx, o) { + result = (obj === o); +} + +Array.prototype.forEach.call(obj, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-4.js new file mode 100644 index 0000000000..0be07076bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-4.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - k values are passed in ascending numeric + order +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +var lastIdx = 0; +var called = 0; +var result = true; + +function callbackfn(val, idx, o) { + called++; + if (lastIdx !== idx) { + result = false; + } else { + lastIdx++; + } +} + +arr.forEach(callbackfn); + +assert(result, 'result !== true'); +assert.sameValue(arr.length, called, 'arr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-5.js new file mode 100644 index 0000000000..b2576859b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-5.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - k values are accessed during each + iteration and not prior to starting the loop on an Array +---*/ + +var result = true; +var kIndex = []; + +//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(val, idx, obj) { + //Each position should be visited one time, which means k is accessed one time during iterations. + if (typeof kIndex[idx] === "undefined") { + //when current position is visited, its previous index should has been visited. + if (idx !== 0 && typeof kIndex[idx - 1] === "undefined") { + result = false; + } + kIndex[idx] = 1; + } else { + result = false; + } +} + +[11, 12, 13, 14].forEach(callbackfn, undefined); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-6.js new file mode 100644 index 0000000000..725d0cfe81 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-6.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - arguments to callbackfn are self + consistent +---*/ + +var result = false; +var obj = { + 0: 11, + length: 1 +}; +var thisArg = {}; + +function callbackfn() { + result = (this === thisArg && + arguments[0] === 11 && + arguments[1] === 0 && + arguments[2] === obj); +} + +Array.prototype.forEach.call(obj, callbackfn, thisArg); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-7.js new file mode 100644 index 0000000000..412f00a381 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-7.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - unhandled exceptions happened in + callbackfn terminate iteration +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + if (idx > 0) { + accessed = true; + } + if (idx === 0) { + throw new Error("Exception occurred in callbackfn"); + } +} + +var obj = { + 0: 11, + 4: 10, + 10: 8, + length: 20 +}; +assert.throws(Error, function() { + Array.prototype.forEach.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-8.js new file mode 100644 index 0000000000..a6f9f43845 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-8.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element changed by callbackfn on + previous iterations is observed +---*/ + +var result = false; +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +function callbackfn(val, idx, o) { + if (idx === 0) { + obj[idx + 1] = 8; + } + + if (idx === 1) { + result = (val === 8); + } +} + +Array.prototype.forEach.call(obj, callbackfn); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-9.js new file mode 100644 index 0000000000..39f3a8822e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-9.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn is called with 0 formal + parameter +---*/ + +var called = 0; + +function callbackfn() { + called++; +} + +[11, 12].forEach(callbackfn); + +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-1.js new file mode 100644 index 0000000000..c31720f83e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-1.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (empty array) +---*/ + +var callCnt = 0; + +function cb() { + callCnt++ +} +var i = [].forEach(cb); + +assert.sameValue(callCnt, 0, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-10.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-10.js new file mode 100644 index 0000000000..e420981f80 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-10.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - subclassed array when length is reduced +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 1; + +var callCnt = 0; + +function cb() { + callCnt++ +} +var i = f.forEach(cb); + +assert.sameValue(callCnt, 1, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-11.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-11.js new file mode 100644 index 0000000000..7dfb750468 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-11.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't mutate the array on which it is + called on +---*/ + +function callbackfn(val, idx, obj) +{ + return true; +} +var arr = [1, 2, 3, 4, 5]; +arr.forEach(callbackfn); + +assert.sameValue(arr[0], 1, 'arr[0]'); +assert.sameValue(arr[1], 2, 'arr[1]'); +assert.sameValue(arr[2], 3, 'arr[2]'); +assert.sameValue(arr[3], 4, 'arr[3]'); +assert.sameValue(arr[4], 5, 'arr[4]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-12.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-12.js new file mode 100644 index 0000000000..d763c47310 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-12.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach doesn't visit expandos +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + callCnt++; +} +var arr = [1, 2, 3, 4, 5]; +arr["i"] = 10; +arr[true] = 11; + +arr.forEach(callbackfn); + +assert.sameValue(callCnt, 5, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-13.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-13.js new file mode 100644 index 0000000000..90614a656e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-13.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - undefined will be returned when 'len' is + 0 +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; +} + +var result = [].forEach(callbackfn); + +assert.sameValue(typeof result, "undefined", 'typeof result'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-2.js new file mode 100644 index 0000000000..1a23bdfd29 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-2.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden to null (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = null; + +var callCnt = 0; + +function cb() { + callCnt++ +} +var i = f.forEach(cb); + +assert.sameValue(callCnt, 0, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-3.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-3.js new file mode 100644 index 0000000000..91efb92f37 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-3.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden to false (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = false; + +var callCnt = 0; + +function cb() { + callCnt++ +} +var i = f.forEach(cb); + +assert.sameValue(callCnt, 0, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-4.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-4.js new file mode 100644 index 0000000000..a207068ae4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-4.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden to 0 (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 0; + +var callCnt = 0; + +function cb() { + callCnt++ +} +var i = f.forEach(cb); + +assert.sameValue(callCnt, 0, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-5.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-5.js new file mode 100644 index 0000000000..f9832c79d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-5.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden to '0' (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = '0'; + +var callCnt = 0; + +function cb() { + callCnt++ +} +var i = f.forEach(cb); + +assert.sameValue(callCnt, 0, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-6.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-6.js new file mode 100644 index 0000000000..e3663c28d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-6.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden with obj with valueOf) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; + +var callCnt = 0; + +function cb() { + callCnt++ +} +var i = f.forEach(cb); + +assert.sameValue(callCnt, 0, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-7.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-7.js new file mode 100644 index 0000000000..8e3ff6bc9a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-7.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden with obj w/o valueOf + (toString)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +var callCnt = 0; + +function cb() { + callCnt++ +} +var i = f.forEach(cb); + +assert.sameValue(callCnt, 0, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-8.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-8.js new file mode 100644 index 0000000000..0d12ee5fef --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-8.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden with [] +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +f.length = []; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +var callCnt = 0; + +function cb() { + callCnt++ +} +var i = f.forEach(cb); + +assert.sameValue(callCnt, 0, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-9.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-9.js new file mode 100644 index 0000000000..86b1401585 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/15.4.4.18-8-9.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden with [0] +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +f.length = [0]; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. + +var callCnt = 0; + +function cb() { + callCnt++ +} +var i = f.forEach(cb); + +assert.sameValue(callCnt, 0, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A1.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A1.js new file mode 100644 index 0000000000..1b43537136 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A1.js @@ -0,0 +1,14 @@ +// Copyright 2011 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: array.forEach can be frozen while in progress +esid: sec-array.prototype.foreach +description: Freezes array.forEach during a forEach to see if it works +---*/ + +['z'].forEach(function() { + Object.freeze(Array.prototype.forEach); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A2.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A2.js new file mode 100644 index 0000000000..9a0f116a3a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/S15.4.4.18_A2.js @@ -0,0 +1,17 @@ +// Copyright 2011 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: array.forEach can be frozen while in progress +esid: sec-array.prototype.foreach +description: Freezes array.forEach during a forEach to see if it works +---*/ + +function foo() { + ['z'].forEach(function() { + Object.freeze(Array.prototype.forEach); + }); +} +foo(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/browser.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/call-with-boolean.js new file mode 100644 index 0000000000..792044dc69 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/call-with-boolean.js @@ -0,0 +1,20 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.forEach +description: Array.prototype.forEach applied to boolean primitive +---*/ + +assert.sameValue( + Array.prototype.forEach.call(true, () => {}), + undefined, + 'Array.prototype.forEach.call(true, () => {}) must return undefined' +); +assert.sameValue( + Array.prototype.forEach.call(false, () => {}), + undefined, + 'Array.prototype.forEach.call(false, () => {}) must return undefined' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js new file mode 100644 index 0000000000..402b9a7007 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js @@ -0,0 +1,72 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.forEach +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.forEach.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + }); + + assert.compareArray(elements, expectedElements, 'elements (shrink)'); + assert.compareArray(indices, expectedIndices, 'indices (shrink)'); + assert.compareArray(arrays, expectedArrays, 'arrays (shrink)'); + assert.sameValue(result, undefined, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.forEach.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, undefined, 'result (grow)'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/length.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/length.js new file mode 100644 index 0000000000..8ca4a6185e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.forEach +description: > + The "length" property of Array.prototype.forEach +info: | + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.forEach.length, 1); + +verifyNotEnumerable(Array.prototype.forEach, 'length'); +verifyNotWritable(Array.prototype.forEach, 'length'); +verifyConfigurable(Array.prototype.forEach, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/name.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/name.js new file mode 100644 index 0000000000..08beb915e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach.name is "forEach". +info: | + Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.forEach.name, "forEach"); + +verifyNotEnumerable(Array.prototype.forEach, "name"); +verifyNotWritable(Array.prototype.forEach, "name"); +verifyConfigurable(Array.prototype.forEach, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/not-a-constructor.js new file mode 100644 index 0000000000..9662abaf98 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/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: > + Array.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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.forEach), + false, + 'isConstructor(Array.prototype.forEach) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.forEach(() => {}); +}, '`new Array.prototype.forEach(() => {})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/prop-desc.js new file mode 100644 index 0000000000..d26cffd102 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.forEach +description: > + "forEach" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.forEach, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "forEach"); +verifyWritable(Array.prototype, "forEach"); +verifyConfigurable(Array.prototype, "forEach"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/shell.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/shell.js new file mode 100644 index 0000000000..05fecd6ef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/shell.js @@ -0,0 +1,161 @@ +// GENERATED, DO NOT EDIT +// file: testTypedArray.js +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - floatArrayConstructors + - nonClampedIntArrayConstructors + - intArrayConstructors + - typedArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - nonAtomicsFriendlyTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +var floatArrayConstructors = [ + Float64Array, + Float32Array +]; + +var nonClampedIntArrayConstructors = [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array +]; + +var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]); + +// Float16Array is a newer feature +// adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it +if (typeof Float16Array !== 'undefined') { + floatArrayConstructors.push(Float16Array); +} + +/** + * Array containing every non-bigint typed array constructor. + */ + +var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]); +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} + +/** + * Checks if the given argument is one of the float-based TypedArray constructors. + * + * @param {constructor} ctor - the value to check + * @returns {boolean} + */ +function isFloatTypedArrayConstructor(arg) { + return floatArrayConstructors.indexOf(arg) !== -1; +} + +/** + * Determines the precision of the given float-based TypedArray constructor. + * + * @param {constructor} ctor - the value to check + * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively. + */ +function floatTypedArrayConstructorPrecision(FA) { + if (typeof Float16Array !== "undefined" && FA === Float16Array) { + return "half"; + } else if (FA === Float32Array) { + return "single"; + } else if (FA === Float64Array) { + return "double"; + } else { + throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray"); + } +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/browser.js b/js/src/tests/test262/built-ins/Array/prototype/includes/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/includes/call-with-boolean.js new file mode 100644 index 0000000000..ca044e76fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/call-with-boolean.js @@ -0,0 +1,17 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.includes +description: Array.prototype.includes applied to boolean primitive +features: [Array.prototype.includes] +---*/ + +assert.sameValue(Array.prototype.includes.call(true), false, 'Array.prototype.includes.call(true) must return false'); +assert.sameValue( + Array.prototype.includes.call(false), + false, + 'Array.prototype.includes.call(false) must return false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js b/js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js new file mode 100644 index 0000000000..94e21047a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js @@ -0,0 +1,26 @@ +// 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-array.prototype.includes +description: Return false if fromIndex >= ArrayLength +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + 5. If n ≥ 0, then + a. Let k be n. + ... + 7. Repeat, while k < len + ... + 8. Return false. +features: [Array.prototype.includes] +---*/ + +var sample = [7, 7, 7, 7]; +assert.sameValue(sample.includes(7, 4), false, "length"); +assert.sameValue(sample.includes(7, 5), false, "length + 1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-infinity.js b/js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-infinity.js new file mode 100644 index 0000000000..b54da632c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-infinity.js @@ -0,0 +1,37 @@ +// 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-array.prototype.includes +description: handle Infinity values for fromIndex +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + 5. If n ≥ 0, then + a. Let k be n. + 6. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 7. Repeat, while k < len + ... + 8. Return false. +features: [Array.prototype.includes] +---*/ + +var sample = [42, 43, 43, 41]; + +assert.sameValue( + sample.includes(43, Infinity), + false, + "includes(43, Infinity)" +); +assert.sameValue( + sample.includes(43, -Infinity), + true, + "includes(43, -Infinity)" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-minus-zero.js b/js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-minus-zero.js new file mode 100644 index 0000000000..5a58d0e358 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-minus-zero.js @@ -0,0 +1,24 @@ +// 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-array.prototype.includes +description: -0 fromIndex becomes 0 +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. Let k be n. + ... + 7. Repeat, while k < len + ... +features: [Array.prototype.includes] +---*/ + +var sample = [42, 43]; +assert.sameValue(sample.includes(42, -0), true, "-0 [0]"); +assert.sameValue(sample.includes(43, -0), true, "-0 [1]"); +assert.sameValue(sample.includes(44, -0), false, "-0 [2]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/get-prop.js b/js/src/tests/test262/built-ins/Array/prototype/includes/get-prop.js new file mode 100644 index 0000000000..572f4afe54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/get-prop.js @@ -0,0 +1,48 @@ +// 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-array.prototype.includes +description: get array-like indexed properties +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + ... +includes: [compareArray.js] +features: [Proxy, Array.prototype.includes] +---*/ + +var calls; + +var obj = {}; + +var p = new Proxy(obj, { + get: function(_, key) { + calls.push(key); + + if (key === "length") { + return 4; + } + + return key * 10; + } +}); + +calls = []; +assert.sameValue( + [].includes.call(p, 42), + false, + '[].includes.call("new Proxy(obj, {get: function(_, key) {calls.push(key); if (key === "length") {return 4;} return key * 10;}})", 42) must return false' +); +assert.compareArray(calls, ["length", "0", "1", "2", "3"], + 'The value of calls is expected to be ["length", "0", "1", "2", "3"]' +); + +calls = []; +assert.sameValue([].includes.call(p, 10), true, '[].includes.call("new Proxy(obj, {get: function(_, key) {calls.push(key); if (key === "length") {return 4;} return key * 10;}})", 10) must return true'); +assert.compareArray(calls, ["length", "0", "1"], 'The value of calls is expected to be ["length", "0", "1"]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/length-boundaries.js b/js/src/tests/test262/built-ins/Array/prototype/includes/length-boundaries.js new file mode 100644 index 0000000000..56811d9ca8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/length-boundaries.js @@ -0,0 +1,85 @@ +// 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-array.prototype.includes +description: length boundaries from ToLength operation +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... + + 7.1.15 ToLength ( argument ) + + 1. Let len be ? ToInteger(argument). + 2. If len ≤ +0, return +0. + 3. If len is +∞, return 2**53-1. + 4. Return min(len, 2**53-1). +features: [Array.prototype.includes] +---*/ + +var obj = { + "0": "a", + "1": "b", + "9007199254740990": "c", // 2 ** 53 - 2 + "9007199254740991": "d", // 2 ** 53 - 1 + "9007199254740992": "e", // 2 ** 53 +}; + +obj.length = -0; +assert.sameValue([].includes.call(obj, "a"), false, "-0"); + +obj.length = -1; +assert.sameValue([].includes.call(obj, "a"), false, "-1"); + +obj.length = -0.1; +assert.sameValue([].includes.call(obj, "a"), false, "-0.1"); + +obj.length = -Infinity; +assert.sameValue([].includes.call(obj, "a"), false, "-Infinity"); + +var fromIndex = 9007199254740990; + +obj.length = 9007199254740991; +assert.sameValue( + [].includes.call(obj, "c", fromIndex), + true, + "2**53-1, found value at 2**53-2" +); + +obj.length = 9007199254740991; +assert.sameValue( + [].includes.call(obj, "d", fromIndex), + false, + "2**53-1, ignores indexes >= 2**53-1" +); + +obj.length = 9007199254740992; +assert.sameValue( + [].includes.call(obj, "d", fromIndex), + false, + "2**53, ignores indexes >= 2**53-1" +); + +obj.length = 9007199254740993; +assert.sameValue( + [].includes.call(obj, "d", fromIndex), + false, + "2**53+1, ignores indexes >= 2**53-1" +); + +obj.length = Infinity; +assert.sameValue( + [].includes.call(obj, "c", fromIndex), + true, + "Infinity, found item" +); +assert.sameValue( + [].includes.call(obj, "d", fromIndex), + false, + "Infinity, ignores indexes >= 2**53-1" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/length-zero-returns-false.js b/js/src/tests/test262/built-ins/Array/prototype/includes/length-zero-returns-false.js new file mode 100644 index 0000000000..0911c7b02e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/length-zero-returns-false.js @@ -0,0 +1,30 @@ +// 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-array.prototype.includes +description: Returns false if length is 0 +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. If len is 0, return false. + ... +features: [Array.prototype.includes] +---*/ + +var calls = 0; +var fromIndex = { + valueOf: function() { + calls++; + } +}; + +var sample = []; +assert.sameValue(sample.includes(0), false, "returns false"); +assert.sameValue(sample.includes(), false, "returns false - no arg"); +assert.sameValue(sample.includes(0, fromIndex), false, "using fromIndex"); +assert.sameValue(calls, 0, "length is checked before ToInteger(fromIndex)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/length.js b/js/src/tests/test262/built-ins/Array/prototype/includes/length.js new file mode 100644 index 0000000000..e437df4d3c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/length.js @@ -0,0 +1,32 @@ +// 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-array.prototype.includes +description: > + Array.prototype.includes.length is 1. +info: | + Array.prototype.includes ( searchElement [ , fromIndex ] ) + + 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: [Array.prototype.includes] +---*/ + +assert.sameValue(Array.prototype.includes.length, 1); + +verifyNotEnumerable(Array.prototype.includes, "length"); +verifyNotWritable(Array.prototype.includes, "length"); +verifyConfigurable(Array.prototype.includes, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/name.js b/js/src/tests/test262/built-ins/Array/prototype/includes/name.js new file mode 100644 index 0000000000..c97a1fed91 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/name.js @@ -0,0 +1,29 @@ +// 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-array.prototype.includes +description: > + Array.prototype.includes.name is "includes". +info: | + Array.prototype.includes (searchElement [ , fromIndex ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Array.prototype.includes] +---*/ + +assert.sameValue(Array.prototype.includes.name, "includes"); + +verifyNotEnumerable(Array.prototype.includes, "name"); +verifyNotWritable(Array.prototype.includes, "name"); +verifyConfigurable(Array.prototype.includes, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/no-arg.js b/js/src/tests/test262/built-ins/Array/prototype/includes/no-arg.js new file mode 100644 index 0000000000..ead28581d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/no-arg.js @@ -0,0 +1,22 @@ +// 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-array.prototype.includes +description: no argument searches for a undefined value +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + ... +features: [Array.prototype.includes] +---*/ + +assert.sameValue([0].includes(), false, "[0].includes()"); +assert.sameValue([undefined].includes(), true, "[undefined].includes()"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/includes/not-a-constructor.js new file mode 100644 index 0000000000..0d673a9c31 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/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: > + Array.prototype.includes 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, arrow-function, Array.prototype.includes] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.includes), + false, + 'isConstructor(Array.prototype.includes) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.includes(1); +}, '`new Array.prototype.includes(1)` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/includes/prop-desc.js new file mode 100644 index 0000000000..73df81c82e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/prop-desc.js @@ -0,0 +1,19 @@ +// 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-array.prototype.includes +description: > + "includes" property of Array.prototype +info: | + ES6 section 17: Every other data property described in clauses 18 through 26 + and in Annex B.2 has the attributes { [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [Array.prototype.includes] +---*/ + +verifyNotEnumerable(Array.prototype, "includes"); +verifyWritable(Array.prototype, "includes"); +verifyConfigurable(Array.prototype, "includes"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-get-length.js b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-get-length.js new file mode 100644 index 0000000000..db90db38d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-get-length.js @@ -0,0 +1,28 @@ +// 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-array.prototype.includes +description: Return abrupt from Get(O, "length") +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... +features: [Array.prototype.includes] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + [].includes.call(obj, 7); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-get-prop.js b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-get-prop.js new file mode 100644 index 0000000000..14b1a49d47 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-get-prop.js @@ -0,0 +1,41 @@ +// 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-array.prototype.includes +description: Return abrupt getting index properties +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + ... +features: [Array.prototype.includes] +---*/ + +var stopped = 0; + +var obj = { + length: 3 +}; + +Object.defineProperty(obj, "1", { + get: function() { + throw new Test262Error(); + } +}); + +Object.defineProperty(obj, "2", { + get: function() { + stopped++; + } +}); + +assert.throws(Test262Error, function() { + [].includes.call(obj, 7); +}); + +assert.sameValue(stopped, 0, "It stops the loop after the abrupt completion"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js new file mode 100644 index 0000000000..34426017f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js @@ -0,0 +1,25 @@ +// 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-array.prototype.includes +description: Return abrupt from ToInteger(fromIndex) - using symbol +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + ... +features: [Symbol, Array.prototype.includes] +---*/ + +var fromIndex = Symbol("1"); + +var sample = [7]; + +assert.throws(TypeError, function() { + sample.includes(7, fromIndex); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tointeger-fromindex.js b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tointeger-fromindex.js new file mode 100644 index 0000000000..0ec1c60e4b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tointeger-fromindex.js @@ -0,0 +1,29 @@ +// 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-array.prototype.includes +description: Return abrupt from ToInteger(fromIndex) +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + ... +features: [Array.prototype.includes] +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var sample = [7]; + +assert.throws(Test262Error, function() { + sample.includes(7, fromIndex); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tonumber-length-symbol.js b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tonumber-length-symbol.js new file mode 100644 index 0000000000..d0d41dd0dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tonumber-length-symbol.js @@ -0,0 +1,24 @@ +// 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-array.prototype.includes +description: Return abrupt from ToNumber(symbol "length") +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... +features: [Symbol, Array.prototype.includes] +---*/ + +var obj = { + length: Symbol("1") +}; + +assert.throws(TypeError, function() { + [].includes.call(obj, 7); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tonumber-length.js b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tonumber-length.js new file mode 100644 index 0000000000..cfd5d6a024 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tonumber-length.js @@ -0,0 +1,40 @@ +// 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-array.prototype.includes +description: Return abrupt from ToNumber("length") +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... +features: [Array.prototype.includes] +---*/ + +var obj1 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; + +var obj2 = { + length: { + toString: function() { + throw new Test262Error(); + } + } +}; + +assert.throws(Test262Error, function() { + [].includes.call(obj1); +}, "valueOf"); + +assert.throws(Test262Error, function() { + [].includes.call(obj2); +}, "toString"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/samevaluezero.js b/js/src/tests/test262/built-ins/Array/prototype/includes/samevaluezero.js new file mode 100644 index 0000000000..091cfc72e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/samevaluezero.js @@ -0,0 +1,30 @@ +// 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-array.prototype.includes +description: search element is compared using SameValueZero +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + ... +features: [Array.prototype.includes] +---*/ + +var sample = [42, 0, 1, NaN]; +assert.sameValue(sample.includes("42"), false, "'42'"); +assert.sameValue(sample.includes([42]), false, "[42]"); +assert.sameValue(sample.includes(42.0), true, "42.0"); +assert.sameValue(sample.includes(-0), true, "-0"); +assert.sameValue(sample.includes(true), false, "true"); +assert.sameValue(sample.includes(false), false, "false"); +assert.sameValue(sample.includes(null), false, "null"); +assert.sameValue(sample.includes(""), false, "empty string"); +assert.sameValue(sample.includes(NaN), true, "NaN"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/search-found-returns-true.js b/js/src/tests/test262/built-ins/Array/prototype/includes/search-found-returns-true.js new file mode 100644 index 0000000000..c6f0bfd9a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/search-found-returns-true.js @@ -0,0 +1,43 @@ +// 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-array.prototype.includes +description: returns true for found index +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. Let k be n. + 6. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + ... +features: [Symbol, Array.prototype.includes] +---*/ + +var symbol = Symbol("1"); +var obj = {}; +var array = []; + +var sample = [42, "test262", null, undefined, true, false, 0, -1, "", symbol, obj, array]; + +assert.sameValue(sample.includes(42), true, "42"); +assert.sameValue(sample.includes("test262"), true, "'test262'"); +assert.sameValue(sample.includes(null), true, "null"); +assert.sameValue(sample.includes(undefined), true, "undefined"); +assert.sameValue(sample.includes(true), true, "true"); +assert.sameValue(sample.includes(false), true, "false"); +assert.sameValue(sample.includes(0), true, "0"); +assert.sameValue(sample.includes(-1), true, "-1"); +assert.sameValue(sample.includes(""), true, "the empty string"); +assert.sameValue(sample.includes(symbol), true, "symbol"); +assert.sameValue(sample.includes(obj), true, "obj"); +assert.sameValue(sample.includes(array), true, "array"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/search-not-found-returns-false.js b/js/src/tests/test262/built-ins/Array/prototype/includes/search-not-found-returns-false.js new file mode 100644 index 0000000000..aadd6db2c7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/search-not-found-returns-false.js @@ -0,0 +1,45 @@ +// 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-array.prototype.includes +description: returns false if the element is not found +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. Let k be n. + 6. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + 8. Return false. +features: [Symbol, Array.prototype.includes] +---*/ + +assert.sameValue([42].includes(43), false, "43"); + +assert.sameValue(["test262"].includes("test"), false, "string"); + +assert.sameValue([0, "test262", undefined].includes(""), false, "the empty string"); + +assert.sameValue(["true", false].includes(true), false, "true"); +assert.sameValue(["", true].includes(false), false, "false"); + +assert.sameValue([undefined, false, 0, 1].includes(null), false, "null"); +assert.sameValue([null].includes(undefined), false, "undefined"); + +assert.sameValue([Symbol("1")].includes(Symbol("1")), false, "symbol"); +assert.sameValue([{}].includes({}), false, "object"); +assert.sameValue([ + [] +].includes([]), false, "array"); + +var sample = [42]; +assert.sameValue(sample.includes(sample), false, "this"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/shell.js b/js/src/tests/test262/built-ins/Array/prototype/includes/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/sparse.js b/js/src/tests/test262/built-ins/Array/prototype/includes/sparse.js new file mode 100644 index 0000000000..96e0a6db14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/sparse.js @@ -0,0 +1,54 @@ +// 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-array.prototype.includes +description: Searches all indexes from a sparse array +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. Let k be n. + 6. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + ... +features: [Array.prototype.includes] +---*/ + +assert.sameValue( + [, , , ].includes(undefined), + true, + "[ , , , ].includes(undefined)" +); + +assert.sameValue( + [, , , 42, ].includes(undefined, 4), + false, + "[ , , , 42, ].includes(undefined, 4)" +); + +var sample = [, , , 42, , ]; + +assert.sameValue( + sample.includes(undefined), + true, + "sample.includes(undefined)" +); +assert.sameValue( + sample.includes(undefined, 4), + true, + "sample.includes(undefined, 4)" +); +assert.sameValue( + sample.includes(42, 3), + true, + "sample.includes(42, 3)" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/this-is-not-object.js b/js/src/tests/test262/built-ins/Array/prototype/includes/this-is-not-object.js new file mode 100644 index 0000000000..c19d2b24a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/this-is-not-object.js @@ -0,0 +1,25 @@ +// 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-array.prototype.includes +description: > + Throws a TypeError exception when `this` cannot be coerced to Object +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + 1. Let O be ? ToObject(this value). + ... +features: [Array.prototype.includes] +---*/ + +var includes = Array.prototype.includes; + +assert.throws(TypeError, function() { + includes.call(undefined, 42); +}, "this is undefined"); + +assert.throws(TypeError, function() { + includes.call(null, 42); +}, "this is null"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/tointeger-fromindex.js b/js/src/tests/test262/built-ins/Array/prototype/includes/tointeger-fromindex.js new file mode 100644 index 0000000000..3e62e6f620 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/tointeger-fromindex.js @@ -0,0 +1,55 @@ +// 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-array.prototype.includes +description: get the integer value from fromIndex +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + 5. If n ≥ 0, then + a. Let k be n. + ... + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + 8. Return false. +features: [Array.prototype.includes] +---*/ + +var obj = { + valueOf: function() { + return 1; + } +}; + +var sample = [42, 43]; +assert.sameValue(sample.includes(42, "1"), false, "string [0]"); +assert.sameValue(sample.includes(43, "1"), true, "string [1]"); + +assert.sameValue(sample.includes(42, true), false, "true [0]"); +assert.sameValue(sample.includes(43, true), true, "true [1]"); + +assert.sameValue(sample.includes(42, false), true, "false [0]"); +assert.sameValue(sample.includes(43, false), true, "false [1]"); + +assert.sameValue(sample.includes(42, NaN), true, "NaN [0]"); +assert.sameValue(sample.includes(43, NaN), true, "NaN [1]"); + +assert.sameValue(sample.includes(42, null), true, "null [0]"); +assert.sameValue(sample.includes(43, null), true, "null [1]"); + +assert.sameValue(sample.includes(42, undefined), true, "undefined [0]"); +assert.sameValue(sample.includes(43, undefined), true, "undefined [1]"); + +assert.sameValue(sample.includes(42, null), true, "null [0]"); +assert.sameValue(sample.includes(43, null), true, "null [1]"); + +assert.sameValue(sample.includes(42, obj), false, "object [0]"); +assert.sameValue(sample.includes(43, obj), true, "object [1]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/tolength-length.js b/js/src/tests/test262/built-ins/Array/prototype/includes/tolength-length.js new file mode 100644 index 0000000000..a2a2fec104 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/tolength-length.js @@ -0,0 +1,90 @@ +// 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-array.prototype.includes +description: length value coerced on ToLength +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... + + 7.1.15 ToLength ( argument ) + + 1. Let len be ? ToInteger(argument). + 2. If len ≤ +0, return +0. + 3. If len is +∞, return 253-1. + 4. Return min(len, 253-1). +features: [Array.prototype.includes] +---*/ + +var obj = { + "0": "a", + "1": "b" +}; + +obj.length = 0.1; +assert.sameValue([].includes.call(obj, "a"), false, "0.1"); + +obj.length = 0.99; +assert.sameValue([].includes.call(obj, "a"), false, "0.99"); + +obj.length = 1.00001; +assert.sameValue([].includes.call(obj, "a"), true, "1.00001"); + +obj.length = 1.1; +assert.sameValue([].includes.call(obj, "a"), true, "1.1"); + +obj.length = "0"; +assert.sameValue([].includes.call(obj, "a"), false, "string '0'"); + +obj.length = "1"; +assert.sameValue([].includes.call(obj, "a"), true, "string '1', item found"); + +obj.length = "1"; +assert.sameValue([].includes.call(obj, "b"), false, "string '1', item not found"); + +obj.length = "2"; +assert.sameValue([].includes.call(obj, "b"), true, "string '2', item found"); + +obj.length = ""; +assert.sameValue([].includes.call(obj, "a"), false, "the empty string"); + +obj.length = undefined; +assert.sameValue([].includes.call(obj, "a"), false, "undefined"); + +obj.length = NaN; +assert.sameValue([].includes.call(obj, "a"), false, "NaN"); + +obj.length = []; +assert.sameValue([].includes.call(obj, "a"), false, "[]"); + +obj.length = [1]; +assert.sameValue([].includes.call(obj, "a"), true, "[1]"); + +obj.length = null; +assert.sameValue([].includes.call(obj, "a"), false, "null"); + +obj.length = false; +assert.sameValue([].includes.call(obj, "a"), false, "false"); + +obj.length = true; +assert.sameValue([].includes.call(obj, "a"), true, "true"); + +obj.length = { + valueOf: function() { + return 2; + } +}; +assert.sameValue([].includes.call(obj, "b"), true, "ordinary object.valueOf"); + +obj.length = { + toString: function() { + return 2; + } +}; +assert.sameValue([].includes.call(obj, "b"), true, "ordinary object.toString"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/using-fromindex.js b/js/src/tests/test262/built-ins/Array/prototype/includes/using-fromindex.js new file mode 100644 index 0000000000..ea55845ba7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/using-fromindex.js @@ -0,0 +1,52 @@ +// 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-array.prototype.includes +description: Searches using fromIndex +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. Let k be n. + 6. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + ... +features: [Array.prototype.includes] +---*/ + +var sample = ["a", "b", "c"]; +assert.sameValue(sample.includes("a", 0), true, "includes('a', 0)"); +assert.sameValue(sample.includes("a", 1), false, "includes('a', 1)"); +assert.sameValue(sample.includes("a", 2), false, "includes('a', 2)"); + +assert.sameValue(sample.includes("b", 0), true, "includes('b', 0)"); +assert.sameValue(sample.includes("b", 1), true, "includes('b', 1)"); +assert.sameValue(sample.includes("b", 2), false, "includes('b', 2)"); + +assert.sameValue(sample.includes("c", 0), true, "includes('c', 0)"); +assert.sameValue(sample.includes("c", 1), true, "includes('c', 1)"); +assert.sameValue(sample.includes("c", 2), true, "includes('c', 2)"); + +assert.sameValue(sample.includes("a", -1), false, "includes('a', -1)"); +assert.sameValue(sample.includes("a", -2), false, "includes('a', -2)"); +assert.sameValue(sample.includes("a", -3), true, "includes('a', -3)"); +assert.sameValue(sample.includes("a", -4), true, "includes('a', -4)"); + +assert.sameValue(sample.includes("b", -1), false, "includes('b', -1)"); +assert.sameValue(sample.includes("b", -2), true, "includes('b', -2)"); +assert.sameValue(sample.includes("b", -3), true, "includes('b', -3)"); +assert.sameValue(sample.includes("b", -4), true, "includes('b', -4)"); + +assert.sameValue(sample.includes("c", -1), true, "includes('c', -1)"); +assert.sameValue(sample.includes("c", -2), true, "includes('c', -2)"); +assert.sameValue(sample.includes("c", -3), true, "includes('c', -3)"); +assert.sameValue(sample.includes("c", -4), true, "includes('c', -4)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/values-are-not-cached.js b/js/src/tests/test262/built-ins/Array/prototype/includes/values-are-not-cached.js new file mode 100644 index 0000000000..229e1f16da --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/values-are-not-cached.js @@ -0,0 +1,46 @@ +// 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-array.prototype.includes +description: indexed values are not cached +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + ... +features: [Array.prototype.includes] +---*/ + +function getCleanObj() { + var obj = {}; + Object.defineProperty(obj, "length", { + get: function() { + Object.defineProperty(obj, "0", { + get: function() { + obj[1] = "ecma262"; + obj[2] = "cake"; + return "tc39"; + } + }); + return 2; + } + }); + + return obj; +} + +var obj; +obj = getCleanObj(); +assert.sameValue([].includes.call(obj, "tc39"), true, "'tc39' is true"); + +obj = getCleanObj(); +assert.sameValue([].includes.call(obj, "ecma262"), true, "'ecma262' is true"); + +obj = getCleanObj(); +assert.sameValue([].includes.call(obj, "cake"), false, "'cake' is false"); +assert.sameValue(obj[2], "cake", "'2' is set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-1.js new file mode 100644 index 0000000000..11d3aa8be5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to undefined throws a TypeError +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.indexOf.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-10.js new file mode 100644 index 0000000000..932296e6d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-10.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to the Math object +---*/ + +Math[1] = true; +Math.length = 2; + +assert.sameValue(Array.prototype.indexOf.call(Math, true), 1, 'Array.prototype.indexOf.call(Math, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-11.js new file mode 100644 index 0000000000..2c9aabe034 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-11.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to Date object +---*/ + +var obj = new Date(); +obj.length = 2; +obj[1] = true; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-12.js new file mode 100644 index 0000000000..cf772580c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-12.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to RegExp object +---*/ + +var obj = new RegExp(); +obj.length = 2; +obj[1] = true; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-13.js new file mode 100644 index 0000000000..c5e93fd016 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-13.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to the JSON object +---*/ + +var targetObj = {}; + +JSON[3] = targetObj; +JSON.length = 5; + +assert.sameValue(Array.prototype.indexOf.call(JSON, targetObj), 3, 'Array.prototype.indexOf.call(JSON, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-14.js new file mode 100644 index 0000000000..914b39da96 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-14.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to Error object +---*/ + +var obj = new SyntaxError(); +obj[1] = true; +obj.length = 2; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-15.js new file mode 100644 index 0000000000..2574217a04 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-15.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to Arguments object +---*/ + +function fun() { + return arguments; +} +var obj = fun(1, true, 3); + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-2.js new file mode 100644 index 0000000000..ee6698db14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to null throws a TypeError +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.indexOf.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-3.js new file mode 100644 index 0000000000..3f5658031e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-3.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to boolean primitive +---*/ + +var targetObj = {}; + +Boolean.prototype[1] = targetObj; +Boolean.prototype.length = 2; + +assert.sameValue(Array.prototype.indexOf.call(true, targetObj), 1, 'Array.prototype.indexOf.call(true, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-4.js new file mode 100644 index 0000000000..f09918dd7f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-4.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to Boolean Object +---*/ + +var obj = new Boolean(false); +obj.length = 2; +obj[1] = true; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-5.js new file mode 100644 index 0000000000..5da413e931 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-5.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to number primitive +---*/ + +var targetObj = {}; + +Number.prototype[1] = targetObj; +Number.prototype.length = 2; + +assert.sameValue(Array.prototype.indexOf.call(5, targetObj), 1, 'Array.prototype.indexOf.call(5, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-6.js new file mode 100644 index 0000000000..9a33a67e19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-6.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to Number object +---*/ + +var obj = new Number(-3); +obj.length = 2; +obj[1] = true; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-7.js new file mode 100644 index 0000000000..153ac82af6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-7.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to string primitive +---*/ + +assert.sameValue(Array.prototype.indexOf.call("abc", "b"), 1, 'Array.prototype.indexOf.call("abc", "b")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-8.js new file mode 100644 index 0000000000..6b1a41b797 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-8.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to String object +---*/ + +var obj = new String("null"); + +assert.sameValue(Array.prototype.indexOf.call(obj, 'l'), 2, 'Array.prototype.indexOf.call(obj, "l")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-9.js new file mode 100644 index 0000000000..15dfa49518 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-1-9.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to Function object +---*/ + +var obj = function(a, b) { + return a + b; +}; +obj[1] = true; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-10-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-10-1.js new file mode 100644 index 0000000000..40f4f5b72d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-10-1.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 for elements not present in + array +---*/ + +var a = new Array(); +a[100] = 1; +a[99999] = ""; +a[10] = new Object(); +a[5555] = 5.5; +a[123456] = "str"; +a[5] = 1E+309; + +assert.sameValue(a.indexOf(1), 100, 'a.indexOf(1)'); +assert.sameValue(a.indexOf(""), 99999, 'a.indexOf("")'); +assert.sameValue(a.indexOf("str"), 123456, 'a.indexOf("str")'); +assert.sameValue(a.indexOf(1E+309), 5, 'a.indexOf(1E+309)'); //Infinity +assert.sameValue(a.indexOf(5.5), 5555, 'a.indexOf(5.5)'); + +assert.sameValue(a.indexOf(true), -1, 'a.indexOf(true)'); +assert.sameValue(a.indexOf(5), -1, 'a.indexOf(5)'); +assert.sameValue(a.indexOf("str1"), -1, 'a.indexOf("str1")'); +assert.sameValue(a.indexOf(null), -1, 'a.indexOf(null)'); +assert.sameValue(a.indexOf(new Object()), -1, 'a.indexOf(new Object())'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-10-2.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-10-2.js new file mode 100644 index 0000000000..ff0e89ed06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-10-2.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 and does not + access any other properties +---*/ + +var accessed = false; +var f = { + length: 0 +}; +Object.defineProperty(f, "0", { + get: function() { + accessed = true; + return 1; + } +}); + + +var i = Array.prototype.indexOf.call(f, 1); + + +assert.sameValue(i, -1, 'i'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-1.js new file mode 100644 index 0000000000..5f430eb93e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-1.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own data property on an + Array-like object +---*/ + +var objOne = { + 1: true, + length: 2 +}; +var objTwo = { + 2: true, + length: 2 +}; + +assert.sameValue(Array.prototype.indexOf.call(objOne, true), 1, 'Array.prototype.indexOf.call(objOne, true)'); +assert.sameValue(Array.prototype.indexOf.call(objTwo, true), -1, 'Array.prototype.indexOf.call(objTwo, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-10.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-10.js new file mode 100644 index 0000000000..d7a505975a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-10.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is inherited accessor property +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var childOne = new Con(); +childOne[1] = true; +var childTwo = new Con(); +childTwo[2] = true; + +assert.sameValue(Array.prototype.indexOf.call(childOne, true), 1, 'Array.prototype.indexOf.call(childOne, true)'); +assert.sameValue(Array.prototype.indexOf.call(childTwo, true), -1, 'Array.prototype.indexOf.call(childTwo, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-11.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-11.js new file mode 100644 index 0000000000..d876195f4a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-11.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own accessor property + without a get function +---*/ + +var obj = { + 1: true +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-12.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-12.js new file mode 100644 index 0000000000..5deb0792f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-12.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own accessor property + without a get function that overrides an inherited accessor + property +---*/ + +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 20; + }, + configurable: true +}); + +var obj = { + 1: 1 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(obj, 1), -1, 'Array.prototype.indexOf.call(obj, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-13.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-13.js new file mode 100644 index 0000000000..e5cc36b827 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-13.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is inherited accessor property + without a get function +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[1] = true; + +assert.sameValue(Array.prototype.indexOf.call(child, true), -1, 'Array.prototype.indexOf.call(child, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-14.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-14.js new file mode 100644 index 0000000000..a19d2b0bf2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-14.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is undefined property +---*/ + +var obj = { + 0: true, + 1: true +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-17.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-17.js new file mode 100644 index 0000000000..56d42df41f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-17.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf applied to Arguments object which + implements its own property get method +---*/ + +var func = function(a, b) { + arguments[2] = false; + return Array.prototype.indexOf.call(arguments, true) === 1 && + Array.prototype.indexOf.call(arguments, false) === -1; +}; + +assert(func(0, true), 'func(0, true) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-18.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-18.js new file mode 100644 index 0000000000..ed303ebe80 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-18.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf applied to String object, which implements + its own property get method +---*/ + +var str = new String("012"); + +String.prototype[3] = "3"; + +assert.sameValue(Array.prototype.indexOf.call(str, "2"), 2, 'Array.prototype.indexOf.call(str, "2")'); +assert.sameValue(Array.prototype.indexOf.call(str, "3"), -1, 'Array.prototype.indexOf.call(str, "3")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-19.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-19.js new file mode 100644 index 0000000000..2fa1f2a27b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-19.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf applied to Function object which + implements its own property get method +---*/ + +var obj = function(a, b) { + return a + b; +}; +obj[1] = "b"; +obj[2] = "c"; + +assert.sameValue(Array.prototype.indexOf.call(obj, obj[1]), 1, 'Array.prototype.indexOf.call(obj, obj[1])'); +assert.sameValue(Array.prototype.indexOf.call(obj, obj[2]), -1, 'Array.prototype.indexOf.call(obj, obj[2])'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-2.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-2.js new file mode 100644 index 0000000000..8960e5980d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-2.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is own data property on an Array +---*/ + +var targetObj = {}; + +Array.prototype[2] = targetObj; + + +assert.sameValue([0, targetObj].indexOf(targetObj), 1, '[0, targetObj].indexOf(targetObj)'); +assert.sameValue([0, 1].indexOf(targetObj), -1, '[0, 1].indexOf(targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-3.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-3.js new file mode 100644 index 0000000000..e1d5ca85fa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own data property that + overrides an inherited data property on an Array-like object +---*/ + +var proto = { + length: 0 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +child[1] = true; + +assert.sameValue(Array.prototype.indexOf.call(child, true), 1, 'Array.prototype.indexOf.call(child, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-4.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-4.js new file mode 100644 index 0000000000..0763674b85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-4.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own data property that + overrides an inherited data property on an Array +---*/ + +var targetObj = {}; +var arrProtoLen; + +arrProtoLen = Array.prototype.length; +Array.prototype.length = 0; + +assert.sameValue([0, targetObj].indexOf(targetObj), 1, '[0, targetObj].indexOf(targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-5.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-5.js new file mode 100644 index 0000000000..44cdad1edd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-5.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own data property that + overrides an inherited accessor property on an Array-like object +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 0; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[1] = true; + +assert.sameValue(Array.prototype.indexOf.call(child, true), 1, 'Array.prototype.indexOf.call(child, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-6.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-6.js new file mode 100644 index 0000000000..b33bf0b3cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-6.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is an inherited data property +---*/ + +var proto = { + length: 2 +}; + +var Con = function() {}; +Con.prototype = proto; + +var childOne = new Con(); +childOne[1] = true; +var childTwo = new Con(); +childTwo[2] = true; + +assert.sameValue(Array.prototype.indexOf.call(childOne, true), 1, 'Array.prototype.indexOf.call(childOne, true)'); +assert.sameValue(Array.prototype.indexOf.call(childTwo, true), -1, 'Array.prototype.indexOf.call(childTwo, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-7.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-7.js new file mode 100644 index 0000000000..4b30c60aca --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-7.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is own accessor property +---*/ + +var objOne = { + 1: true +}; +var objTwo = { + 2: true +}; +Object.defineProperty(objOne, "length", { + get: function() { + return 2; + }, + configurable: true +}); +Object.defineProperty(objTwo, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(objOne, true), 1, 'Array.prototype.indexOf.call(objOne, true)'); +assert.sameValue(Array.prototype.indexOf.call(objTwo, true), -1, 'Array.prototype.indexOf.call(objTwo, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-8.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-8.js new file mode 100644 index 0000000000..b0a5771654 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-8.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own accessor property that + overrides an inherited data property +---*/ + +var proto = { + length: 0 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[1] = true; + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(child, true), 1, 'Array.prototype.indexOf.call(child, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-9.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-9.js new file mode 100644 index 0000000000..cae4411018 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-2-9.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own accessor property that + overrides an inherited accessor property +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 0; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[1] = true; + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(child, true), 1, 'Array.prototype.indexOf.call(child, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-1.js new file mode 100644 index 0000000000..38c611d40a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-1.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - value of 'length' is undefined +---*/ + +var obj = { + 0: 1, + 1: 1, + length: undefined +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, 1), -1, 'Array.prototype.indexOf.call(obj, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-10.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-10.js new file mode 100644 index 0000000000..6f8df06b3e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-10.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is number primitive + (value is NaN) +---*/ + +var obj = { + 0: 0, + length: NaN +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, 0), -1, 'Array.prototype.indexOf.call(obj, 0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-11.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-11.js new file mode 100644 index 0000000000..8bcd52ab94 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-11.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is a string containing a + positive number +---*/ + +var obj = { + 1: 1, + 2: 2, + length: "2" +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, 1), 1, 'Array.prototype.indexOf.call(obj, 1)'); +assert.sameValue(Array.prototype.indexOf.call(obj, 2), -1, 'Array.prototype.indexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-12.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-12.js new file mode 100644 index 0000000000..684104f500 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-12.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is a string containing a + negative number +---*/ + +var obj = { + 1: "true", + 2: "2", + length: "-4294967294" +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, "true"), -1, 'Array.prototype.indexOf.call(obj, "true")'); +assert.sameValue(Array.prototype.indexOf.call(obj, "2"), -1, 'Array.prototype.indexOf.call(obj, "2")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-13.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-13.js new file mode 100644 index 0000000000..aca8a750c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-13.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is a string containing a + decimal number +---*/ + +var obj = { + 199: true, + 200: "200.59", + length: "200.59" +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 199, 'Array.prototype.indexOf.call(obj, true)'); +assert.sameValue(Array.prototype.indexOf.call(obj, "200.59"), -1, 'Array.prototype.indexOf.call(obj, "200.59")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-14.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-14.js new file mode 100644 index 0000000000..6a86141571 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-14.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is a string containing + +/-Infinity +---*/ + +var objOne = { + 0: true, + 1: true, + length: "Infinity" +}; +var objTwo = { + 0: true, + 1: true, + length: "+Infinity" +}; +var objThree = { + 0: true, + 1: true, + length: "-Infinity" +}; + +assert.sameValue(Array.prototype.indexOf.call(objOne, true), 0, 'Array.prototype.indexOf.call(objOne, true)'); +assert.sameValue(Array.prototype.indexOf.call(objTwo, true), 0, 'Array.prototype.indexOf.call(objTwo, true)'); +assert.sameValue(Array.prototype.indexOf.call(objThree, true), -1, 'Array.prototype.indexOf.call(objThree, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-15.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-15.js new file mode 100644 index 0000000000..481724876c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-15.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is a string containing an + exponential number +---*/ + +var obj = { + 1: true, + 2: "2E0", + length: "2E0" +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)'); +assert.sameValue(Array.prototype.indexOf.call(obj, "2E0"), -1, 'Array.prototype.indexOf.call(obj, "2E0")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-16.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-16.js new file mode 100644 index 0000000000..066d22de39 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-16.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is a string containing a hex + number +---*/ + +var obj = { + 10: true, + 11: "0x00B", + length: "0x00B" +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 10, 'Array.prototype.indexOf.call(obj, true)'); +assert.sameValue(Array.prototype.indexOf.call(obj, "0x00B"), -1, 'Array.prototype.indexOf.call(obj, "0x00B")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-17.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-17.js new file mode 100644 index 0000000000..58c9e6f383 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-17.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is a string containing a number + with leading zeros +---*/ + +var obj = { + 1: true, + 2: "0002.0", + length: "0002.0" +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)'); +assert.sameValue(Array.prototype.indexOf.call(obj, "0002.0"), -1, 'Array.prototype.indexOf.call(obj, "0002.0")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-18.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-18.js new file mode 100644 index 0000000000..c598a7a809 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-18.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a string that can't + convert to a number +---*/ + +var obj = { + 0: true, + 100: true, + length: "one" +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-19.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-19.js new file mode 100644 index 0000000000..f834b12a4d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-19.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is an Object which has + an own toString method. +---*/ + +// objects inherit the default valueOf() method from Object +// that simply returns itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. + +var obj = { + 1: true, + 2: 2, + + length: { + toString: function() { + return '2'; + } + } +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)'); +assert.sameValue(Array.prototype.indexOf.call(obj, 2), -1, 'Array.prototype.indexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-2.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-2.js new file mode 100644 index 0000000000..b438683c94 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-2.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf return -1 when 'length' is a boolean + (value is true) +---*/ + +var obj = { + 0: 0, + 1: 1, + length: true +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, 0), 0, 'Array.prototype.indexOf.call(obj, 0)'); +assert.sameValue(Array.prototype.indexOf.call(obj, 1), -1, 'Array.prototype.indexOf.call(obj, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-20.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-20.js new file mode 100644 index 0000000000..48791bba4f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-20.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is an Object which has + an own valueOf method. +---*/ + +//valueOf method will be invoked first, since hint is Number +var obj = { + 1: true, + 2: 2, + length: { + valueOf: function() { + return 2; + } + } +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)'); +assert.sameValue(Array.prototype.indexOf.call(obj, 2), -1, 'Array.prototype.indexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-21.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-21.js new file mode 100644 index 0000000000..fe7f644a30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-21.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is an object that has an own + valueOf method that returns an object and toString method that + returns a string +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var obj = { + 1: true, + length: { + toString: function() { + toStringAccessed = true; + return '2'; + }, + + valueOf: function() { + valueOfAccessed = true; + return {}; + } + } +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)'); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-22.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-22.js new file mode 100644 index 0000000000..8ac4dbac5f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-22.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf throws TypeError exception when 'length' + is an object with toString and valueOf methods that don�t return + primitive values +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var obj = { + length: { + toString: function() { + toStringAccessed = true; + return {}; + }, + + valueOf: function() { + valueOfAccessed = true; + return {}; + } + } +}; + +assert.throws(TypeError, function() { + Array.prototype.indexOf.call(obj); +}); + +assert(toStringAccessed, 'toStringAccessed'); +assert(valueOfAccessed, 'valueOfAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-23.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-23.js new file mode 100644 index 0000000000..68cf078ae0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-23.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf uses inherited valueOf method when + 'length' is an object with an own toString and inherited valueOf + methods +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return 2; +}; + +var obj = { + 1: true, + length: child +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-24.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-24.js new file mode 100644 index 0000000000..7cf673cc83 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-24.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +var obj = { + 122: true, + 123: false, + length: 123.321 +}; //length will be 123 finally + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 122, 'Array.prototype.indexOf.call(obj, true)'); +assert.sameValue(Array.prototype.indexOf.call(obj, false), -1, 'Array.prototype.indexOf.call(obj, false)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-25.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-25.js new file mode 100644 index 0000000000..a1bf7103ce --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-25.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a negative + non-integer +---*/ + +var obj = { + 1: true, + 2: false, + length: -4294967294.5 +}; //length will be 0 finally + +assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)'); +assert.sameValue(Array.prototype.indexOf.call(obj, false), -1, 'Array.prototype.indexOf.call(obj, false)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-28.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-28.js new file mode 100644 index 0000000000..e28525b7e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-28.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is boundary value + (2^32) +---*/ + +var targetObj = {}; +var obj = { + 0: targetObj, + 4294967294: targetObj, + 4294967295: targetObj, + length: 4294967296 +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), 0, 'Array.prototype.indexOf.call(obj, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-29.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-29.js new file mode 100644 index 0000000000..5995fcdea1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-29.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is boundary value + (2^32 + 1) +---*/ + +var targetObj = {}; +var obj = { + 0: targetObj, + 1: 4294967297, + length: 4294967297 +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), 0, 'Array.prototype.indexOf.call(obj, targetObj)'); +assert.sameValue(Array.prototype.indexOf.call(obj, 4294967297), 1, 'Array.prototype.indexOf.call(obj, 4294967297)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-3.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-3.js new file mode 100644 index 0000000000..8c3b35aee3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a number (value is + 0) +---*/ + +var obj = { + 0: true, + length: 0 +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-4.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-4.js new file mode 100644 index 0000000000..0b256c079b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-4.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a number (value is + +0) +---*/ + +var obj = { + 0: true, + length: +0 +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-5.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-5.js new file mode 100644 index 0000000000..eadd3f14ab --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-5.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a number (value is + -0) +---*/ + +var obj = { + 0: true, + length: -0 +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-6.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-6.js new file mode 100644 index 0000000000..4ce21bcb8d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-6.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a number (value is + positive) +---*/ + +var obj = { + 3: true, + 4: false, + length: 4 +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 3, 'Array.prototype.indexOf.call(obj, true)'); +assert.sameValue(Array.prototype.indexOf.call(obj, false), -1, 'Array.prototype.indexOf.call(obj, false)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-7.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-7.js new file mode 100644 index 0000000000..837a6e173c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-7.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a number (value is + negative) +---*/ + +var obj = { + 4: true, + 5: false, + length: 5 - Math.pow(2, 32) +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)'); +assert.sameValue(Array.prototype.indexOf.call(obj, false), -1, 'Array.prototype.indexOf.call(obj, false)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-8.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-8.js new file mode 100644 index 0000000000..ecd7ab5a23 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-8.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a number (value is + Infinity) +---*/ + +var obj = { + 0: 0, + length: Infinity +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, 0), 0, 'Array.prototype.indexOf.call(obj, 0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-9.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-9.js new file mode 100644 index 0000000000..f8b8d27f6f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-3-9.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a number (value is + -Infinity) +---*/ + +var obj = { + 0: 0, + length: -Infinity +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, 0), -1, 'Array.prototype.indexOf.call(obj, 0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-1.js new file mode 100644 index 0000000000..5662545bfe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf returns -1 if 'length' is 0 (empty array) +---*/ + +var i = [].indexOf(42); + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-10.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-10.js new file mode 100644 index 0000000000..852ab80528 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-10.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is a number of value -6e-1 +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: -6e-1 +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), -1, 'Array.prototype.indexOf.call(obj, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-11.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-11.js new file mode 100644 index 0000000000..29c47ac5f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-11.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is an empty string +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: "" +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), -1, 'Array.prototype.indexOf.call(obj, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-2.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-2.js new file mode 100644 index 0000000000..5ea615ce0c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-2.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 ( length + overridden to null (type conversion)) +---*/ + +var i = Array.prototype.indexOf.call({ + length: null +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-3.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-3.js new file mode 100644 index 0000000000..edf2191577 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 (length + overridden to false (type conversion)) +---*/ + +var i = Array.prototype.indexOf.call({ + length: false +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-4.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-4.js new file mode 100644 index 0000000000..bc3c408e4a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-4.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 (generic + 'array' with length 0 ) +---*/ + +var i = Array.prototype.indexOf.call({ + length: 0 +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-5.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-5.js new file mode 100644 index 0000000000..1c99c2fce5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-5.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 ( length + overridden to '0' (type conversion)) +---*/ + +var i = Array.prototype.indexOf.call({ + length: '0' +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-6.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-6.js new file mode 100644 index 0000000000..f907ebe0ad --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-6.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 (subclassed + Array, length overridden with obj with valueOf) +---*/ + +var i = Array.prototype.indexOf.call({ + length: { + valueOf: function() { + return 0; + } + } +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-7.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-7.js new file mode 100644 index 0000000000..c9b7d46cbe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-7.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 ( length is + object overridden with obj w/o valueOf (toString)) +---*/ + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +var i = Array.prototype.indexOf.call({ + length: { + toString: function() { + return '0'; + } + } +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-8.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-8.js new file mode 100644 index 0000000000..1d182ed052 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-8.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 (length is an + empty array) +---*/ + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +var i = Array.prototype.indexOf.call({ + length: [] +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-9.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-9.js new file mode 100644 index 0000000000..507aac7fcf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-4-9.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is a number of value 0.1 +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: 0.1 +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), -1, 'Array.prototype.indexOf.call(obj, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-1.js new file mode 100644 index 0000000000..0b535ee0a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf when fromIndex is string +---*/ + +var a = [1, 2, 1, 2, 1, 2]; + +assert.sameValue(a.indexOf(2, "2"), 3, '"2" resolves to 2'); +assert.sameValue(a.indexOf(2, "one"), 1, '"one" resolves to 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-10.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-10.js new file mode 100644 index 0000000000..d482884a09 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-10.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is positive number) +---*/ + +var targetObj = {}; + +assert.sameValue([0, targetObj, 2].indexOf(targetObj, 2), -1, '[0, targetObj, 2].indexOf(targetObj, 2)'); +assert.sameValue([0, 1, targetObj].indexOf(targetObj, 2), 2, '[0, 1, targetObj].indexOf(targetObj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-11.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-11.js new file mode 100644 index 0000000000..dffaa0859f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-11.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is negative number) +---*/ + +var targetObj = {}; + +assert.sameValue([0, targetObj, 2].indexOf(targetObj, -1), -1, '[0, targetObj, 2].indexOf(targetObj, -1)'); +assert.sameValue([0, 1, targetObj].indexOf(targetObj, -1), 2, '[0, 1, targetObj].indexOf(targetObj, -1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-12.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-12.js new file mode 100644 index 0000000000..2c3fd1e947 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-12.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is Infinity) +---*/ + +var arr = []; +arr[Math.pow(2, 32) - 2] = true; //length is the max value of Uint type + +assert.sameValue(arr.indexOf(true, Infinity), -1, 'arr.indexOf(true, Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-13.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-13.js new file mode 100644 index 0000000000..c144730ac2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-13.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is -Infinity) +---*/ + +assert.sameValue([true].indexOf(true, -Infinity), 0, '[true].indexOf(true, -Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-14.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-14.js new file mode 100644 index 0000000000..f7c424bda2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-14.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is NaN) +---*/ + +assert.sameValue([true].indexOf(true, NaN), 0, '[true].indexOf(true, NaN)'); +assert.sameValue([true].indexOf(true, -NaN), 0, '[true].indexOf(true, -NaN)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-15.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-15.js new file mode 100644 index 0000000000..555cb704a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-15.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a string + containing a negative number +---*/ + +assert.sameValue([0, true, 2].indexOf(true, "-1"), -1, '[0, true, 2].indexOf(true, "-1")'); +assert.sameValue([0, 1, true].indexOf(true, "-1"), 2, '[0, 1, true].indexOf(true, "-1")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-16.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-16.js new file mode 100644 index 0000000000..b10cf23ae8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-16.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a string + containing Infinity +---*/ + +var arr = []; +arr[Math.pow(2, 32) - 2] = true; //length is the max value of Uint type + +assert.sameValue(arr.indexOf(true, "Infinity"), -1, 'arr.indexOf(true, "Infinity")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-17.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-17.js new file mode 100644 index 0000000000..6229e6f0c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-17.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a string + containing -Infinity +---*/ + +assert.sameValue([true].indexOf(true, "-Infinity"), 0, '[true].indexOf(true, "-Infinity")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-18.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-18.js new file mode 100644 index 0000000000..4d02f2b9f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-18.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a string + containing an exponential number +---*/ + +var targetObj = {}; + +assert.sameValue([0, 1, targetObj, 3, 4].indexOf(targetObj, "3E0"), -1, '[0, 1, targetObj, 3, 4].indexOf(targetObj, "3E0")'); +assert.sameValue([0, 1, 2, targetObj, 4].indexOf(targetObj, "3E0"), 3, '[0, 1, 2, targetObj, 4].indexOf(targetObj, "3E0")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-19.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-19.js new file mode 100644 index 0000000000..34bbfb71ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-19.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a string + containing a hex number +---*/ + +var targetObj = {}; + +assert.sameValue([0, 1, targetObj, 3, 4].indexOf(targetObj, "0x0003"), -1, '[0, 1, targetObj, 3, 4].indexOf(targetObj, "0x0003")'); +assert.sameValue([0, 1, 2, targetObj, 4].indexOf(targetObj, "0x0003"), 3, '[0, 1, 2, targetObj, 4].indexOf(targetObj, "0x0003")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-2.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-2.js new file mode 100644 index 0000000000..13307e700a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-2.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf when fromIndex is floating point number +---*/ + +var a = new Array(1, 2, 3); + +assert.sameValue(a.indexOf(3, 0.49), 2, '0.49 resolves to 0'); +assert.sameValue(a.indexOf(1, 0.51), 0, '0.51 resolves to 0'); +assert.sameValue(a.indexOf(1, 1.51), -1, '1.51 resolves to 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-20.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-20.js new file mode 100644 index 0000000000..c8665ea766 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-20.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' which is a string + containing a number with leading zeros +---*/ + +var targetObj = {}; + +assert.sameValue([0, 1, targetObj, 3, 4].indexOf(targetObj, "0003.10"), -1, '[0, 1, targetObj, 3, 4].indexOf(targetObj, "0003.10")'); +assert.sameValue([0, 1, 2, targetObj, 4].indexOf(targetObj, "0003.10"), 3, '[0, 1, 2, targetObj, 4].indexOf(targetObj, "0003.10")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-21.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-21.js new file mode 100644 index 0000000000..363684cda1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-21.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is an Object, which + has an own toString method +---*/ + +// objects inherit the default valueOf() method from Object +// that simply returns itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +var fromIndex = { + toString: function() { + return '1'; + } +}; + +assert.sameValue([0, true].indexOf(true, fromIndex), 1, '[0, true].indexOf(true, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-22.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-22.js new file mode 100644 index 0000000000..0b0f1d4357 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-22.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is an Object, which + has an own valueOf method +---*/ + +var fromIndex = { + valueOf: function() { + return 1; + } +}; + + +assert.sameValue([0, true].indexOf(true, fromIndex), 1, '[0, true].indexOf(true, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-23.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-23.js new file mode 100644 index 0000000000..edc75cf561 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-23.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is an object that + has an own valueOf method that returns an object and toString + method that returns a string +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var fromIndex = { + toString: function() { + toStringAccessed = true; + return '1'; + }, + + valueOf: function() { + valueOfAccessed = true; + return {}; + } +}; + +assert.sameValue([0, true].indexOf(true, fromIndex), 1, '[0, true].indexOf(true, fromIndex)'); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-24.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-24.js new file mode 100644 index 0000000000..774b93121c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-24.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf throws TypeError exception when value of + 'fromIndex' is an object with toString and valueOf methods that + don�t return primitive values +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var fromIndex = { + toString: function() { + toStringAccessed = true; + return {}; + }, + + valueOf: function() { + valueOfAccessed = true; + return {}; + } +}; + +assert.throws(TypeError, function() { + [0, true].indexOf(true, fromIndex); +}); + +assert(toStringAccessed, 'toStringAccessed'); +assert(valueOfAccessed, 'valueOfAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-25.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-25.js new file mode 100644 index 0000000000..15a03f87d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-25.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf uses inherited valueOf method when value + of 'fromIndex' is an object with an own toString and inherited + valueOf methods +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 1; + } +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return 2; +}; + +assert.sameValue([0, true].indexOf(true, child), 1, '[0, true].indexOf(true, child)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-26.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-26.js new file mode 100644 index 0000000000..7ae507d893 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-26.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var stepTwoOccurs = false; +var stepFiveOccurs = false; + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + stepTwoOccurs = true; + if (stepFiveOccurs) { + throw new Error("Step 5 occurred out of order"); + } + return 20; + }, + configurable: true +}); + +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; + +Array.prototype.indexOf.call(obj, undefined, fromIndex); + +assert(stepTwoOccurs, 'stepTwoOccurs !== true'); +assert(stepFiveOccurs, 'stepFiveOccurs !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-27.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-27.js new file mode 100644 index 0000000000..922dea82be --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-27.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var stepThreeOccurs = false; +var stepFiveOccurs = false; + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + return { + valueOf: function() { + stepThreeOccurs = true; + if (stepFiveOccurs) { + throw new Error("Step 5 occurred out of order"); + } + return 20; + } + }; + }, + configurable: true +}); + +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; + +Array.prototype.indexOf.call(obj, undefined, fromIndex); + +assert(stepThreeOccurs, 'stepThreeOccurs !== true'); +assert(stepFiveOccurs, 'stepFiveOccurs !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-28.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-28.js new file mode 100644 index 0000000000..6a52b36f57 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-28.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - side effects produced by step 1 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(TypeError, function() { + Array.prototype.indexOf.call(undefined, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-29.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-29.js new file mode 100644 index 0000000000..9837ce9833 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-29.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + throw new RangeError(); + }, + configurable: true +}); + +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(RangeError, function() { + Array.prototype.indexOf.call(obj, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-3.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-3.js new file mode 100644 index 0000000000..809d6b28b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-3.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf when fromIndex is boolean +---*/ + +var a = [1, 2, 3]; + +assert.sameValue(a.indexOf(1, true), -1, 'true resolves to 1'); +assert.sameValue(a.indexOf(1, false), 0, 'false resolves to 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-30.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-30.js new file mode 100644 index 0000000000..c6a0f57084 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-30.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return { + valueOf: function() { + throw new TypeError(); + } + }; + }, + configurable: true +}); + +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(TypeError, function() { + Array.prototype.indexOf.call(obj, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-31.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-31.js new file mode 100644 index 0000000000..fa49ce4b90 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-31.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'fromIndex' is a positive non-integer, + verify truncation occurs in the proper direction +---*/ + +var targetObj = {}; + +assert.sameValue([0, targetObj, 2].indexOf(targetObj, 2.5), -1, '[0, targetObj, 2].indexOf(targetObj, 2.5)'); +assert.sameValue([0, 1, targetObj].indexOf(targetObj, 2.5), 2, '[0, 1, targetObj].indexOf(targetObj, 2.5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-32.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-32.js new file mode 100644 index 0000000000..60d3725ac0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-32.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'fromIndex' is a negative non-integer, + verify truncation occurs in the proper direction +---*/ + +var targetObj = {}; + +assert.sameValue([0, targetObj, 2].indexOf(targetObj, -1.5), -1, '[0, targetObj, 2].indexOf(targetObj, -1.5)'); +assert.sameValue([0, 1, targetObj].indexOf(targetObj, -1.5), 2, '[0, 1, targetObj].indexOf(targetObj, -1.5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-33.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-33.js new file mode 100644 index 0000000000..48b686415c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-33.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf match on the first element, a middle + element and the last element when 'fromIndex' is passed +---*/ + +assert.sameValue([0, 1, 2, 3, 4].indexOf(0, 0), 0, '[0, 1, 2, 3, 4].indexOf(0, 0)'); +assert.sameValue([0, 1, 2, 3, 4].indexOf(2, 1), 2, '[0, 1, 2, 3, 4].indexOf(2, 1)'); +assert.sameValue([0, 1, 2, 3, 4].indexOf(2, 2), 2, '[0, 1, 2, 3, 4].indexOf(2, 2)'); +assert.sameValue([0, 1, 2, 3, 4].indexOf(4, 2), 4, '[0, 1, 2, 3, 4].indexOf(4, 2)'); +assert.sameValue([0, 1, 2, 3, 4].indexOf(4, 4), 4, '[0, 1, 2, 3, 4].indexOf(4, 4)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-4.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-4.js new file mode 100644 index 0000000000..70edf91c2a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-4.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf returns 0 if fromIndex is 'undefined' +---*/ + +var a = [1, 2, 3]; + +// undefined resolves to 0 +assert.sameValue(a.indexOf(1, undefined), 0, 'a.indexOf(1,undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-5.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-5.js new file mode 100644 index 0000000000..f601f1675d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-5.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf returns 0 if fromIndex is null +---*/ + +var a = [1, 2, 3]; + +// null resolves to 0 +assert.sameValue(a.indexOf(1, null), 0, 'a.indexOf(1,null)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-6.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-6.js new file mode 100644 index 0000000000..274f417227 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-6.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'fromIndex' isn't passed +---*/ + +var arr = [0, 1, 2, 3, 4]; +//'fromIndex' will be set as 0 if not passed by default + +assert.sameValue(arr.indexOf(0), arr.indexOf(0, 0), 'arr.indexOf(0)'); +assert.sameValue(arr.indexOf(2), arr.indexOf(2, 0), 'arr.indexOf(2)'); +assert.sameValue(arr.indexOf(4), arr.indexOf(4, 0), 'arr.indexOf(4)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-7.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-7.js new file mode 100644 index 0000000000..2142402238 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-7.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is 0) +---*/ + +assert.sameValue([true].indexOf(true, 0), 0, '[true].indexOf(true, 0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-8.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-8.js new file mode 100644 index 0000000000..e694a870a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-8.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is +0) +---*/ + +assert.sameValue([true].indexOf(true, +0), 0, '[true].indexOf(true, +0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-9.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-9.js new file mode 100644 index 0000000000..c484140e30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-5-9.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is -0) +---*/ + +assert.sameValue([true].indexOf(true, -0), 0, '[true].indexOf(true, -0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-6-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-6-1.js new file mode 100644 index 0000000000..79aa1bd36d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-6-1.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if fromIndex is greater than + Array length +---*/ + +var a = [1, 2, 3]; + +assert.sameValue(a.indexOf(1, 5), -1, 'a.indexOf(1,5)'); +assert.sameValue(a.indexOf(1, 3), -1, 'a.indexOf(1,3)'); +assert.sameValue([].indexOf(1, 0), -1, '[ ].indexOf(1,0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-1.js new file mode 100644 index 0000000000..c03bf04af6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 when 'fromIndex' is length of + array - 1 +---*/ + +assert.sameValue([1, 2, 3].indexOf(1, 2), -1, '[1, 2, 3].indexOf(1, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-2.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-2.js new file mode 100644 index 0000000000..9a5e0fa89f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns correct index when 'fromIndex' is + length of array - 1 +---*/ + +assert.sameValue([1, 2, 3].indexOf(3, 2), 2, '[1, 2, 3].indexOf(3, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-3.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-3.js new file mode 100644 index 0000000000..f3a4585ca8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-3.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 when 'fromIndex' and 'length' + are both 0 +---*/ + +assert.sameValue([].indexOf(1, 0), -1, '[].indexOf(1, 0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-4.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-4.js new file mode 100644 index 0000000000..175ae99274 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-4.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf returns -1 when 'fromIndex' is 1 +---*/ + +assert.sameValue([1, 2, 3].indexOf(1, 1), -1, '[1, 2, 3].indexOf(1, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-5.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-5.js new file mode 100644 index 0000000000..8c7def228d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-7-5.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf returns correct index when 'fromIndex' is 1 +---*/ + +assert.sameValue([1, 2, 3].indexOf(2, 1), 1, '[1, 2, 3].indexOf(2, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-1.js new file mode 100644 index 0000000000..25c5b8043c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-1.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf with negative fromIndex +---*/ + +var a = new Array(1, 2, 3); + + +assert.sameValue(a.indexOf(2, -1), -1, 'a.indexOf(2,-1)'); +assert.sameValue(a.indexOf(2, -2), 1, 'a.indexOf(2,-2)'); +assert.sameValue(a.indexOf(1, -3), 0, 'a.indexOf(1,-3)'); +assert.sameValue(a.indexOf(1, -5.3), 0, 'a.indexOf(1,-5.3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-2.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-2.js new file mode 100644 index 0000000000..ec035415e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns correct index when 'fromIndex' is + -1 +---*/ + +assert.sameValue([1, 2, 3, 4].indexOf(4, -1), 3, '[1, 2, 3, 4].indexOf(4, -1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-3.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-3.js new file mode 100644 index 0000000000..a752d7ee45 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-3.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 when abs('fromIndex') is length + of array - 1 +---*/ + +assert.sameValue([1, 2, 3, 4].indexOf(1, -3), -1, '[1, 2, 3, 4].indexOf(1, -3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-4.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-4.js new file mode 100644 index 0000000000..c0fe6e7a36 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-8-4.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 when abs('fromIndex') is length + of array +---*/ + +assert.sameValue([1, 2, 3, 4].indexOf(0, -4), -1, '[1, 2, 3, 4].indexOf(0, -4)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-1.js new file mode 100644 index 0000000000..a5ad6f9702 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-1.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index (boolean) +---*/ + +var obj = { + toString: function() { + return true + } +}; +var _false = false; +var a = [obj, "true", undefined, 0, _false, null, 1, "str", 0, 1, true, false, true, false]; + +assert.sameValue(a.indexOf(true), 10, 'a[10]=true'); +assert.sameValue(a.indexOf(false), 4, 'a[4] =_false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-10.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-10.js new file mode 100644 index 0000000000..cfe1a6290b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-10.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + note that prior to the finally ES5 draft SameValue was used for comparisions + and hence NaNs could be found using indexOf * +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index (NaN) +---*/ + +var _NaN = NaN; +var a = new Array("NaN", undefined, 0, false, null, { + toString: function() { + return NaN + } +}, "false", _NaN, NaN); + +assert.sameValue(a.indexOf(NaN), -1, 'NaN is equal to nothing, including itself.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-11.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-11.js new file mode 100644 index 0000000000..65cab9d813 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-11.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - the length of iteration isn't changed by + adding elements to the array during iteration +---*/ + +var arr = [20]; + +Object.defineProperty(arr, "0", { + get: function() { + arr[1] = 1; + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.indexOf(1), -1, 'arr.indexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-2.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-2.js new file mode 100644 index 0000000000..5250eb36d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-2.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index (Number) +---*/ + +var obj = { + toString: function() { + return 0 + } +}; +var one = 1; +var _float = -(4 / 3); +var a = new Array(false, undefined, null, "0", obj, -1.3333333333333, "str", -0, true, +0, one, 1, 0, false, _float, -(4 / 3)); + +assert.sameValue(a.indexOf(-(4 / 3)), 14, 'a[14]=_float===-(4/3)'); +assert.sameValue(a.indexOf(0), 7, 'a[7] = +0, 0===+0'); +assert.sameValue(a.indexOf(-0), 7, 'a[7] = +0, -0===+0'); +assert.sameValue(a.indexOf(1), 10, 'a[10] =one=== 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-3.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-3.js new file mode 100644 index 0000000000..ba35d284e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-3.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index(string) +---*/ + +var obj = { + toString: function() { + return "false" + } +}; +var szFalse = "false"; +var a = new Array("false1", undefined, 0, false, null, 1, obj, 0, szFalse, "false"); + +assert.sameValue(a.indexOf("false"), 8, 'a[8]=szFalse'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-4.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-4.js new file mode 100644 index 0000000000..daef7b2fe5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-4.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index(undefined) +---*/ + +var obj = { + toString: function() { + return undefined; + } +}; +var _undefined1 = undefined; +var _undefined2; +var a = new Array(true, 0, false, null, 1, "undefined", obj, 1, _undefined2, _undefined1, undefined); + +assert.sameValue(a.indexOf(undefined), 8, 'a[8]=_undefined2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-5.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-5.js new file mode 100644 index 0000000000..58a61bda0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-5.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index (Object) +---*/ + +var obj1 = { + toString: function() { + return "false" + } +}; +var obj2 = { + toString: function() { + return "false" + } +}; +var obj3 = obj1; +var a = new Array(false, undefined, 0, false, null, { + toString: function() { + return "false" + } +}, "false", obj2, obj1, obj3); + +assert.sameValue(a.indexOf(obj3), 8, 'a[8] = obj1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-6.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-6.js new file mode 100644 index 0000000000..45f95bb47b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-6.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index(null) +---*/ + +var obj = { + toString: function() { + return null + } +}; +var _null = null; +var a = new Array(true, undefined, 0, false, _null, 1, "str", 0, 1, obj, true, false, null); + +assert.sameValue(a.indexOf(null), 4, 'a[4]=_null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-7.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-7.js new file mode 100644 index 0000000000..a686df3320 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-7.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index (self reference) +---*/ + +var a = new Array(0, 1, 2, 3); +a[2] = a; + +assert.sameValue(a.indexOf(a), 2, 'a.indexOf(a)'); +assert.sameValue(a.indexOf(3), 3, 'a.indexOf(3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-8.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-8.js new file mode 100644 index 0000000000..14a34fd1e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-8.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index (Array) +---*/ + +var b = new Array("0,1"); +var a = new Array(0, b, "0,1", 3); + +assert.sameValue(a.indexOf(b.toString()), 2, 'a.indexOf(b.toString())'); +assert.sameValue(a.indexOf("0,1"), 2, 'a.indexOf("0,1")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-9.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-9.js new file mode 100644 index 0000000000..60c04f3105 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-9.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index (Sparse Array) +---*/ + +var a = new Array(0, 1); +a[4294967294] = 2; // 2^32-2 - is max array element +a[4294967295] = 3; // 2^32-1 added as non-array element property +a[4294967296] = 4; // 2^32 added as non-array element property +a[4294967297] = 5; // 2^32+1 added as non-array element property + +// start searching near the end so in case implementation actually tries to test all missing elements!! + +assert.sameValue(a.indexOf(2, 4294967290), 4294967294, 'a.indexOf(2,4294967290 )'); +assert.sameValue(a.indexOf(3, 4294967290), -1, 'a.indexOf(3,4294967290)'); +assert.sameValue(a.indexOf(4, 4294967290), -1, 'a.indexOf(4,4294967290)'); +assert.sameValue(a.indexOf(5, 4294967290), -1, 'a.indexOf(5,4294967290)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-1.js new file mode 100644 index 0000000000..eeb1da1da2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-1.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - added properties in step 2 are visible + here +---*/ + +var arr = {}; + +Object.defineProperty(arr, "length", { + get: function() { + arr[2] = "length"; + return 3; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(arr, "length"), 2, 'Array.prototype.indexOf.call(arr, "length")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-10.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-10.js new file mode 100644 index 0000000000..ddd98f4e79 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-10.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - properties can be added to prototype + after current position are visited on an Array +---*/ + +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(Array.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.indexOf(6.99), 1, 'arr.indexOf(6.99)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-11.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-11.js new file mode 100644 index 0000000000..a95e31b11c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-11.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleting own property causes index + property not to be visited on an Array-like object +---*/ + +var arr = { + length: 2 +}; + +Object.defineProperty(arr, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(arr, 6.99), -1, 'Array.prototype.indexOf.call(arr, 6.99)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-12.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-12.js new file mode 100644 index 0000000000..4c503906c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-12.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleting own property causes index + property not to be visited on an Array +---*/ + +var arr = [1, 2]; + +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.indexOf("6.99"), -1, 'arr.indexOf("6.99")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-13.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-13.js new file mode 100644 index 0000000000..ddd10125cb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-13.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleting property of prototype causes + prototype index property not to be visited on an Array-like Object +---*/ + +var arr = { + 2: 2, + length: 20 +}; + +Object.defineProperty(arr, "0", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; + +assert.sameValue(Array.prototype.indexOf.call(arr, 1), -1, 'Array.prototype.indexOf.call(arr, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-14.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-14.js new file mode 100644 index 0000000000..1edbff8d55 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-14.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleting property of prototype causes + prototype index property not to be visited on an Array +---*/ + +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + delete Array.prototype[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; + +assert.sameValue(arr.indexOf(1), -1, 'arr.indexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-15.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-15.js new file mode 100644 index 0000000000..34d437b0a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-15.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +var arr = { + 0: 0, + 1: 111, + 2: 2, + length: 10 +}; + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; + +assert.sameValue(Array.prototype.indexOf.call(arr, 1), 1, 'Array.prototype.indexOf.call(arr, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-16.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-16.js new file mode 100644 index 0000000000..90f84f8c48 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-16.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +var arr = [0, 111, 2]; + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; + +assert.sameValue(arr.indexOf(1), 1, 'arr.indexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-17.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-17.js new file mode 100644 index 0000000000..07cfc468c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-17.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - decreasing length of array causes index + property not to be visited +---*/ + +var arr = [0, 1, 2, "last"]; + +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.indexOf("last"), -1, 'arr.indexOf("last")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-18.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-18.js new file mode 100644 index 0000000000..f258c5b498 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-18.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - decreasing length of array with + prototype property causes prototype index property to be visited +---*/ + +var arr = [0, 1, 2]; + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +assert.sameValue(arr.indexOf("prototype"), 2, 'arr.indexOf("prototype")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-19.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-19.js new file mode 100644 index 0000000000..4bf02ee442 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-19.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - decreasing length of array does not + delete non-configurable properties +flags: [noStrict] +---*/ + +var arr = [0, 1, 2]; + +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); + +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + + +assert.sameValue(arr.indexOf("unconfigurable"), 2, 'arr.indexOf("unconfigurable")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-2.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-2.js new file mode 100644 index 0000000000..50387482e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-2.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - added properties in step 5 are visible + here on an Array-like object +---*/ + +var arr = { + length: 30 +}; +var targetObj = function() {}; + +var fromIndex = { + valueOf: function() { + arr[4] = targetObj; + return 3; + } +}; + + +assert.sameValue(Array.prototype.indexOf.call(arr, targetObj, fromIndex), 4, 'Array.prototype.indexOf.call(arr, targetObj, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-3.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-3.js new file mode 100644 index 0000000000..a030847c3f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - added properties in step 5 are visible + here on an Array +---*/ + +var arr = []; +arr.length = 30; +var targetObj = function() {}; + +var fromIndex = { + valueOf: function() { + arr[4] = targetObj; + return 3; + } +}; + +assert.sameValue(arr.indexOf(targetObj, fromIndex), 4, 'arr.indexOf(targetObj, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-4.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-4.js new file mode 100644 index 0000000000..ad0b3b53e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-4.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleted properties in step 2 are visible + here +---*/ + +var arr = { + 2: 6.99 +}; + +Object.defineProperty(arr, "length", { + get: function() { + delete arr[2]; + return 3; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(arr, 6.99), -1, 'Array.prototype.indexOf.call(arr, 6.99)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-5.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-5.js new file mode 100644 index 0000000000..3bfd0240fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-5.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleted properties in step 5 are visible + here on an Array-like object +---*/ + +var arr = { + 10: false, + length: 30 +}; + +var fromIndex = { + valueOf: function() { + delete arr[10]; + return 3; + } +}; + +assert.sameValue(Array.prototype.indexOf.call(arr, false, fromIndex), -1, 'Array.prototype.indexOf.call(arr, false, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-6.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-6.js new file mode 100644 index 0000000000..64b13aec12 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-6.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleted properties in step 5 are visible + here on an Array +---*/ + +var arr = []; +arr[10] = "10"; +arr.length = 20; + +var fromIndex = { + valueOf: function() { + delete arr[10]; + return 3; + } +}; + +assert.sameValue(arr.indexOf("10", fromIndex), -1, 'arr.indexOf("10", fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-7.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-7.js new file mode 100644 index 0000000000..5f6a0306d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-7.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - properties added into own object after + current position are visited on an Array-like object +---*/ + +var arr = { + length: 2 +}; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(arr, 1), 1, 'Array.prototype.indexOf.call(arr, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-8.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-8.js new file mode 100644 index 0000000000..fbc2ae6059 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-8.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - properties added into own object after + current position are visited on an Array +---*/ + +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.indexOf(1), 1, 'arr.indexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-9.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-9.js new file mode 100644 index 0000000000..15ced96952 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-a-9.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - properties can be added to prototype + after current position are visited on an Array-like object +---*/ + +var arr = { + length: 2 +}; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(arr, 6.99), 1, 'Array.prototype.indexOf.call(arr, 6.99)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-1.js new file mode 100644 index 0000000000..0ca9e77463 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-1.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - non-existent property wouldn't be called +---*/ + +assert.sameValue([0, , 2].indexOf(undefined), -1, '[0, , 2].indexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-1.js new file mode 100644 index 0000000000..1307ae7afa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-1.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own data + property on an Array-like object +---*/ + +var obj = { + 0: 0, + 1: 1, + 2: 2, + length: 3 +}; + +assert.sameValue(Array.prototype.indexOf.call(obj, 0), 0, 'Array.prototype.indexOf.call(obj, 0)'); +assert.sameValue(Array.prototype.indexOf.call(obj, 1), 1, 'Array.prototype.indexOf.call(obj, 1)'); +assert.sameValue(Array.prototype.indexOf.call(obj, 2), 2, 'Array.prototype.indexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-10.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-10.js new file mode 100644 index 0000000000..96ea7e5005 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-10.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property on an Array-like object +---*/ + +var obj = { + length: 3 +}; +Object.defineProperty(obj, "0", { + get: function() { + return 0; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +Object.defineProperty(obj, "2", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(obj, 0), 0, 'Array.prototype.indexOf.call(obj, 0)'); +assert.sameValue(Array.prototype.indexOf.call(obj, 1), 1, 'Array.prototype.indexOf.call(obj, 1)'); +assert.sameValue(Array.prototype.indexOf.call(obj, 2), 2, 'Array.prototype.indexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-11.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-11.js new file mode 100644 index 0000000000..0343a6c327 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-11.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +var arr = []; + +Array.prototype[0] = false; +Object.defineProperty(arr, "0", { + get: function() { + return true; + }, + configurable: true +}); + +assert.sameValue(arr.indexOf(true), 0, 'arr.indexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-12.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-12.js new file mode 100644 index 0000000000..73d18383d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-12.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +var obj = { + length: 1 +}; + +Object.prototype[0] = false; +Object.defineProperty(obj, "0", { + get: function() { + return true; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 0, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-13.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-13.js new file mode 100644 index 0000000000..0012f6e311 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-13.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +var arr = []; + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + return true; + }, + configurable: true +}); + +assert.sameValue(arr.indexOf(true), 0, 'arr.indexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-14.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-14.js new file mode 100644 index 0000000000..74e757e7a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-14.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var obj = { + length: 1 +}; + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); + +Object.defineProperty(obj, "0", { + get: function() { + return true; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 0, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-15.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-15.js new file mode 100644 index 0000000000..26704a212e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-15.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is inherited + accessor property on an Array +---*/ + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 10; + }, + configurable: true +}); + +Object.defineProperty(Array.prototype, "1", { + get: function() { + return 20; + }, + configurable: true +}); + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return 30; + }, + configurable: true +}); + +assert.sameValue([, , , ].indexOf(10), 0, '[, , , ].indexOf(10)'); +assert.sameValue([, , , ].indexOf(20), 1, '[, , , ].indexOf(20)'); +assert.sameValue([, , , ].indexOf(30), 2, '[, , , ].indexOf(30)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-16.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-16.js new file mode 100644 index 0000000000..bc2fb17e56 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-16.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return 10; + }, + configurable: true +}); + +Object.defineProperty(Object.prototype, "1", { + get: function() { + return 20; + }, + configurable: true +}); + +Object.defineProperty(Object.prototype, "2", { + get: function() { + return 30; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call({ + length: 3 +}, 10), 0, 'Array.prototype.indexOf.call({ length: 3 }, 10)'); +assert.sameValue(Array.prototype.indexOf.call({ + length: 3 +}, 20), 1, 'Array.prototype.indexOf.call({ length: 3 }, 20)'); +assert.sameValue(Array.prototype.indexOf.call({ + length: 3 +}, 30), 2, 'Array.prototype.indexOf.call({ length: 3 }, 30)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-17.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-17.js new file mode 100644 index 0000000000..2f3130b034 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-17.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +assert.sameValue(arr.indexOf(undefined), 0, 'arr.indexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-18.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-18.js new file mode 100644 index 0000000000..56c27077e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-18.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +var obj = { + length: 1 +}; +Object.defineProperty(obj, "0", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(obj, undefined), 0, 'Array.prototype.indexOf.call(obj, undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-19.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-19.js new file mode 100644 index 0000000000..c0f708a2fa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-19.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +var arr = []; + +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(arr.indexOf(undefined), 0, 'arr.indexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-2.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-2.js new file mode 100644 index 0000000000..d06628706e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-2.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own data + property on an Array +---*/ + +assert.sameValue([true, true, true].indexOf(true), 0, '[true, true, true].indexOf(true)'); +assert.sameValue([false, true, true].indexOf(true), 1, '[false, true, true].indexOf(true)'); +assert.sameValue([false, false, true].indexOf(true), 2, '[false, false, true].indexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-20.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-20.js new file mode 100644 index 0000000000..105908b5ba --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-20.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +var proto = {}; +Object.defineProperty(proto, "0", { + get: function() { + return 2; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 1; + +Object.defineProperty(child, "0", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(child, undefined), 0, 'Array.prototype.indexOf.call(child, undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-21.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-21.js new file mode 100644 index 0000000000..7b237f90b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-21.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +Object.defineProperty(Array.prototype, "0", { + set: function() {}, + configurable: true +}); + +assert.sameValue([, ].indexOf(undefined), 0, '[, ].indexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-22.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-22.js new file mode 100644 index 0000000000..b1226745a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-22.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call({ + length: 1 +}, undefined), 0, 'Array.prototype.indexOf.call({ length: 1 }, undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-25.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-25.js new file mode 100644 index 0000000000..afbf121932 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-25.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf applied to Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +var func = function(a, b) { + return 0 === Array.prototype.indexOf.call(arguments, arguments[0]) && + -1 === Array.prototype.indexOf.call(arguments, arguments[1]); +}; + +assert(func(true), 'func(true) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-26.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-26.js new file mode 100644 index 0000000000..216c06e40e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-26.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf applied to Arguments object which + implements its own property get method (number of arguments equals + to number of parameters) +---*/ + +var func = function(a, b) { + return 0 === Array.prototype.indexOf.call(arguments, arguments[0]) && + 1 === Array.prototype.indexOf.call(arguments, arguments[1]) && + -1 === Array.prototype.indexOf.call(arguments, arguments[2]); +}; + +assert(func(0, true), 'func(0, true) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-27.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-27.js new file mode 100644 index 0000000000..d221275e6b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-27.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf applied to Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +var func = function(a, b) { + return 0 === Array.prototype.indexOf.call(arguments, arguments[0]) && + 3 === Array.prototype.indexOf.call(arguments, arguments[3]) && + -1 === Array.prototype.indexOf.call(arguments, arguments[4]); +}; + +assert(func(0, false, 0, true), 'func(0, false, 0, true) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-28.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-28.js new file mode 100644 index 0000000000..bfb2296e7c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-28.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - side-effects are visible in subsequent + iterations on an Array +---*/ + +var preIterVisible = false; +var arr = []; + +Object.defineProperty(arr, "0", { + get: function() { + preIterVisible = true; + return false; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return true; + } else { + return false; + } + }, + configurable: true +}); + +assert.sameValue(arr.indexOf(true), 1, 'arr.indexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-29.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-29.js new file mode 100644 index 0000000000..8043597a36 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-29.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - side-effects are visible in subsequent + iterations on an Array-like object +---*/ + +var preIterVisible = false; +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "0", { + get: function() { + preIterVisible = true; + return false; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return true; + } else { + return false; + } + }, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-3.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-3.js new file mode 100644 index 0000000000..2f2b8d4ce3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-3.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +Array.prototype[0] = false; + +assert.sameValue([true].indexOf(true), 0, '[true].indexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-30.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-30.js new file mode 100644 index 0000000000..d70884aa1e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-30.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - terminates iteration on unhandled + exception on an Array +---*/ + +var accessed = false; +var arr = []; + +Object.defineProperty(arr, "0", { + get: function() { + throw new TypeError(); + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + accessed = true; + return true; + }, + configurable: true +}); +assert.throws(TypeError, function() { + arr.indexOf(true); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-31.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-31.js new file mode 100644 index 0000000000..7d02c668dc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-31.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - terminates iteration on unhandled + exception on an Array-like object +---*/ + +var accessed = false; +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "0", { + get: function() { + throw new TypeError(); + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + accessed = true; + return true; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.indexOf.call(obj, true); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-4.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-4.js new file mode 100644 index 0000000000..5b84ca1310 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-4.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +Object.prototype[0] = false; + +assert.sameValue(Array.prototype.indexOf.call({ + 0: true, + 1: 1, + length: 2 +}, true), 0, 'Array.prototype.indexOf.call({ 0: true, 1: 1, length: 2 }, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-5.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-5.js new file mode 100644 index 0000000000..dbe3b1f86e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-5.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); + +assert.sameValue([true].indexOf(true), 0, '[true].indexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-6.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-6.js new file mode 100644 index 0000000000..f95381e58e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-6.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.indexOf.call({ + 0: true, + 1: 1, + length: 2 +}, true), 0, 'Array.prototype.indexOf.call({ 0: true, 1: 1, length: 2 }, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-7.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-7.js new file mode 100644 index 0000000000..b234373741 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-7.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is inherited + data property on an Array +---*/ + +Array.prototype[0] = true; +Array.prototype[1] = false; +Array.prototype[2] = "true"; + +assert.sameValue([, , , ].indexOf(true), 0, '[, , , ].indexOf(true)'); +assert.sameValue([, , , ].indexOf(false), 1, '[, , , ].indexOf(false)'); +assert.sameValue([, , , ].indexOf("true"), 2, '[, , , ].indexOf("true")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-8.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-8.js new file mode 100644 index 0000000000..24d5761a1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-8.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is inherited + data property on an Array-like object +---*/ + +Object.prototype[0] = true; +Object.prototype[1] = false; +Object.prototype[2] = "true"; + +assert.sameValue(Array.prototype.indexOf.call({ + length: 3 +}, true), 0, 'Array.prototype.indexOf.call({ length: 3 }, true)'); +assert.sameValue(Array.prototype.indexOf.call({ + length: 3 +}, false), 1, 'Array.prototype.indexOf.call({ length: 3 }, false)'); +assert.sameValue(Array.prototype.indexOf.call({ + length: 3 +}, "true"), 2, 'Array.prototype.indexOf.call({ length: 3 }, "true")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-9.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-9.js new file mode 100644 index 0000000000..bfcea0e115 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-9.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property on an Array +---*/ + +var arr = [, , , ]; +Object.defineProperty(arr, "0", { + get: function() { + return 0; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +Object.defineProperty(arr, "2", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(arr.indexOf(0), 0, 'arr.indexOf(0)'); +assert.sameValue(arr.indexOf(1), 1, 'arr.indexOf(1)'); +assert.sameValue(arr.indexOf(2), 2, 'arr.indexOf(2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-1.js new file mode 100644 index 0000000000..0501809791 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-1.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - type of array element is different from + type of search element +---*/ + +assert.sameValue(["true"].indexOf(true), -1, '["true"].indexOf(true)'); +assert.sameValue(["0"].indexOf(0), -1, '["0"].indexOf(0)'); +assert.sameValue([false].indexOf(0), -1, '[false].indexOf(0)'); +assert.sameValue([undefined].indexOf(0), -1, '[undefined].indexOf(0)'); +assert.sameValue([null].indexOf(0), -1, '[null].indexOf(0)'); +assert.sameValue([ + [] +].indexOf(0), -1, '[[]].indexOf(0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-10.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-10.js new file mode 100644 index 0000000000..d264b74681 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-10.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - both array element and search element + are Boolean type, and they have same value +---*/ + +assert.sameValue([false, true].indexOf(true), 1, '[false, true].indexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-11.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-11.js new file mode 100644 index 0000000000..c6049a525f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-11.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - both array element and search element + are Object type, and they refer to the same object +---*/ + +var obj1 = {}; +var obj2 = {}; +var obj3 = obj2; + +assert.sameValue([{}, obj1, obj2].indexOf(obj3), 2, '[{}, obj1, obj2].indexOf(obj3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-2.js new file mode 100644 index 0000000000..cc60a23dab --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - both type of array element and type of + search element are Undefined +---*/ + +assert.sameValue([undefined].indexOf(), 0, '[undefined].indexOf()'); +assert.sameValue([undefined].indexOf(undefined), 0, '[undefined].indexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-3.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-3.js new file mode 100644 index 0000000000..d7f0c7c3f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-3.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - both type of array element and type of + search element are null +---*/ + +assert.sameValue([null].indexOf(null), 0, '[null].indexOf(null)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-4.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-4.js new file mode 100644 index 0000000000..707a6a95cb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-4.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - search element is NaN +---*/ + +assert.sameValue([+NaN, NaN, -NaN].indexOf(NaN), -1, '[+NaN, NaN, -NaN].indexOf(NaN)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-5.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-5.js new file mode 100644 index 0000000000..fde2293094 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-5.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - search element is -NaN +---*/ + +assert.sameValue([+NaN, NaN, -NaN].indexOf(-NaN), -1, '[+NaN, NaN, -NaN].indexOf(-NaN)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-6.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-6.js new file mode 100644 index 0000000000..aa80981cc5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-6.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - array element is +0 and search element + is -0 +---*/ + +assert.sameValue([+0].indexOf(-0), 0, '[+0].indexOf(-0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-7.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-7.js new file mode 100644 index 0000000000..8ab2bc1025 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-7.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - array element is -0 and search element + is +0 +---*/ + +assert.sameValue([-0].indexOf(+0), 0, '[-0].indexOf(+0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-8.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-8.js new file mode 100644 index 0000000000..a94629ab4e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-8.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - both array element and search element + are Number, and they have same value +---*/ + +assert.sameValue([-1, 0, 1].indexOf(1), 2, '[-1, 0, 1].indexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-9.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-9.js new file mode 100644 index 0000000000..514461bb32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-ii-9.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - both array element and search element + are String, and they have exactly the same sequence of characters +---*/ + +assert.sameValue(["", "ab", "bca", "abc"].indexOf("abc"), 3, '["", "ab", "bca", "abc"].indexOf("abc")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-iii-1.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-iii-1.js new file mode 100644 index 0000000000..3ca832f862 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-iii-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - returns index of last one when more than + two elements in array are eligible +---*/ + +assert.sameValue([1, 2, 2, 1, 2].indexOf(2), 1, '[1, 2, 2, 1, 2].indexOf(2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-iii-2.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-iii-2.js new file mode 100644 index 0000000000..cf0f4fb3c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/15.4.4.14-9-b-iii-2.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - returns without visiting subsequent + element once search value is found +---*/ + +var arr = [1, 2, , 1, 2]; +var elementThirdAccessed = false; +var elementFifthAccessed = false; + +Object.defineProperty(arr, "2", { + get: function() { + elementThirdAccessed = true; + return 2; + }, + configurable: true +}); +Object.defineProperty(arr, "4", { + get: function() { + elementFifthAccessed = true; + return 2; + }, + configurable: true +}); + +arr.indexOf(2); + +assert.sameValue(elementThirdAccessed, false, 'elementThirdAccessed'); +assert.sameValue(elementFifthAccessed, false, 'elementFifthAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/browser.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/call-with-boolean.js new file mode 100644 index 0000000000..b39ac9944b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/call-with-boolean.js @@ -0,0 +1,12 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexOf +description: Array.prototype.indexOf applied to boolean primitive +---*/ + +assert.sameValue(Array.prototype.indexOf.call(true), -1, 'Array.prototype.indexOf.call(true) must return -1'); +assert.sameValue(Array.prototype.indexOf.call(false), -1, 'Array.prototype.indexOf.call(false) must return -1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js new file mode 100644 index 0000000000..fb95f97899 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js @@ -0,0 +1,45 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Calls [[HasProperty]] on the prototype to check for existing elements. +info: | + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) + ... + 8. Repeat, while k < len + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ... +includes: [proxyTrapsHelper.js] +features: [Proxy] +---*/ + +var array = [1, null, 3]; + +Object.setPrototypeOf(array, new Proxy(Array.prototype, allowProxyTraps({ + has: function(t, pk) { + return pk in t; + } +}))); + +var fromIndex = { + valueOf: function() { + // Zero the array's length. The loop in step 8 iterates over the original + // length value of 100, but the only prototype MOP method which should be + // called is [[HasProperty]]. + array.length = 0; + return 0; + } +}; + +Array.prototype.indexOf.call(array, 100, fromIndex); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/fromindex-zero-conversion.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/fromindex-zero-conversion.js new file mode 100644 index 0000000000..721d5db763 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/fromindex-zero-conversion.js @@ -0,0 +1,18 @@ +// Copyright 2016 The V8 project authors. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.prototype.indexof +description: > + Return +0 when fromIndex is -0 and return index refers to the first position +info: | + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 6. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be n. + ... +---*/ + +assert.sameValue(1 / [true].indexOf(true, -0), +Infinity) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/length-near-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/length-near-integer-limit.js new file mode 100644 index 0000000000..5dddc31aaf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/length-near-integer-limit.js @@ -0,0 +1,37 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Elements are found in an array-like object + whose "length" property is near the integer limit. +info: | + Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + [...] + 9. Repeat, while k < len + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ii. Let same be the result of performing Strict Equality Comparison searchElement === elementK. + iii. If same is true, return k. + [...] +---*/ + +var el = {}; +var elIndex = Number.MAX_SAFE_INTEGER - 1; +var fromIndex = Number.MAX_SAFE_INTEGER - 3; +var arrayLike = { + length: Number.MAX_SAFE_INTEGER, +}; + +arrayLike[elIndex] = el; + +var res = Array.prototype.indexOf.call(arrayLike, el, fromIndex); + +assert.sameValue(res, elIndex); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/length-zero-returns-minus-one.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/length-zero-returns-minus-one.js new file mode 100644 index 0000000000..aacbec9710 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/length-zero-returns-minus-one.js @@ -0,0 +1,24 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.indexof +description: > + Returns -1 if length is 0. +info: | + Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + 3. If len is 0, return -1. +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error("Length should be checked before ToInteger(fromIndex)."); + }, +}; + +assert.sameValue([].indexOf(1), -1); +assert.sameValue([].indexOf(2, fromIndex), -1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/length.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/length.js new file mode 100644 index 0000000000..36a44e19dc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + The "length" property of Array.prototype.indexOf +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.indexOf.length, 1); + +verifyNotEnumerable(Array.prototype.indexOf, 'length'); +verifyNotWritable(Array.prototype.indexOf, 'length'); +verifyConfigurable(Array.prototype.indexOf, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/name.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/name.js new file mode 100644 index 0000000000..5017f4381c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf.name is "indexOf". +info: | + Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.indexOf.name, "indexOf"); + +verifyNotEnumerable(Array.prototype.indexOf, "name"); +verifyNotWritable(Array.prototype.indexOf, "name"); +verifyConfigurable(Array.prototype.indexOf, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/not-a-constructor.js new file mode 100644 index 0000000000..d297029668 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/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: > + Array.prototype.indexOf 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.indexOf), + false, + 'isConstructor(Array.prototype.indexOf) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.indexOf(); +}, '`new Array.prototype.indexOf()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/prop-desc.js new file mode 100644 index 0000000000..dd6ecb2cb3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + "indexOf" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.indexOf, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "indexOf"); +verifyWritable(Array.prototype, "indexOf"); +verifyConfigurable(Array.prototype, "indexOf"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/shell.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/shell.js new file mode 100644 index 0000000000..bc72493f03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/shell.js @@ -0,0 +1,33 @@ +// GENERATED, DO NOT EDIT +// file: proxyTrapsHelper.js +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Used to assert the correctness of object behavior in the presence + and context of Proxy objects. +defines: [allowProxyTraps] +---*/ + +function allowProxyTraps(overrides) { + function throwTest262Error(msg) { + return function () { throw new Test262Error(msg); }; + } + if (!overrides) { overrides = {}; } + return { + getPrototypeOf: overrides.getPrototypeOf || throwTest262Error('[[GetPrototypeOf]] trap called'), + setPrototypeOf: overrides.setPrototypeOf || throwTest262Error('[[SetPrototypeOf]] trap called'), + isExtensible: overrides.isExtensible || throwTest262Error('[[IsExtensible]] trap called'), + preventExtensions: overrides.preventExtensions || throwTest262Error('[[PreventExtensions]] trap called'), + getOwnPropertyDescriptor: overrides.getOwnPropertyDescriptor || throwTest262Error('[[GetOwnProperty]] trap called'), + has: overrides.has || throwTest262Error('[[HasProperty]] trap called'), + get: overrides.get || throwTest262Error('[[Get]] trap called'), + set: overrides.set || throwTest262Error('[[Set]] trap called'), + deleteProperty: overrides.deleteProperty || throwTest262Error('[[Delete]] trap called'), + defineProperty: overrides.defineProperty || throwTest262Error('[[DefineOwnProperty]] trap called'), + enumerate: throwTest262Error('[[Enumerate]] trap called: this trap has been removed'), + ownKeys: overrides.ownKeys || throwTest262Error('[[OwnPropertyKeys]] trap called'), + apply: overrides.apply || throwTest262Error('[[Call]] trap called'), + construct: overrides.construct || throwTest262Error('[[Construct]] trap called') + }; +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.1_T1.js new file mode 100644 index 0000000000..3fb2f83124 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If length is zero, return the empty string +esid: sec-array.prototype.join +description: Checking this use new Array() and [] +---*/ + +var x = new Array(); +if (x.join() !== "") { + throw new Test262Error('#1: x = new Array(); x.join() === "". Actual: ' + (x.join())); +} + +x = []; +x[0] = 1; +x.length = 0; +if (x.join() !== "") { + throw new Test262Error('#2: x = []; x[0] = 1; x.length = 0; x.join() === "". Actual: ' + (x.join())); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.2_T1.js new file mode 100644 index 0000000000..4107dafdb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.2_T1.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If separator is undefined, a single comma is used as the separator +esid: sec-array.prototype.join +description: Checking this use new Array() and [] +---*/ + +var x = new Array(0, 1, 2, 3); +if (x.join() !== "0,1,2,3") { + throw new Test262Error('#1: x = new Array(0,1,2,3); x.join() === "0,1,2,3". Actual: ' + (x.join())); +} + +x = []; +x[0] = 0; +x[3] = 3; +if (x.join() !== "0,,,3") { + throw new Test262Error('#2: x = []; x[0] = 0; x[3] = 3; x.join() === "0,,,3". Actual: ' + (x.join())); +} + +x = []; +x[0] = 0; +if (x.join() !== "0") { + throw new Test262Error('#3: x = []; x[0] = 0; x.join() === "0". Actual: ' + (x.join())); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.2_T2.js new file mode 100644 index 0000000000..bea80dc36e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.2_T2.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If separator is undefined, a single comma is used as the separator +esid: sec-array.prototype.join +description: Checking this use new Array() and [] +---*/ + +var x = new Array(0, 1, 2, 3); +if (x.join(undefined) !== "0,1,2,3") { + throw new Test262Error('#1: x = new Array(0,1,2,3); x.join(undefined) === "0,1,2,3". Actual: ' + (x.join(undefined))); +} + +x = []; +x[0] = 0; +x[3] = 3; +if (x.join(undefined) !== "0,,,3") { + throw new Test262Error('#2: x = []; x[0] = 0; x[3] = 3; x.join(undefined) === "0,,,3". Actual: ' + (x.join(undefined))); +} + +x = []; +x[0] = 0; +if (x.join(undefined) !== "0") { + throw new Test262Error('#3: x = []; x[0] = 0; x.join(undefined) === "0". Actual: ' + (x.join(undefined))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.3_T1.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.3_T1.js new file mode 100644 index 0000000000..23c0bf98aa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.3_T1.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If array element is undefined or null, use the empty string +esid: sec-array.prototype.join +description: Checking this use new Array() and [] +---*/ + +var x = []; +x[0] = undefined; +if (x.join() !== "") { + throw new Test262Error('#1: x = []; x[0] = undefined; x.join() === "". Actual: ' + (x.join())); +} + +x = []; +x[0] = null; +if (x.join() !== "") { + throw new Test262Error('#2: x = []; x[0] = null; x.join() === "". Actual: ' + (x.join())); +} + +x = Array(undefined, 1, null, 3); +if (x.join() !== ",1,,3") { + throw new Test262Error('#3: x = Array(undefined,1,null,3); x.join() === ",1,,3". Actual: ' + (x.join())); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T1.js new file mode 100644 index 0000000000..3767112626 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T1.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The join function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.join +description: If ToUint32(length) is zero, return the empty string +---*/ + +var obj = {}; +obj.join = Array.prototype.join; + +if (obj.length !== undefined) { + throw new Test262Error('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + if (obj.join() !== "") { + throw new Test262Error('#1: var obj = {}; obj.join = Array.prototype.join; obj.join() === "". Actual: ' + (obj.join())); + } + if (obj.length !== undefined) { + throw new Test262Error('#2: var obj = {}; obj.join = Array.prototype.join; obj.join(); obj.length === undefined. Actual: ' + (obj.length)); + } +} + +obj.length = undefined; +if (obj.join() !== "") { + throw new Test262Error('#3: var obj = {}; obj.length = undefined; obj.join = Array.prototype.join; obj.join() === ". Actual: ' + (obj.join())); +} + +if (obj.length !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.length = undefined; obj.join = Array.prototype.join; obj.join(); obj.length === undefined. Actual: ' + (obj.length)); +} + +obj.length = null +if (obj.join() !== "") { + throw new Test262Error('#5: var obj = {}; obj.length = null; obj.join = Array.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} + +if (obj.length !== null) { + throw new Test262Error('#6: var obj = {}; obj.length = null; obj.join = Array.prototype.join; obj.join(); obj.length === null. Actual: ' + (obj.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T2.js new file mode 100644 index 0000000000..ef3b1004ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T2.js @@ -0,0 +1,63 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The join function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.join +description: If ToUint32(length) is zero, return the empty string +---*/ + +var obj = {}; +obj.join = Array.prototype.join; + +obj.length = NaN; +if (obj.join() !== "") { + throw new Test262Error('#1: var obj = {}; obj.length = NaN; obj.join = Array.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} + +assert.sameValue(obj.length, NaN, "obj.length is NaN"); + +obj.length = Number.NEGATIVE_INFINITY; +if (obj.join() !== "") { + throw new Test262Error('#5: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.join = Array.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} + +if (obj.length !== Number.NEGATIVE_INFINITY) { + throw new Test262Error('#6: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.join = Array.prototype.join; obj.join(); obj.length === Number.NEGATIVE_INFINITY. Actual: ' + (obj.length)); +} + +obj.length = -0; +if (obj.join() !== "") { + throw new Test262Error('#7: var obj = {}; obj.length = -0; obj.join = Array.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} + +if (obj.length !== -0) { + throw new Test262Error('#8: var obj = {}; obj.length = -0; obj.join = Array.prototype.join; obj.join(); obj.length === 0. Actual: ' + (obj.length)); +} else { + if (1 / obj.length !== Number.NEGATIVE_INFINITY) { + throw new Test262Error('#8: var obj = {}; obj.length = -0; obj.join = Array.prototype.join; obj.join(); obj.length === -0. Actual: ' + (obj.length)); + } +} + +obj.length = 0.5; +if (obj.join() !== "") { + throw new Test262Error('#9: var obj = {}; obj.length = 0.5; obj.join = Array.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} + +if (obj.length !== 0.5) { + throw new Test262Error('#10: var obj = {}; obj.length = 0.5; obj.join = Array.prototype.join; obj.join(); obj.length === 0.5. Actual: ' + (obj.length)); +} + +var x = new Number(0); +obj.length = x; +if (obj.join() !== "") { + throw new Test262Error('#11: var x = new Number(0); var obj = {}; obj.length = x; obj.join = Array.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} + +if (obj.length !== x) { + throw new Test262Error('#12: var x = new Number(0); var obj = {}; obj.length = x; obj.join = Array.prototype.join; obj.join(); obj.length === x. Actual: ' + (obj.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T3.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T3.js new file mode 100644 index 0000000000..edd94bbfb1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T3.js @@ -0,0 +1,51 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The join function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.join +description: If ToUint32(length) is zero, return the empty string +---*/ + +var obj = {}; +obj.join = Array.prototype.join; + +obj.length = 4.5; +if (obj.join() !== ",,,") { + throw new Test262Error('#1: var obj = {}; obj.length = 4.5; obj.join = Array.prototype.join; obj.join() === ",,,". Actual: ' + (obj.join())); +} + +obj[0] = undefined; +obj[1] = 1; +obj[2] = null; +if (obj.join() !== ",1,,") { + throw new Test262Error('#1: var obj = {}; obj.length = 4.5; obj[0] = undefined; obj[1] = 1; obj[2] = null; obj.join = Array.prototype.join; obj.join() === ",1,,". Actual: ' + (obj.join())); +} + +if (obj.length !== 4.5) { + throw new Test262Error('#1: var obj = {}; obj.length = 4.5; obj[0] = undefined; obj[1] = 1; obj[2] = null; obj.join = Array.prototype.join; obj.join(); obj.length === 4.5. Actual: ' + (obj.length)); +} + +var obj = {}; +obj.join = Array.prototype.join; + +var x = new Number(4.5); +obj.length = x; +if (obj.join() !== ",,,") { + throw new Test262Error('#4: var obj = {}; var x = new Number(4.5); obj.length = x; obj.join = Array.prototype.join; obj.join() === ",,,". Actual: ' + (obj.join())); +} + +obj[0] = undefined; +obj[1] = 1; +obj[2] = null; +if (obj.join() !== ",1,,") { + throw new Test262Error('#5: var obj = {}; var x = new Number(4.5); obj.length = x; obj[0] = undefined; obj[1] = 1; obj[2] = null; obj.join = Array.prototype.join; obj.join() === ",1,,". Actual: ' + (obj.join())); +} + +if (obj.length !== x) { + throw new Test262Error('#6: var obj = {}; var x = new Number(4.5); obj.length = x; obj[0] = undefined; obj[1] = 1; obj[2] = null; obj.join = Array.prototype.join; obj.join(); obj.length === x. Actual: ' + (obj.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T4.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T4.js new file mode 100644 index 0000000000..a7b77ba974 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T4.js @@ -0,0 +1,95 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The join function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.join +description: > + Operator use ToNumber from length. If Type(value) is Object, + evaluate ToPrimitive(value, Number) +---*/ + +var obj = {}; +obj.join = Array.prototype.join; + +obj.length = { + valueOf() { + return 3 + } +}; +assert.sameValue(obj.join(), ",,", 'obj.join() must return ",,"'); + +obj.length = { + valueOf() { + return 3 + }, + toString() { + return 2 + } +}; +assert.sameValue(obj.join(), ",,", 'obj.join() must return ",,"'); + +obj.length = { + valueOf() { + return 3 + }, + toString() { + return {} + } +}; +assert.sameValue(obj.join(), ",,", 'obj.join() must return ",,"'); + +obj.length = { + valueOf() { + return 3 + }, + toString() { + throw new Test262Error(); + } +}; +assert.sameValue(obj.join(), ",,", 'obj.join() must return ",,"'); + +obj.length = { + toString() { + return 2 + } +}; +assert.sameValue(obj.join(), ",", 'obj.join() must return ","'); + +obj.length = { + valueOf() { + return {} + }, + toString() { + return 2 + } +} +assert.sameValue(obj.join(), ",", 'obj.join() must return ","'); + +assert.throws(Test262Error, () => { + obj.length = { + valueOf() { + throw new Test262Error(); + }, + toString() { + return 2 + } + }; + obj.join(); +}); + +assert.throws(TypeError, () => { + obj.length = { + valueOf() { + return {} + }, + toString() { + return {} + } + }; + obj.join(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.1_T1.js new file mode 100644 index 0000000000..1f8dcd4d71 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.1_T1.js @@ -0,0 +1,46 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToString from separator +esid: sec-array.prototype.join +description: > + Checking separator in ["", "\\", "&", true, Infinity, null, + undefind, NaN] +---*/ + +var x = new Array(0, 1, 2, 3); +if (x.join("") !== "0123") { + throw new Test262Error('#0: x = new Array(0,1,2,3); x.join("") === "0123". Actual: ' + (x.join(""))); +} + +x = new Array(0, 1, 2, 3); +if (x.join("\\") !== "0\\1\\2\\3") { + throw new Test262Error('#1: x = new Array(0,1,2,3); x.join("\\") === "0\\1\\2\\3". Actual: ' + (x.join("\\"))); +} + +if (x.join("&") !== "0&1&2&3") { + throw new Test262Error('#2: x = new Array(0,1,2,3); x.join("&") === "0&1&2&3". Actual: ' + (x.join("&"))); +} + +if (x.join(true) !== "0true1true2true3") { + throw new Test262Error('#3: x = new Array(0,1,2,3); x.join(true) === "0true1true2true3". Actual: ' + (x.join(true))); +} + +if (x.join(Infinity) !== "0Infinity1Infinity2Infinity3") { + throw new Test262Error('#4: x = new Array(0,1,2,3); x.join(Infinity) === "0Infinity1Infinity2Infinity3". Actual: ' + (x.join(Infinity))); +} + +if (x.join(null) !== "0null1null2null3") { + throw new Test262Error('#3: 5 = new Array(0,1,2,3); x.join(null) === "0null1null2null3". Actual: ' + (x.join(null))); +} + +if (x.join(undefined) !== "0,1,2,3") { + throw new Test262Error('#6: x = new Array(0,1,2,3); x.join(undefined) === "0,1,2,3". Actual: ' + (x.join(undefined))); +} + +if (x.join(NaN) !== "0NaN1NaN2NaN3") { + throw new Test262Error('#7: x = new Array(0,1,2,3); x.join(NaN) === "0NaN1NaN2NaN3". Actual: ' + (x.join(NaN))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.1_T2.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.1_T2.js new file mode 100644 index 0000000000..7ceea3ef98 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.1_T2.js @@ -0,0 +1,146 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToString from separator +esid: sec-array.prototype.join +description: > + If Type(separator) is Object, evaluate ToPrimitive(separator, + String) +---*/ + +var x = new Array(0, 1, 2, 3); +var object = { + valueOf() { + return "+" + } +}; + +assert.sameValue( + x.join(object), + "0[object Object]1[object Object]2[object Object]3", + 'x.join({valueOf() {return "+"}}) must return "0[object Object]1[object Object]2[object Object]3"' +); + +var object = { + valueOf() { + return "+" + }, + toString() { + return "*" + } +}; + +assert.sameValue( + x.join(object), + "0*1*2*3", + 'x.join("{valueOf() {return "+"}, toString() {return "*"}}) must return "0*1*2*3"' +); + +var object = { + valueOf() { + return "+" + }, + toString() { + return {} + } +}; + +assert.sameValue( + x.join(object), + "0+1+2+3", + 'x.join({valueOf() {return "+"}, toString() {return {}}}) must return "0+1+2+3"' +); + +try { + var object = { + valueOf() { + throw "error" + }, + toString() { + return "*" + } + }; + + assert.sameValue( + x.join(object), + "0*1*2*3", + 'x.join("{valueOf() {throw "error"}, toString() {return "*"}}) must return "0*1*2*3"' + ); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} + +var object = { + toString() { + return "*" + } +}; +assert.sameValue(x.join(object), "0*1*2*3", 'x.join({toString() {return "*"}}) must return "0*1*2*3"'); + +var object = { + valueOf() { + return {} + }, + toString() { + return "*" + } +} + +assert.sameValue( + x.join(object), + "0*1*2*3", + 'x.join({valueOf() {return {}}, toString() {return "*"}}) must return "0*1*2*3"' +); + +try { + var object = { + valueOf() { + return "+" + }, + toString() { + throw "error" + } + }; + x.join(object); + throw new Test262Error('#7.1: var object = {valueOf() {return "+"}, toString() {throw "error"}}; x.join(object) throw "error". Actual: ' + (x.join(object))); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} + +try { + var object = { + valueOf() { + return {} + }, + toString() { + return {} + } + }; + x.join(object); + throw new Test262Error('#8.1: var object = {valueOf() {return {}}, toString() {return {}}}; x.join(object) throw TypeError. Actual: ' + (x.join(object))); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +try { + var object = { + toString() { + throw "error" + } + }; + [].join(object); + throw new Test262Error('#9.1: var object = {toString() {throw "error"}}; [].join(object) throw "error". Actual: ' + ([].join(object))); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.2_T1.js new file mode 100644 index 0000000000..bcea5c4239 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.2_T1.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToString from array arguments +esid: sec-array.prototype.join +description: > + Checking arguments and separator in ["", "\\", "&", true, + Infinity, null, undefind, NaN] +---*/ + +var x = new Array("", "", ""); +if (x.join("") !== "") { + throw new Test262Error('#0: var x = new Array("","",""); x.join("") === "". Actual: ' + (x.join(""))); +} + +var x = new Array("\\", "\\", "\\"); +if (x.join("\\") !== "\\\\\\\\\\") { + throw new Test262Error('#1: var x = new Array("\\","\\","\\"); x.join("\\") === "\\\\\\\\\\". Actual: ' + (x.join("\\"))); +} + +var x = new Array("&", "&", "&"); +if (x.join("&") !== "&&&&&") { + throw new Test262Error('#2: var x = new Array("&", "&", "&"); x.join("&") === "&&&&&". Actual: ' + (x.join("&"))); +} + +var x = new Array(true, true, true); +if (x.join() !== "true,true,true") { + throw new Test262Error('#3: var x = new Array(true,true,true); x.join(true,true,true) === "true,true,true". Actual: ' + (x.join(true, true, true))); +} + +var x = new Array(null, null, null); +if (x.join() !== ",,") { + throw new Test262Error('#4: var x = new Array(null,null,null); x.join(null,null,null) === ",,". Actual: ' + (x.join(null, null, null))); +} + +var x = new Array(undefined, undefined, undefined); +if (x.join() !== ",,") { + throw new Test262Error('#5: var x = new Array(undefined,undefined,undefined); x.join(undefined,undefined,undefined) === ",,". Actual: ' + (x.join(undefined, undefined, undefined))); +} + +var x = new Array(Infinity, Infinity, Infinity); +if (x.join() !== "Infinity,Infinity,Infinity") { + throw new Test262Error('#6: var x = new Array(Infinity,Infinity,Infinity); x.join(Infinity,Infinity,Infinity) === "Infinity,Infinity,Infinity". Actual: ' + (x.join(Infinity, Infinity, Infinity))); +} + +var x = new Array(NaN, NaN, NaN); +if (x.join() !== "NaN,NaN,NaN") { + throw new Test262Error('#7: var x = new Array(NaN,NaN,NaN); x.join(NaN,NaN,NaN) === "NaN,NaN,NaN". Actual: ' + (x.join(NaN, NaN, NaN))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.2_T2.js new file mode 100644 index 0000000000..047a76bed6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.2_T2.js @@ -0,0 +1,113 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToString from array arguments +esid: sec-array.prototype.join +description: If Type(argument) is Object, evaluate ToPrimitive(argument, String) +---*/ + +var object = { + valueOf: function() { + return "+" + } +}; +var x = new Array(object); +assert.sameValue(x.join(), "[object Object]", 'x.join() must return "[object Object]"'); + +var object = { + valueOf: function() { + return "+" + }, + toString: function() { + return "*" + } +}; +var x = new Array(object); +assert.sameValue(x.join(), "*", 'x.join() must return "*"'); + +var object = { + valueOf: function() { + return "+" + }, + toString: function() { + return {} + } +}; +var x = new Array(object); +assert.sameValue(x.join(), "+", 'x.join() must return "+"'); + +try { + var object = { + valueOf: function() { + throw "error" + }, + toString: function() { + return "*" + } + }; + var x = new Array(object); + assert.sameValue(x.join(), "*", 'x.join() must return "*"'); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} + +var object = { + toString: function() { + return "*" + } +}; +var x = new Array(object); +assert.sameValue(x.join(), "*", 'x.join() must return "*"'); + +var object = { + valueOf: function() { + return {} + }, + toString: function() { + return "*" + } +} +var x = new Array(object); +assert.sameValue(x.join(), "*", 'x.join() must return "*"'); + +try { + var object = { + valueOf: function() { + return "+" + }, + toString: function() { + throw "error" + } + }; + var x = new Array(object); + x.join(); + throw new Test262Error('#7.1: var object = {valueOf: function() {return "+"}, toString: function() {throw "error"}} var x = new Array(object); x.join() throw "error". Actual: ' + (x.join())); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} + +try { + var object = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + var x = new Array(object); + x.join(); + throw new Test262Error('#8.1: var object = {valueOf: function() {return {}}, toString: function() {return {}}} var x = new Array(object); x.join() throw TypeError. Actual: ' + (x.join())); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A4_T3.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A4_T3.js new file mode 100644 index 0000000000..c199dd6210 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A4_T3.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.join +description: length = -4294967294 +---*/ + +var obj = {}; +obj.join = Array.prototype.join; +obj[0] = "x"; +obj[1] = "y"; +obj[2] = "z"; +obj.length = -4294967294; + +if (obj.join("") !== "") { + throw new Test262Error('#1: var obj = {}; obj.join = Array.prototype.join; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.join("") === "". Actual: ' + (obj.join(""))); +} + +if (obj.length !== -4294967294) { + throw new Test262Error('#2: var obj = {}; obj.join = Array.prototype.join; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.join(""); obj.length === -4294967294. Actual: ' + (obj.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A5_T1.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A5_T1.js new file mode 100644 index 0000000000..781cb601d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A5_T1.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]] from not an inherited property" +esid: sec-array.prototype.join +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Array.prototype[1] = 1; +var x = [0]; +x.length = 2; +if (x.join() !== "0,1") { + throw new Test262Error('#1: Array.prototype[1] = 1; x = [0]; x.length = 2; x.join() === "0,1". Actual: ' + (x.join())); +} + +Object.prototype[1] = 1; +Object.prototype.length = 2; +Object.prototype.join = Array.prototype.join; +x = { + 0: 0 +}; +if (x.join() !== "0,1") { + throw new Test262Error('#2: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.join = Array.prototype.join; x = {0:0}; x.join() === "0,1". Actual: ' + (x.join())); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A6.6.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A6.6.js new file mode 100644 index 0000000000..1772e04386 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A6.6.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The join property of Array has not prototype property +esid: sec-array.prototype.join +description: Checking Array.prototype.join.prototype +---*/ + +if (Array.prototype.join.prototype !== undefined) { + throw new Test262Error('#1: Array.prototype.join.prototype === undefined. Actual: ' + (Array.prototype.join.prototype)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/browser.js b/js/src/tests/test262/built-ins/Array/prototype/join/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/join/call-with-boolean.js new file mode 100644 index 0000000000..3bbdbfd037 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/call-with-boolean.js @@ -0,0 +1,12 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.join +description: Array.prototype.join applied to boolean primitive +---*/ + +assert.sameValue(Array.prototype.join.call(true), "", 'Array.prototype.join.call(true) must return ""'); +assert.sameValue(Array.prototype.join.call(false), "", 'Array.prototype.join.call(false) must return ""'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/length.js b/js/src/tests/test262/built-ins/Array/prototype/join/length.js new file mode 100644 index 0000000000..bdef13a59f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.join +description: > + The "length" property of Array.prototype.join +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.join.length, 1); + +verifyNotEnumerable(Array.prototype.join, 'length'); +verifyNotWritable(Array.prototype.join, 'length'); +verifyConfigurable(Array.prototype.join, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/name.js b/js/src/tests/test262/built-ins/Array/prototype/join/name.js new file mode 100644 index 0000000000..3af90e214e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.join +description: > + Array.prototype.join.name is "join". +info: | + Array.prototype.join (separator) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.join.name, "join"); + +verifyNotEnumerable(Array.prototype.join, "name"); +verifyNotWritable(Array.prototype.join, "name"); +verifyConfigurable(Array.prototype.join, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/join/not-a-constructor.js new file mode 100644 index 0000000000..e92cd56335 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/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: > + Array.prototype.join 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, arrow-function] +---*/ + +assert.sameValue(isConstructor(Array.prototype.join), false, 'isConstructor(Array.prototype.join) must return false'); + +assert.throws(TypeError, () => { + new Array.prototype.join(); +}, '`new Array.prototype.join()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/join/prop-desc.js new file mode 100644 index 0000000000..f0948561ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.join +description: > + "join" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.join, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "join"); +verifyWritable(Array.prototype, "join"); +verifyConfigurable(Array.prototype, "join"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/shell.js b/js/src/tests/test262/built-ins/Array/prototype/join/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/keys/browser.js b/js/src/tests/test262/built-ins/Array/prototype/keys/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/keys/iteration-mutable.js b/js/src/tests/test262/built-ins/Array/prototype/keys/iteration-mutable.js new file mode 100644 index 0000000000..e1eee7e83c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/keys/iteration-mutable.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-array.prototype.keys +description: > + New items in the array are accessible via iteration until iterator is "done". +info: | + When an item is added to the array after the iterator is created but + before the iterator is "done" (as defined by 22.1.5.2.1), the new item's + key should be accessible via iteration. When an item is added to the + array after the iterator is "done", the new item's key should not be + accessible via iteration. +---*/ + +var array = []; +var iterator = array.keys(); +var result; + +array.push('a'); + +result = iterator.next(); +assert.sameValue(result.done, false, 'First result `done` flag'); +assert.sameValue(result.value, 0, 'First result `value`'); + +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); + +array.push('b'); + +result = iterator.next(); +assert.sameValue( + result.done, true, + 'Exhausted result `done` flag (after push)' +); +assert.sameValue( + result.value, undefined, + 'Exhausted result `value` (after push)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/keys/iteration.js b/js/src/tests/test262/built-ins/Array/prototype/keys/iteration.js new file mode 100644 index 0000000000..32e0530717 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/keys/iteration.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-array.prototype.keys +description: > + The return is a valid iterator with the array's numeric properties. +info: | + 22.1.3.13 Array.prototype.keys ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key"). +---*/ + +var array = ['a', 'b', 'c']; +var iterator = array.keys(); +var result; + +result = iterator.next(); +assert.sameValue(result.value, 0, 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 1, 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 2, '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'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/keys/length.js b/js/src/tests/test262/built-ins/Array/prototype/keys/length.js new file mode 100644 index 0000000000..6d997e5972 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/keys/length.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-array.prototype.keys +description: > + Array.prototype.keys.length value and descriptor. +info: | + 22.1.3.13 Array.prototype.keys ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.keys.length, 0, + 'The value of `Array.prototype.keys.length` is `0`' +); + +verifyNotEnumerable(Array.prototype.keys, 'length'); +verifyNotWritable(Array.prototype.keys, 'length'); +verifyConfigurable(Array.prototype.keys, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/keys/name.js b/js/src/tests/test262/built-ins/Array/prototype/keys/name.js new file mode 100644 index 0000000000..11ea5c508f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/keys/name.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-array.prototype.keys +description: > + Array.prototype.keys.name value and descriptor. +info: | + 22.1.3.13 Array.prototype.keys ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.keys.name, 'keys', + 'The value of `Array.prototype.keys.name` is `"keys"`' +); + +verifyNotEnumerable(Array.prototype.keys, 'name'); +verifyNotWritable(Array.prototype.keys, 'name'); +verifyConfigurable(Array.prototype.keys, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/keys/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/keys/not-a-constructor.js new file mode 100644 index 0000000000..8d0b5db966 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/keys/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: > + Array.prototype.keys 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, arrow-function] +---*/ + +assert.sameValue(isConstructor(Array.prototype.keys), false, 'isConstructor(Array.prototype.keys) must return false'); + +assert.throws(TypeError, () => { + new Array.prototype.keys(); +}, '`new Array.prototype.keys()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/keys/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/keys/prop-desc.js new file mode 100644 index 0000000000..6230d94566 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/keys/prop-desc.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-array.prototype.keys +description: > + Property type and descriptor. +info: | + 22.1.3.13 Array.prototype.keys ( ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Array.prototype.keys, + 'function', + '`typeof Array.prototype.keys` is `function`' +); + +verifyNotEnumerable(Array.prototype, 'keys'); +verifyWritable(Array.prototype, 'keys'); +verifyConfigurable(Array.prototype, 'keys'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/keys/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/Array/prototype/keys/return-abrupt-from-this.js new file mode 100644 index 0000000000..0885de5532 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/keys/return-abrupt-from-this.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-array.prototype.keys +description: > + Return abrupt from ToObject(this value). +info: | + 22.1.3.13 Array.prototype.keys ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +assert.throws(TypeError, function() { + Array.prototype.keys.call(undefined); +}); + +assert.throws(TypeError, function() { + Array.prototype.keys.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/keys/returns-iterator-from-object.js b/js/src/tests/test262/built-ins/Array/prototype/keys/returns-iterator-from-object.js new file mode 100644 index 0000000000..d48cc27f94 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/keys/returns-iterator-from-object.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-array.prototype.keys +description: > + Creates an iterator from a custom object. +info: | + 22.1.3.13 Array.prototype.keys ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key"). +features: [Symbol.iterator] +---*/ + +var obj = { + length: 2 +}; +var iter = Array.prototype.keys.call(obj); +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].keys() is %ArrayIteratorPrototype%' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/keys/returns-iterator.js b/js/src/tests/test262/built-ins/Array/prototype/keys/returns-iterator.js new file mode 100644 index 0000000000..56ba5b5af5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/keys/returns-iterator.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-array.prototype.keys +description: > + The method should return an Iterator instance. +info: | + 22.1.3.13 Array.prototype.keys ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key"). + + 22.1.5.1 CreateArrayIterator Abstract Operation + + ... + 2. Let iterator be ObjectCreate(%ArrayIteratorPrototype%, «‍[[IteratedObject]], + [[ArrayIteratorNextIndex]], [[ArrayIterationKind]]»). + ... + 6. Return iterator. +features: [Symbol.iterator] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); +var iter = [].keys(); + +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].keys() is %ArrayIteratorPrototype%' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/keys/shell.js b/js/src/tests/test262/built-ins/Array/prototype/keys/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-1.js new file mode 100644 index 0000000000..f4385f56f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to undefined throws a TypeError +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.lastIndexOf.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-10.js new file mode 100644 index 0000000000..9d791295f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-10.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to the Math object +---*/ + +Math.length = 2; +Math[1] = 100; + +assert.sameValue(Array.prototype.lastIndexOf.call(Math, 100), 1, 'Array.prototype.lastIndexOf.call(Math, 100)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-11.js new file mode 100644 index 0000000000..ba3a3046b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-11.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Date object +---*/ + +var obj = new Date(); +obj.length = 2; +obj[1] = true; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-12.js new file mode 100644 index 0000000000..ad8fdee8d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-12.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to RegExp object +---*/ + +var obj = new RegExp("afdasf"); +obj.length = 100; +obj[1] = "afdasf"; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, "afdasf"), 1, 'Array.prototype.lastIndexOf.call(obj, "afdasf")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-13.js new file mode 100644 index 0000000000..0c1b6d06ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-13.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to the JSON object +---*/ + +var targetObj = {}; + +JSON[3] = targetObj; +JSON.length = 5; + +assert.sameValue(Array.prototype.lastIndexOf.call(JSON, targetObj), 3, 'Array.prototype.lastIndexOf.call(JSON, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-14.js new file mode 100644 index 0000000000..c4ff1e4c1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-14.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Error object +---*/ + +var obj = new SyntaxError(); +obj.length = 2; +obj[1] = Infinity; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, Infinity), 1, 'Array.prototype.lastIndexOf.call(obj, Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-15.js new file mode 100644 index 0000000000..2fd89b80d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-15.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to the Arguments object +---*/ + +var obj = (function fun() { + return arguments; +}(1, 2, 3)); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), 1, 'Array.prototype.lastIndexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-2.js new file mode 100644 index 0000000000..ab7a152285 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to null throws a TypeError +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.lastIndexOf.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-3.js new file mode 100644 index 0000000000..d662edf0e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-3.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to boolean primitive +---*/ + +Boolean.prototype[1] = true; +Boolean.prototype.length = 2; + +assert.sameValue(Array.prototype.lastIndexOf.call(true, true), 1, 'Array.prototype.lastIndexOf.call(true, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-4.js new file mode 100644 index 0000000000..7f11852e14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-4.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Boolean object +---*/ + +var obj = new Boolean(false); +obj.length = 2; +obj[1] = true; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-5.js new file mode 100644 index 0000000000..d2432b9b22 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-5.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to number primitive +---*/ + +Number.prototype[1] = isNaN; +Number.prototype.length = 2; + +assert.sameValue(Array.prototype.lastIndexOf.call(5, isNaN), 1, 'Array.prototype.lastIndexOf.call(5, isNaN)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-6.js new file mode 100644 index 0000000000..6cd70edfd6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-6.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Number object +---*/ + +var obj = new Number(-3); +obj.length = 2; +obj[1] = true; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-7.js new file mode 100644 index 0000000000..5fa4fa5da9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-7.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to string primitive +---*/ + +assert.sameValue(Array.prototype.lastIndexOf.call("abc", "c"), 2, 'Array.prototype.lastIndexOf.call("abc", "c")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-8.js new file mode 100644 index 0000000000..8a94cd4945 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-8.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to String object +---*/ + +var obj = new String("undefined"); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, "f"), 4, 'Array.prototype.lastIndexOf.call(obj, "f")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-9.js new file mode 100644 index 0000000000..d01b502e5d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-9.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Function object +---*/ + +var obj = function(a, b) { + return a + b; +}; +obj[1] = true; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-1.js new file mode 100644 index 0000000000..1b26440d04 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-1.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own data property on an + Array-like object +---*/ + +var obj = { + 1: null, + 2: undefined, + length: 2 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, null), 1, 'Array.prototype.lastIndexOf.call(obj, null)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, undefined), -1, 'Array.prototype.lastIndexOf.call(obj, undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-10.js new file mode 100644 index 0000000000..672f273669 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-10.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is inherited accessor + property on an Array-like object +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[1] = 1; +child[2] = 2; + +assert.sameValue(Array.prototype.lastIndexOf.call(child, 1), 1, 'Array.prototype.lastIndexOf.call(child, 1)'); +assert.sameValue(Array.prototype.lastIndexOf.call(child, 2), -1, 'Array.prototype.lastIndexOf.call(child, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-11.js new file mode 100644 index 0000000000..e5008d2ffb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-11.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property + without a get function on an Array-like object +---*/ + +var obj = { + 0: 1 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), -1, 'Array.prototype.lastIndexOf.call(obj, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-12.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-12.js new file mode 100644 index 0000000000..a9bbce058e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-12.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property + without a get function that overrides an inherited accessor + property on an Array-like object +---*/ + +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 20; + }, + configurable: true +}); + +var obj = { + 1: 1 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), -1, 'Array.prototype.lastIndexOf.call(obj, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-13.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-13.js new file mode 100644 index 0000000000..dcecfb9241 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-13.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is inherited accessor + property without a get function on an Array-like object +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = true; + +assert.sameValue(Array.prototype.lastIndexOf.call(child, true), -1, 'Array.prototype.lastIndexOf.call(child, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-14.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-14.js new file mode 100644 index 0000000000..58062484b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-14.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is undefined property on an + Array-like object +---*/ + +var obj = { + 0: null, + 1: undefined +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, null), -1, 'Array.prototype.lastIndexOf.call(obj, null)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-17.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-17.js new file mode 100644 index 0000000000..5e29cd9be5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-17.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to Arguments object which + implements its own property get method +---*/ + +var targetObj = function() {}; +var func = function(a, b) { + arguments[2] = function() {}; + return Array.prototype.lastIndexOf.call(arguments, targetObj) === 1 && + Array.prototype.lastIndexOf.call(arguments, arguments[2]) === -1; +}; + +assert(func(0, targetObj), 'func(0, targetObj) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-18.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-18.js new file mode 100644 index 0000000000..90c8ee9d56 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-18.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to String object which + implements its own property get method +---*/ + +var str = new String("012"); + +String.prototype[3] = "3"; + +assert.sameValue(Array.prototype.lastIndexOf.call(str, "2"), 2, 'Array.prototype.lastIndexOf.call(str, "2")'); +assert.sameValue(Array.prototype.lastIndexOf.call(str, "3"), -1, 'Array.prototype.lastIndexOf.call(str, "3")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-19.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-19.js new file mode 100644 index 0000000000..6278205ca0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-19.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to String object which + implements its own property get method +---*/ + +var obj = function(a, b) { + return a + b; +}; +obj[1] = "b"; +obj[2] = "c"; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, obj[1]), 1, 'Array.prototype.lastIndexOf.call(obj, obj[1])'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, obj[2]), -1, 'Array.prototype.lastIndexOf.call(obj, obj[2])'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-2.js new file mode 100644 index 0000000000..53f995706d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-2.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own data property on an + Array +---*/ + +var targetObj = {}; + +Array.prototype[2] = targetObj; + +assert.sameValue([0, targetObj].lastIndexOf(targetObj), 1, '[0, targetObj].lastIndexOf(targetObj)'); +assert.sameValue([0, 1].lastIndexOf(targetObj), -1, '[0, 1].lastIndexOf(targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-3.js new file mode 100644 index 0000000000..b280836efe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own data property that + overrides an inherited data property on an Array-like object +---*/ + +var proto = { + length: 0 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +child[1] = child; + +assert.sameValue(Array.prototype.lastIndexOf.call(child, child), 1, 'Array.prototype.lastIndexOf.call(child, child)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-4.js new file mode 100644 index 0000000000..7289b10cef --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-4.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf when 'length' is own data property + that overrides an inherited data property on an Array +---*/ + +var targetObj = {}; +var arrProtoLen; + +arrProtoLen = Array.prototype.length; +Array.prototype.length = 0; + +assert.sameValue([0, targetObj, 2].lastIndexOf(targetObj), 1, '[0, targetObj, 2].lastIndexOf(targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-5.js new file mode 100644 index 0000000000..342a9b7b38 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-5.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own data property that + overrides an inherited accessor property on an Array-like object +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 0; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[1] = null; + +assert.sameValue(Array.prototype.lastIndexOf.call(child, null), 1, 'Array.prototype.lastIndexOf.call(child, null)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-6.js new file mode 100644 index 0000000000..c667d16d54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-6.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is an inherited data + property on an Array-like object +---*/ + +var proto = { + length: 2 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[1] = "x"; +child[2] = "y"; + +assert.sameValue(Array.prototype.lastIndexOf.call(child, "x"), 1, 'Array.prototype.lastIndexOf.call(child, "x")'); +assert.sameValue(Array.prototype.lastIndexOf.call(child, "y"), -1, 'Array.prototype.lastIndexOf.call(child, "y")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-7.js new file mode 100644 index 0000000000..c288c87c01 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-7.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property on + an Array-like object +---*/ + +var obj = { + 1: true, + 2: false +}; + +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, false), -1, 'Array.prototype.lastIndexOf.call(obj, false)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-8.js new file mode 100644 index 0000000000..6bc99e9075 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-8.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property + that overrides an inherited data property on an Array-like object +---*/ + +var proto = { + length: 0 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[1] = eval; + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(child, eval), 1, 'Array.prototype.lastIndexOf.call(child, eval)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-9.js new file mode 100644 index 0000000000..eeaf5fea4e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-9.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property + that overrides an inherited accessor property on an Array-like + object +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 0; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[1] = true; + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(child, true), 1, 'Array.prototype.lastIndexOf.call(child, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-1.js new file mode 100644 index 0000000000..f86e3f5311 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-1.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - value of 'length' is undefined +---*/ + +var obj = { + 0: 1, + 1: 1, + length: undefined +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), -1, 'Array.prototype.lastIndexOf.call(obj, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-10.js new file mode 100644 index 0000000000..a5c9bddfda --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-10.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is NaN) +---*/ + +var obj = { + 0: 0, + length: NaN +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), -1, 'Array.prototype.lastIndexOf.call(obj, 0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-11.js new file mode 100644 index 0000000000..c86e83fedb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-11.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing positive number +---*/ + +var obj = { + 1: true, + 2: false, + length: "2" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, false), -1, 'Array.prototype.lastIndexOf.call(obj, false)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-12.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-12.js new file mode 100644 index 0000000000..354a3df9a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-12.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing negative number +---*/ + +var obj = { + 1: null, + 2: undefined, + length: "-4294967294" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, null), -1, 'Array.prototype.lastIndexOf.call(obj, null)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, undefined), -1, 'Array.prototype.lastIndexOf.call(obj, undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-13.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-13.js new file mode 100644 index 0000000000..e5e15da4a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-13.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing a decimal number +---*/ + +var obj = { + 4: 4, + 5: 5, + length: "5.512345" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 4), 4, 'Array.prototype.lastIndexOf.call(obj, 4)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 5), -1, 'Array.prototype.lastIndexOf.call(obj, 5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-14.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-14.js new file mode 100644 index 0000000000..efae423b3d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-14.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing -Infinity +---*/ + +var objThree = { + 0: true, + 1: true, + length: "-Infinity" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(objThree, true), -1, 'Array.prototype.lastIndexOf.call(objThree, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-15.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-15.js new file mode 100644 index 0000000000..ad686a0d7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-15.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing an exponential number +---*/ + +var obj = { + 229: 229, + 230: 2.3E2, + length: "2.3E2" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 229), 229, 'Array.prototype.lastIndexOf.call(obj, 229)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2.3E2), -1, 'Array.prototype.lastIndexOf.call(obj, 2.3E2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-16.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-16.js new file mode 100644 index 0000000000..8a834a9473 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-16.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string which + is able to be converted into hex number +---*/ + +var obj = { + 2573: 2573, + 2574: 0x000A0E, + length: "0x000A0E" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2573), 2573, 'Array.prototype.lastIndexOf.call(obj, 2573)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0x000A0E), -1, 'Array.prototype.lastIndexOf.call(obj, 0x000A0E)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-17.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-17.js new file mode 100644 index 0000000000..00f1012438 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-17.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing a number with leading zeros +---*/ + +var obj = { + 1: 1, + 2: 2, + length: "0002.0" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), 1, 'Array.prototype.lastIndexOf.call(obj, 1)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), -1, 'Array.prototype.lastIndexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-18.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-18.js new file mode 100644 index 0000000000..913eef31ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-18.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string that + can't convert to a number +---*/ + +var targetObj = new String("123abc123"); +var obj = { + 0: targetObj, + length: "123abc123" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), -1, 'Array.prototype.lastIndexOf.call(obj, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-19.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-19.js new file mode 100644 index 0000000000..fd1ee62626 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-19.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is an Object which + has an own toString method +---*/ + +// objects inherit the default valueOf() method from Object +// that simply returns itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. + +var targetObj = this; +var obj = { + 1: targetObj, + 2: 2, + + length: { + toString: function() { + return '2'; + } + } +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), 1, 'Array.prototype.lastIndexOf.call(obj, targetObj)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), -1, 'Array.prototype.lastIndexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-2.js new file mode 100644 index 0000000000..025ec6cb7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-2.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf return -1 when value of 'length' is a + boolean (value is true) +---*/ + +var obj = { + 0: 0, + 1: 1, + length: true +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), 0, 'Array.prototype.lastIndexOf.call(obj, 0)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), -1, 'Array.prototype.lastIndexOf.call(obj, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-20.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-20.js new file mode 100644 index 0000000000..880f103161 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-20.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is an Object which + has an own valueOf method +---*/ + +//valueOf method will be invoked first, since hint is Number +var obj = { + 1: true, + 2: 2, + + length: { + valueOf: function() { + return 2; + } + } +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), -1, 'Array.prototype.lastIndexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-21.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-21.js new file mode 100644 index 0000000000..274586c363 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-21.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is an object that has an + own valueOf method that returns an object and toString method that + returns a string +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var targetObj = this; +var obj = { + 1: targetObj, + length: { + toString: function() { + toStringAccessed = true; + return '3'; + }, + + valueOf: function() { + valueOfAccessed = true; + return {}; + } + } +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), 1, 'Array.prototype.lastIndexOf.call(obj, targetObj)'); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-22.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-22.js new file mode 100644 index 0000000000..69b038aec8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-22.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf throws TypeError exception when + 'length' is an object with toString and valueOf methods that don�t + return primitive values +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var obj = { + 1: true, + length: { + toString: function() { + toStringAccessed = true; + return {}; + }, + + valueOf: function() { + valueOfAccessed = true; + return {}; + } + } +}; + +assert.throws(TypeError, function() { + Array.prototype.lastIndexOf.call(obj, true); +}); + +assert(toStringAccessed, 'toStringAccessed'); +assert(valueOfAccessed, 'valueOfAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-23.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-23.js new file mode 100644 index 0000000000..af48742adb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-23.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf uses inherited valueOf method when + 'length' is an object with an own toString and an inherited + valueOf methods +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return 2; +}; + +var obj = { + 1: child, + length: child +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, child), 1, 'Array.prototype.lastIndexOf.call(obj, child)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-24.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-24.js new file mode 100644 index 0000000000..ed6f48f6f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-24.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +var obj = { + 122: true, + 123: false, + length: 123.5 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 122, 'Array.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, false), -1, 'Array.prototype.lastIndexOf.call(obj, false)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-25.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-25.js new file mode 100644 index 0000000000..585ab0d4c7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-25.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a negative + non-integer +---*/ + +var obj = { + 1: true, + 2: false, + length: -4294967294.5 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), -1, 'Array.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, false), -1, 'Array.prototype.lastIndexOf.call(obj, false)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-28.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-28.js new file mode 100644 index 0000000000..24ea851f8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-28.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is boundary value + (2^32) +---*/ + +var targetObj = {}; +var obj = { + 0: targetObj, + 4294967294: targetObj, + 4294967295: targetObj, + length: 4294967296 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), 4294967295, 'verify length is 4294967296 finally'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-3.js new file mode 100644 index 0000000000..de944fac4f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is 0) +---*/ + +var obj = { + 0: "undefined", + length: 0 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, "undefined"), -1, 'Array.prototype.lastIndexOf.call(obj, "undefined")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-4.js new file mode 100644 index 0000000000..34a8125362 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-4.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is -0) +---*/ + +var obj = { + 0: true, + length: -0 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), -1, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-5.js new file mode 100644 index 0000000000..6afbbdf2ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-5.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is +0) +---*/ + +var obj = { + 0: +0, + length: +0 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, +0), -1, 'Array.prototype.lastIndexOf.call(obj, +0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-6.js new file mode 100644 index 0000000000..8eda321c5c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-6.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is a positive number) +---*/ + +var obj = { + 99: true, + 100: 100, + length: 100 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 99, 'Array.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 100), -1, 'Array.prototype.lastIndexOf.call(obj, 100)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-7.js new file mode 100644 index 0000000000..1927b2a448 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-7.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is a negative number) +---*/ + +var obj = { + 4: -Infinity, + 5: Infinity, + length: 5 - Math.pow(2, 32) +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, -Infinity), -1, 'Array.prototype.lastIndexOf.call(obj, -Infinity)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, Infinity), -1, 'Array.prototype.lastIndexOf.call(obj, Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-9.js new file mode 100644 index 0000000000..30c8ef8f83 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-9.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is -Infinity) +---*/ + +var obj = { + 0: 0, + length: -Infinity +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), -1, 'Array.prototype.lastIndexOf.call(obj, 0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-1.js new file mode 100644 index 0000000000..bfb23e02ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-1.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 (empty + array) +---*/ + +var i = [].lastIndexOf(42); + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-10.js new file mode 100644 index 0000000000..5f8f630970 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-10.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - 'length' is a number of value -6e-1 +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: -6e-1 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), -1, 'Array.prototype.lastIndexOf.call(obj, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-11.js new file mode 100644 index 0000000000..c61d585b22 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-11.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - 'length' is an empty string +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: "" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), -1, 'Array.prototype.lastIndexOf.call(obj, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-2.js new file mode 100644 index 0000000000..4d0ede9e0c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-2.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 ( length + overridden to null (type conversion)) +---*/ + +var i = Array.prototype.lastIndexOf.call({ + length: null +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-3.js new file mode 100644 index 0000000000..baa7664f32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 (length + overridden to false (type conversion)) +---*/ + +var i = Array.prototype.lastIndexOf.call({ + length: false +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-4.js new file mode 100644 index 0000000000..c244013353 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-4.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 (generic + 'array' with length 0 ) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 0; + +var i = Array.prototype.lastIndexOf.call({ + length: 0 +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-5.js new file mode 100644 index 0000000000..0e714da0d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-5.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 ( length + overridden to '0' (type conversion)) +---*/ + +var i = Array.prototype.lastIndexOf.call({ + length: '0' +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-6.js new file mode 100644 index 0000000000..a306208a54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-6.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 + (subclassed Array, length overridden with obj with valueOf) +---*/ + +var i = Array.prototype.lastIndexOf.call({ + length: { + valueOf: function() { + return 0; + } + } +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-7.js new file mode 100644 index 0000000000..427740b352 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-7.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 ( length + is object overridden with obj w/o valueOf (toString)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +var i = Array.prototype.lastIndexOf.call({ + length: { + toString: function() { + return '0'; + } + } +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-8.js new file mode 100644 index 0000000000..cf499e8c88 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-8.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 (length is + an empty array) +---*/ + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +var i = Array.prototype.lastIndexOf.call({ + length: [] +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-9.js new file mode 100644 index 0000000000..8f45c25286 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-9.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - 'length' is a number of value 0.1 +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: 0.1 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), -1, 'Array.prototype.lastIndexOf.call(obj, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-1.js new file mode 100644 index 0000000000..d3cdfb1cc3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is string +---*/ + +var a = new Array(0, 1, 1); + +assert.sameValue(a.lastIndexOf(1, "1"), 1, '"1" resolves to 1'); +assert.sameValue(a.lastIndexOf(1, "one"), -1, 'NaN string resolves to 01'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-10.js new file mode 100644 index 0000000000..54e6f8d483 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-10.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is positive number) +---*/ + +var targetObj = {}; + +assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, 1.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, 1.5)'); +assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, 1.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, 1.5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-11.js new file mode 100644 index 0000000000..a7ba8fac31 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-11.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is negative number) +---*/ + +var targetObj = {}; + +assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, -2.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, -2.5)'); +assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, -2.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, -2.5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-12.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-12.js new file mode 100644 index 0000000000..d43456a631 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-12.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is Infinity) +---*/ + +var arr = []; +arr[Math.pow(2, 32) - 2] = null; // length is the max value of Uint type + +assert.sameValue(arr.lastIndexOf(null, Infinity), Math.pow(2, 32) - 2, 'arr.lastIndexOf(null, Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-13.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-13.js new file mode 100644 index 0000000000..8dd7c0b72d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-13.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is -Infinity) +---*/ + +assert.sameValue([true].lastIndexOf(true, -Infinity), -1, '[true].lastIndexOf(true, -Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-14.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-14.js new file mode 100644 index 0000000000..719c88cd1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-14.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is NaN) +---*/ + +// from Index will be convert to +0 +assert.sameValue([0, true].lastIndexOf(true, NaN), -1, '[0, true].lastIndexOf(true, NaN)'); +assert.sameValue([true, 0].lastIndexOf(true, NaN), 0, '[true, 0].lastIndexOf(true, NaN)'); +assert.sameValue([0, true].lastIndexOf(true, -NaN), -1, '[0, true].lastIndexOf(true, -NaN)'); +assert.sameValue([true, 0].lastIndexOf(true, -NaN), 0, '[true, 0].lastIndexOf(true, -NaN)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-15.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-15.js new file mode 100644 index 0000000000..5e0bea2c89 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-15.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing a negative number +---*/ + +assert.sameValue([0, "-2", 2].lastIndexOf("-2", "-2"), 1, '[0, "-2", 2].lastIndexOf("-2", "-2")'); +assert.sameValue([0, 2, "-2"].lastIndexOf("-2", "-2"), -1, '[0, 2, "-2"].lastIndexOf("-2", "-2")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-16.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-16.js new file mode 100644 index 0000000000..3732ca9a21 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-16.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing Infinity +---*/ + +var arr = []; +arr[Math.pow(2, 32) - 2] = true; // length is the max value of Uint type + +assert.sameValue(arr.lastIndexOf(true, "Infinity"), Math.pow(2, 32) - 2, 'arr.lastIndexOf(true, "Infinity")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-17.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-17.js new file mode 100644 index 0000000000..cbb216b417 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-17.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing -Infinity +---*/ + +assert.sameValue([true].lastIndexOf(true, "-Infinity"), -1, '[true].lastIndexOf(true, "-Infinity")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-18.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-18.js new file mode 100644 index 0000000000..f38439c1c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-18.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing an exponential number +---*/ + +var targetObj = {}; + +assert.sameValue([0, NaN, targetObj, 3, false].lastIndexOf(targetObj, "2E0"), 2, '[0, NaN, targetObj, 3, false].lastIndexOf(targetObj, "2E0")'); +assert.sameValue([0, NaN, 3, targetObj, false].lastIndexOf(targetObj, "2E0"), -1, '[0, NaN, 3, targetObj, false].lastIndexOf(targetObj, "2E0")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-19.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-19.js new file mode 100644 index 0000000000..6045c3150d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-19.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing a hex number +---*/ + +var targetObj = {}; + +assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, "0x0002"), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, "0x0002")'); +assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, "0x0002"), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, "0x0002")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-2.js new file mode 100644 index 0000000000..81044c0f9a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-2.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is floating point number +---*/ + +var a = new Array(1, 2, 1); + +assert.sameValue(a.lastIndexOf(2, 1.49), 1, '1.49 resolves to 1'); +assert.sameValue(a.lastIndexOf(2, 0.51), -1, '0.51 resolves to 0'); +assert.sameValue(a.lastIndexOf(1, 0.51), 0, '0.51 resolves to 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-20.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-20.js new file mode 100644 index 0000000000..d4aeda529e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-20.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' which is a + string containing a number with leading zeros +---*/ + +var targetObj = {}; + +assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, "0002.10"), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, "0002.10")'); +assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, "0002.10"), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, "0002.10")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-21.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-21.js new file mode 100644 index 0000000000..135ca125b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-21.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' which is an + Object, and has an own toString method +---*/ + +// objects inherit the default valueOf() method from Object +// that simply returns itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +var fromIndex = { + toString: function() { + return '2'; + } +}; +var targetObj = new RegExp(); + +assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex)'); +assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-22.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-22.js new file mode 100644 index 0000000000..66c7181a62 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-22.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' which is an + object, and has an own valueOf method +---*/ + +var fromIndex = { + valueOf: function() { + return 2; + } +}; + +var targetObj = function() {}; + +assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex)'); +assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js new file mode 100644 index 0000000000..5b47483aba --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is an object + that has an own valueOf method that returns an object and toString + method that returns a string +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var fromIndex = { + toString: function() { + toStringAccessed = true; + return '1'; + }, + + valueOf: function() { + valueOfAccessed = true; + return {}; + } +}; + +assert.sameValue([0, true].lastIndexOf(true, fromIndex), 1, '[0, true].lastIndexOf(true, fromIndex)'); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js new file mode 100644 index 0000000000..241fd28960 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf throws TypeError exception when value + of 'fromIndex' is an object that both toString and valueOf methods + than don't return primitive value +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var fromIndex = { + toString: function() { + toStringAccessed = true; + return {}; + }, + + valueOf: function() { + valueOfAccessed = true; + return {}; + } +}; + +assert.throws(TypeError, function() { + [0, null].lastIndexOf(null, fromIndex); +}); + +assert(toStringAccessed, 'toStringAccessed'); +assert(valueOfAccessed, 'valueOfAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-25.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-25.js new file mode 100644 index 0000000000..880fd7b678 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-25.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf use inherited valueOf method when + value of 'fromIndex' is an object with an own toString and + inherited valueOf methods +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 1; + } +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return 1; +}; + +assert.sameValue([0, true].lastIndexOf(true, child), 1, '[0, true].lastIndexOf(true, child)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-26.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-26.js new file mode 100644 index 0000000000..99f034bb86 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-26.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var stepTwoOccurs = false; +var stepFiveOccurs = false; +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + stepTwoOccurs = true; + if (stepFiveOccurs) { + throw new Error("Step 5 occurred out of order"); + } + return 20; + }, + configurable: true +}); + +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; + +Array.prototype.lastIndexOf.call(obj, undefined, fromIndex); + +assert(stepTwoOccurs, 'stepTwoOccurs !== true'); +assert(stepFiveOccurs, 'stepFiveOccurs !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-27.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-27.js new file mode 100644 index 0000000000..446fa542ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-27.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var stepThreeOccurs = false; +var stepFiveOccurs = false; + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + return { + valueOf: function() { + stepThreeOccurs = true; + if (stepFiveOccurs) { + throw new Error("Step 5 occurred out of order"); + } + return 20; + } + }; + }, + configurable: true +}); + +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; + +Array.prototype.lastIndexOf.call(obj, undefined, fromIndex); + +assert(stepThreeOccurs, 'stepThreeOccurs !== true'); +assert(stepFiveOccurs, 'stepFiveOccurs !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-28.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-28.js new file mode 100644 index 0000000000..27b7d245bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-28.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 1 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(TypeError, function() { + Array.prototype.lastIndexOf.call(undefined, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-29.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-29.js new file mode 100644 index 0000000000..c5a9ce14be --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-29.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + throw new RangeError(); + }, + configurable: true +}); + +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(RangeError, function() { + Array.prototype.lastIndexOf.call(obj, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-3.js new file mode 100644 index 0000000000..56bfd0e78b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-3.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is boolean +---*/ + +var a = new Array(1, 2, 1); + +assert.sameValue(a.lastIndexOf(2, true), 1, 'true resolves to 1'); +assert.sameValue(a.lastIndexOf(2, false), -1, 'false resolves to 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-30.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-30.js new file mode 100644 index 0000000000..4d4f6f0633 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-30.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return { + valueOf: function() { + throw new TypeError(); + } + }; + }, + configurable: true +}); + +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(TypeError, function() { + Array.prototype.lastIndexOf.call(obj, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-31.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-31.js new file mode 100644 index 0000000000..7c4c6a233a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-31.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'fromIndex' is a positive + non-integer, verify truncation occurs in the proper direction +---*/ + +var targetObj = {}; + +assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, 1.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, 1.5)'); +assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, 1.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, 1.5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-32.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-32.js new file mode 100644 index 0000000000..8e1431b6b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-32.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'fromIndex' is a negative + non-integer, verify truncation occurs in the proper direction +---*/ + +var targetObj = {}; + +assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, -2.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, -2.5)'); +assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, -2.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, -2.5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-33.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-33.js new file mode 100644 index 0000000000..6768c47c48 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-33.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - match on the first element, a middle + element and the last element when 'fromIndex' is passed +---*/ + +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(0, 0), 0, '[0, 1, 2, 3, 4].lastIndexOf(0, 0)'); +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(0, 2), 0, '[0, 1, 2, 3, 4].lastIndexOf(0, 2)'); +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(2, 2), 2, '[0, 1, 2, 3, 4].lastIndexOf(2, 2)'); +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(2, 4), 2, '[0, 1, 2, 3, 4].lastIndexOf(2, 4)'); +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(4, 4), 4, '[0, 1, 2, 3, 4].lastIndexOf(4, 4)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-4.js new file mode 100644 index 0000000000..6ae526981b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-4.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is undefined +---*/ + +var a = new Array(1, 2, 1); + +// undefined resolves to 0, no second argument resolves to len +assert.sameValue(a.lastIndexOf(2, undefined), -1, 'a.lastIndexOf(2,undefined)'); +assert.sameValue(a.lastIndexOf(1, undefined), 0, 'a.lastIndexOf(1,undefined)'); +assert.sameValue(a.lastIndexOf(1), 2, 'a.lastIndexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-5.js new file mode 100644 index 0000000000..1c5773d639 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-5.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is null +---*/ + +var a = new Array(1, 2, 1); + +// null resolves to 0 +assert.sameValue(a.lastIndexOf(2, null), -1, 'a.lastIndexOf(2,null)'); +assert.sameValue(a.lastIndexOf(1, null), 0, 'a.lastIndexOf(1,null)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-6.js new file mode 100644 index 0000000000..80cc1a0171 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-6.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when 'fromIndex' isn't passed +---*/ + +var arr = [0, 1, 2, 3, 4]; +//'fromIndex' will be set as 4 if not passed by default + +assert.sameValue(arr.lastIndexOf(0), arr.lastIndexOf(0, 4), 'arr.lastIndexOf(0)'); +assert.sameValue(arr.lastIndexOf(2), arr.lastIndexOf(2, 4), 'arr.lastIndexOf(2)'); +assert.sameValue(arr.lastIndexOf(4), arr.lastIndexOf(4, 4), 'arr.lastIndexOf(4)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-7.js new file mode 100644 index 0000000000..a35ae973b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-7.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is 0) +---*/ + +assert.sameValue([0, 100].lastIndexOf(100, 0), -1, 'verify fromIndex is not more than 0'); +assert.sameValue([200, 0].lastIndexOf(200, 0), 0, 'verify fromIndex is not less than 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-8.js new file mode 100644 index 0000000000..3197f71bf5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-8.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is +0) +---*/ + +assert.sameValue([0, true].lastIndexOf(true, +0), -1, '[0, true].lastIndexOf(true, +0)'); +assert.sameValue([true, 0].lastIndexOf(true, +0), 0, '[true, 0].lastIndexOf(true, +0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-9.js new file mode 100644 index 0000000000..c253f21f73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-9.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is -0) +---*/ + +assert.sameValue([0, true].lastIndexOf(true, -0), -1, '[0, true].lastIndexOf(true, -0)'); +assert.sameValue([true, 0].lastIndexOf(true, -0), 0, '[true, 0].lastIndexOf(true, -0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-1.js new file mode 100644 index 0000000000..955920f7ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-1.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf when fromIndex greater than + Array.length +---*/ + +var a = new Array(1, 2, 3); + +assert.sameValue(a.lastIndexOf(3, 5.4), 2, 'a.lastIndexOf(3,5.4)'); +assert.sameValue(a.lastIndexOf(3, 3.1), 2, 'a.lastIndexOf(3,3.1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-2.js new file mode 100644 index 0000000000..f0844197a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns correct index when 'fromIndex' + is length of array - 1 +---*/ + +assert.sameValue([1, 2, 3].lastIndexOf(3, 2), 2, '[1, 2, 3].lastIndexOf(3, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-3.js new file mode 100644 index 0000000000..ee9c2981b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-3.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 when 'fromIndex' is length + of array - 1 +---*/ + +assert.sameValue([1, 2, 3].lastIndexOf(3, 1), -1, '[1, 2, 3].lastIndexOf(3, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-4.js new file mode 100644 index 0000000000..8bdf1136b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-4.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 when 'fromIndex' and + 'length' are both 0 +---*/ + +assert.sameValue([].lastIndexOf(1, 0), -1, '[].lastIndexOf(1, 0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-5.js new file mode 100644 index 0000000000..7446566b69 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-5.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf returns -1 when 'fromIndex' is 1 +---*/ + +assert.sameValue([1, 2, 3].lastIndexOf(3, 1), -1, '[1, 2, 3].lastIndexOf(3, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-6.js new file mode 100644 index 0000000000..b298623733 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-6.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns correct index when 'fromIndex' + is 1 +---*/ + +assert.sameValue([1, 2, 3].lastIndexOf(2, 1), 1, '[1, 2, 3].lastIndexOf(2, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-1.js new file mode 100644 index 0000000000..b80100b7e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-1.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf with negative fromIndex +---*/ + +var a = new Array(1, 2, 3); + + +assert.sameValue(a.lastIndexOf(2, -2), 1, 'a.lastIndexOf(2,-2)'); +assert.sameValue(a.lastIndexOf(2, -3), -1, 'a.lastIndexOf(2,-3)'); +assert.sameValue(a.lastIndexOf(1, -5.3), -1, 'a.lastIndexOf(1,-5.3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-2.js new file mode 100644 index 0000000000..3cf39efa6b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns correct index when 'fromIndex' + is -1 +---*/ + +assert.sameValue([1, 2, 3, 4].lastIndexOf(4, -1), 3, '[1, 2, 3, 4].lastIndexOf(4, -1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-3.js new file mode 100644 index 0000000000..dfd6dcbf92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-3.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 when abs('fromIndex') is + length of array - 1 +---*/ + +assert.sameValue([1, 2, 3, 4].lastIndexOf(3, -3), -1, '[1, 2, 3, 4].lastIndexOf(3, -3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-4.js new file mode 100644 index 0000000000..460ed58951 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-4.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 when abs('fromIndex') is + length of array +---*/ + +assert.sameValue([1, 2, 3, 4].lastIndexOf(2, -4), -1, '[1, 2, 3, 4].lastIndexOf(2, -4)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-1.js new file mode 100644 index 0000000000..1c260c4cb9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-1.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(boolean) +---*/ + +var obj = { + toString: function() { + return true + } +}; +var _false = false; +var a = new Array(false, true, false, obj, _false, true, "true", undefined, 0, null, 1, "str", 0, 1); + +assert.sameValue(a.lastIndexOf(true), 5, 'a[5]=true'); +assert.sameValue(a.lastIndexOf(false), 4, 'a[4] =_false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-10.js new file mode 100644 index 0000000000..2915a82e7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-10.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + note that prior to the finally ES5 draft SameValue was used for comparisions + and hence NaNs could be found using lastIndexOf * +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index (NaN) +---*/ + +var _NaN = NaN; +var a = new Array("NaN", _NaN, NaN, undefined, 0, false, null, { + toString: function() { + return NaN + } +}, "false"); + +assert.sameValue(a.lastIndexOf(NaN), -1, 'NaN matches nothing, not even itself'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-11.js new file mode 100644 index 0000000000..27fcf1ddfa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-11.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - the length of iteration isn't + changed by adding elements to the array during iteration +---*/ + +var arr = [20]; + +Object.defineProperty(arr, "0", { + get: function() { + arr[1] = 1; + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(1), -1, 'arr.lastIndexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-2.js new file mode 100644 index 0000000000..bd64d700ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-2.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(Number) +---*/ + +var obj = { + toString: function() { + return 0 + } +}; +var one = 1; +var _float = -(4 / 3); +var a = new Array(+0, true, 0, -0, false, undefined, null, "0", obj, _float, -(4 / 3), -1.3333333333333, "str", one, 1, false); + +assert.sameValue(a.lastIndexOf(-(4 / 3)), 10, 'a[10]=-(4/3)'); +assert.sameValue(a.lastIndexOf(0), 3, 'a[3] = -0, but using === -0 and 0 are equal'); +assert.sameValue(a.lastIndexOf(-0), 3, 'a[3] = -0'); +assert.sameValue(a.lastIndexOf(1), 14, 'a[14] = 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-3.js new file mode 100644 index 0000000000..253cc86161 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-3.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(string) +---*/ + +var obj = { + toString: function() { + return "false" + } +}; +var szFalse = "false"; +var a = new Array(szFalse, "false", "false1", undefined, 0, false, null, 1, obj, 0); + +assert.sameValue(a.lastIndexOf("false"), 1, 'a.lastIndexOf("false")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-4.js new file mode 100644 index 0000000000..f32dfa8da7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-4.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(undefined) +---*/ + +var obj = { + toString: function() { + return undefined; + } +}; +var _undefined1 = undefined; +var _undefined2; +var a = new Array(_undefined1, _undefined2, undefined, true, 0, false, null, 1, "undefined", obj, 1); + +assert.sameValue(a.lastIndexOf(undefined), 2, 'a.lastIndexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-5.js new file mode 100644 index 0000000000..70abd20bc2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-5.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(Object) +---*/ + +var obj1 = { + toString: function() { + return "false" + } +}; +var obj2 = { + toString: function() { + return "false" + } +}; +var obj3 = obj1; +var a = new Array(obj2, obj1, obj3, false, undefined, 0, false, null, { + toString: function() { + return "false" + } +}, "false"); + +assert.sameValue(a.lastIndexOf(obj3), 2, 'a.lastIndexOf(obj3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-6.js new file mode 100644 index 0000000000..6dcade2541 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-6.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(null) +---*/ + +var obj = { + toString: function() { + return null + } +}; +var _null = null; +var a = new Array(true, undefined, 0, false, null, 1, "str", 0, 1, null, true, false, undefined, _null, "null", undefined, "str", obj); + +assert.sameValue(a.lastIndexOf(null), 13, 'a.lastIndexOf(null)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js new file mode 100644 index 0000000000..c564170300 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf must return correct index (self + reference) +---*/ + +var a = new Array(0, 1, 2, 3); +a[2] = a; + +assert.sameValue(a.lastIndexOf(a), 2, 'a.lastIndexOf(a)'); +assert.sameValue(a.lastIndexOf(3), 3, 'a.lastIndexOf(3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-8.js new file mode 100644 index 0000000000..d31afa8f21 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-8.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index (Array) +---*/ + +var b = new Array("0,1"); +var a = new Array(0, b, "0,1", 3); + +assert.sameValue(a.lastIndexOf(b.toString()), 2, 'a.lastIndexOf(b.toString())'); +assert.sameValue(a.lastIndexOf("0,1"), 2, 'a.lastIndexOf("0,1")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-9.js new file mode 100644 index 0000000000..142287e556 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-9.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf must return correct index (Sparse + Array) +---*/ + +var a = new Array(0, 1); +a[4294967294] = 2; // 2^32-2 - is max array element index +a[4294967295] = 3; // 2^32-1 added as non-array element property +a[4294967296] = 4; // 2^32 added as non-array element property +a[4294967297] = 5; // 2^32+1 added as non-array element property +// stop searching near the end in case implementation actually tries to test all missing elements!! +a[4294967200] = 3; +a[4294967201] = 4; +a[4294967202] = 5; + + +assert.sameValue(a.lastIndexOf(2), 4294967294, 'a.lastIndexOf(2)'); +assert.sameValue(a.lastIndexOf(3), 4294967200, 'a.lastIndexOf(3)'); +assert.sameValue(a.lastIndexOf(4), 4294967201, 'a.lastIndexOf(4)'); +assert.sameValue(a.lastIndexOf(5), 4294967202, 'a.lastIndexOf(5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-1.js new file mode 100644 index 0000000000..842ce1212e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-1.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - added properties in step 2 are + visible here +---*/ + +var arr = {}; + +Object.defineProperty(arr, "length", { + get: function() { + arr[2] = "length"; + return 3; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, "length"), 2, 'Array.prototype.lastIndexOf.call(arr, "length")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-10.js new file mode 100644 index 0000000000..7203adc20b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-10.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - properties can be added to prototype + after current position are visited on an Array +---*/ + +var arr = [0, , 2]; + +Object.defineProperty(arr, "2", { + get: function() { + Object.defineProperty(Array.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(6.99), 1, 'arr.lastIndexOf(6.99)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-11.js new file mode 100644 index 0000000000..76ccef72e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-11.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting own property causes index + property not to be visited on an Array-like object +---*/ + +var arr = { + length: 200 +}; + +Object.defineProperty(arr, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); + +Object.defineProperty(arr, "100", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, 6.99), -1, 'Array.prototype.lastIndexOf.call(arr, 6.99)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-12.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-12.js new file mode 100644 index 0000000000..2f2acfd10e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-12.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting own property causes index + property not to be visited on an Array +---*/ + +var arr = [1, 2, 3, 4]; + +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); + +Object.defineProperty(arr, "3", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf("6.99"), -1, 'arr.lastIndexOf("6.99")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-13.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-13.js new file mode 100644 index 0000000000..71733f1f61 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-13.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting property of prototype + causes prototype index property not to be visited on an Array-like + Object +---*/ + +var arr = { + 2: 2, + length: 20 +}; + +Object.defineProperty(arr, "3", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, 1), -1, 'Array.prototype.lastIndexOf.call(arr, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-14.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-14.js new file mode 100644 index 0000000000..f9a2d957c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-14.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting property of prototype + causes prototype index property not to be visited on an Array +---*/ + +var arr = [0, , 2]; + +Object.defineProperty(arr, "20", { + get: function() { + delete Array.prototype[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; + +assert.sameValue(arr.lastIndexOf(1), -1, 'arr.lastIndexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-15.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-15.js new file mode 100644 index 0000000000..c49c77510d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-15.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting own property with + prototype property causes prototype index property to be visited + on an Array-like object +---*/ + +var arr = { + 0: 0, + 1: 111, + 2: 2, + length: 10 +}; + +Object.defineProperty(arr, "6", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, 1), 1, 'Array.prototype.lastIndexOf.call(arr, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-16.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-16.js new file mode 100644 index 0000000000..1759de886d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-16.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting own property with + prototype property causes prototype index property to be visited + on an Array +---*/ + +var arr = [0, 111, 2]; + +Object.defineProperty(arr, "2", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; + +assert.sameValue(arr.lastIndexOf(1), 1, 'arr.lastIndexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-17.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-17.js new file mode 100644 index 0000000000..d31028ca92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-17.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - decreasing length of array causes + index property not to be visited +---*/ + +var arr = [0, 1, 2, "last", 4]; + +Object.defineProperty(arr, "4", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf("last"), -1, 'arr.lastIndexOf("last")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-18.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-18.js new file mode 100644 index 0000000000..8ca10a1747 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-18.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - decreasing length of array with + prototype property causes prototype index property to be visited +---*/ + +var arr = [0, 1, 2, 3, 4]; + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); + +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf("prototype"), 2, 'arr.lastIndexOf("prototype")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-19.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-19.js new file mode 100644 index 0000000000..5c83ccc2eb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-19.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - decreasing length of array does not + delete non-configurable properties +flags: [noStrict] +---*/ + +var arr = [0, 1, 2, 3]; + +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); + +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf("unconfigurable"), 2, 'arr.lastIndexOf("unconfigurable")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-2.js new file mode 100644 index 0000000000..ba60f5372e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-2.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - added properties in step 5 are + visible here on an Array-like object +---*/ + +var arr = { + length: 30 +}; +var targetObj = function() {}; + +var fromIndex = { + valueOf: function() { + arr[4] = targetObj; + return 10; + } +}; + + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, targetObj, fromIndex), 4, 'Array.prototype.lastIndexOf.call(arr, targetObj, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js new file mode 100644 index 0000000000..c2e793eca2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - added properties in step 5 are + visible here on an Array +---*/ + +var arr = []; +arr.length = 30; +var targetObj = function() {}; + +var fromIndex = { + valueOf: function() { + arr[4] = targetObj; + return 11; + } +}; + +assert.sameValue(arr.lastIndexOf(targetObj, fromIndex), 4, 'arr.lastIndexOf(targetObj, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-4.js new file mode 100644 index 0000000000..c679b73e99 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-4.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleted properties in step 2 are + visible here +---*/ + +var arr = { + 2: 6.99 +}; + +Object.defineProperty(arr, "length", { + get: function() { + delete arr[2]; + return 3; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, 6.99), -1, 'Array.prototype.lastIndexOf.call(arr, 6.99)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-5.js new file mode 100644 index 0000000000..e2334b5c8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-5.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleted properties of step 5 are + visible here on an Array-like object +---*/ + +var arr = { + 10: false, + length: 30 +}; + +var fromIndex = { + valueOf: function() { + delete arr[10]; + return 15; + } +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, false, fromIndex), -1, 'Array.prototype.lastIndexOf.call(arr, false, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-6.js new file mode 100644 index 0000000000..55b9946bcf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-6.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleted properties of step 5 are + visible here on an Array +---*/ + +var arr = []; +arr[10] = "10"; +arr.length = 20; + +var fromIndex = { + valueOf: function() { + delete arr[10]; + return 11; + } +}; + +assert.sameValue(arr.lastIndexOf("10", fromIndex), -1, 'arr.lastIndexOf("10", fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-7.js new file mode 100644 index 0000000000..2841b2d2ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-7.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - properties added into own object + after current position are visited on an Array-like object +---*/ + +var arr = { + length: 8 +}; + +Object.defineProperty(arr, "4", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, 1), 1, 'Array.prototype.lastIndexOf.call(arr, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-8.js new file mode 100644 index 0000000000..4ef6ff9545 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-8.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - properties added into own object + after current position are visited on an Array +---*/ + +var arr = [0, , 2]; + +Object.defineProperty(arr, "2", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(1), 1, 'arr.lastIndexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-9.js new file mode 100644 index 0000000000..4d49dddf43 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-9.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - properties can be added to + prototype after current position are visited on an Array-like + object +---*/ + +var arr = { + length: 9 +}; + +Object.defineProperty(arr, "4", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return Infinity; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, Infinity), 1, 'Array.prototype.lastIndexOf.call(arr, Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-1.js new file mode 100644 index 0000000000..0b41785a4c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-1.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - undefined property wouldn't be called +---*/ + +assert.sameValue([0, , 2].lastIndexOf(undefined), -1, '[0, , 2].lastIndexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-1.js new file mode 100644 index 0000000000..2742fd255f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-1.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property on an Array-like object +---*/ + +var obj = { + 0: 0, + 1: 1, + 2: 2, + length: 3 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), 0, 'Array.prototype.lastIndexOf.call(obj, 0)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), 1, 'Array.prototype.lastIndexOf.call(obj, 1)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), 2, 'Array.prototype.lastIndexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-10.js new file mode 100644 index 0000000000..bc71c16406 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-10.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property on an Array-like object +---*/ + +var obj = { + length: 3 +}; +Object.defineProperty(obj, "0", { + get: function() { + return 0; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +Object.defineProperty(obj, "2", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), 0, 'Array.prototype.lastIndexOf.call(obj, 0)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), 1, 'Array.prototype.lastIndexOf.call(obj, 1)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), 2, 'Array.prototype.lastIndexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-11.js new file mode 100644 index 0000000000..3da84aa06f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-11.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property that overrides an inherited data property on an + Array +---*/ + +var arr = []; + +Array.prototype[0] = false; +Object.defineProperty(arr, "0", { + get: function() { + return true; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(true), 0, 'arr.lastIndexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-12.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-12.js new file mode 100644 index 0000000000..e370128354 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-12.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property that overrides an inherited data property on an + Array-like object +---*/ + +var obj = { + length: 1 +}; + +Object.prototype[0] = false; +Object.defineProperty(obj, "0", { + get: function() { + return true; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 0, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-13.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-13.js new file mode 100644 index 0000000000..48fb0deee0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-13.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property that overrides an inherited accessor property on + an Array +---*/ + +var arr = []; + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + return true; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(true), 0, 'arr.lastIndexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-14.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-14.js new file mode 100644 index 0000000000..3242cd10a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-14.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property that overrides an inherited accessor property on + an Array-like object +---*/ + +var obj = { + length: 1 +}; + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); + +Object.defineProperty(obj, "0", { + get: function() { + return true; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 0, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-15.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-15.js new file mode 100644 index 0000000000..17af30793e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-15.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + accessor property on an Array +---*/ + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 10; + }, + configurable: true +}); + +Object.defineProperty(Array.prototype, "1", { + get: function() { + return 20; + }, + configurable: true +}); + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return 30; + }, + configurable: true +}); + +assert.sameValue([, , , ].lastIndexOf(10), 0, '[, , , ].lastIndexOf(10)'); +assert.sameValue([, , , ].lastIndexOf(20), 1, '[, , , ].lastIndexOf(20)'); +assert.sameValue([, , , ].lastIndexOf(30), 2, '[, , , ].lastIndexOf(30)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-16.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-16.js new file mode 100644 index 0000000000..08f99a3c0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-16.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return 10; + }, + configurable: true +}); + +Object.defineProperty(Object.prototype, "1", { + get: function() { + return 20; + }, + configurable: true +}); + +Object.defineProperty(Object.prototype, "2", { + get: function() { + return 30; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call({ + length: 3 +}, 10), 0, 'Array.prototype.lastIndexOf.call({ length: 3 }, 10)'); +assert.sameValue(Array.prototype.lastIndexOf.call({ + length: 3 +}, 20), 1, 'Array.prototype.lastIndexOf.call({ length: 3 }, 20)'); +assert.sameValue(Array.prototype.lastIndexOf.call({ + length: 3 +}, 30), 2, 'Array.prototype.lastIndexOf.call({ length: 3 }, 30)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-17.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-17.js new file mode 100644 index 0000000000..b14f5e38ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-17.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property without a get function on an Array +---*/ + +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(undefined), 0, 'arr.lastIndexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-18.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-18.js new file mode 100644 index 0000000000..4e0b52c9b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-18.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property without a get function on an Array-like object +---*/ + +var obj = { + length: 1 +}; +Object.defineProperty(obj, "0", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, undefined), 0, 'Array.prototype.lastIndexOf.call(obj, undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-19.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-19.js new file mode 100644 index 0000000000..c2aa8c19cb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-19.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property without a get function that overrides an + inherited accessor property on an Array-like object +---*/ + +var obj = { + length: 1 +}; + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return 20; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + set: function() {}, + configurable: true +}); + +assert(obj.hasOwnProperty(0), 'obj.hasOwnProperty(0) !== true'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, undefined), 0, 'Array.prototype.lastIndexOf.call(obj, undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-2.js new file mode 100644 index 0000000000..0d6bcdbe1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-2.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property on an Array +---*/ + +assert.sameValue([true, true, true].lastIndexOf(true), 2, '[true, true, true].lastIndexOf(true)'); +assert.sameValue([true, true, false].lastIndexOf(true), 1, '[true, true, false].lastIndexOf(true)'); +assert.sameValue([true, false, false].lastIndexOf(true), 0, '[true, false, false].lastIndexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-20.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-20.js new file mode 100644 index 0000000000..9cda64323e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-20.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is an own + accessor property without a get function that overrides an + inherited accessor property on an Array +---*/ + +var arr = [, 1]; + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 100; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +assert(arr.hasOwnProperty(0), 'arr.hasOwnProperty(0) !== true'); +assert.sameValue(arr.lastIndexOf(undefined), 0, 'arr.lastIndexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-21.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-21.js new file mode 100644 index 0000000000..35f9c4af84 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-21.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +Object.defineProperty(Array.prototype, "0", { + set: function() {}, + configurable: true +}); + +assert.sameValue([, ].lastIndexOf(undefined), 0, '[, ].lastIndexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-22.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-22.js new file mode 100644 index 0000000000..b870f4e856 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-22.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call({ + length: 1 +}, undefined), 0, 'Array.prototype.lastIndexOf.call({ length: 1 }, undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-25.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-25.js new file mode 100644 index 0000000000..38363b773b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-25.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +var func = function(a, b) { + return 0 === Array.prototype.lastIndexOf.call(arguments, arguments[0]) && + -1 === Array.prototype.lastIndexOf.call(arguments, arguments[1]); +}; + +assert(func(true), 'func(true) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-26.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-26.js new file mode 100644 index 0000000000..f3e209120c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-26.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to Arguments object which + implements its own property get method (number of arguments equals + to number of parameters) +---*/ + +var func = function(a, b) { + return 0 === Array.prototype.lastIndexOf.call(arguments, arguments[0]) && + 1 === Array.prototype.lastIndexOf.call(arguments, arguments[1]) && + -1 === Array.prototype.lastIndexOf.call(arguments, arguments[2]); +}; + +assert(func(0, true), 'func(0, true) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-27.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-27.js new file mode 100644 index 0000000000..9e8618f62c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-27.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +var func = function(a, b) { + assert.sameValue(Array.prototype.lastIndexOf.call(arguments, arguments[0]), 2); + assert.sameValue(Array.prototype.lastIndexOf.call(arguments, arguments[3]), 3); + assert.sameValue(Array.prototype.lastIndexOf.call(arguments, arguments[4]), -1); +}; + +(function() { + func(0, arguments, 0, Object.prototype); +})(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-28.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-28.js new file mode 100644 index 0000000000..6002512ccc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-28.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side-effects are visible in + subsequent iterations on an Array +---*/ + +var preIterVisible = false; +var arr = []; + +Object.defineProperty(arr, "2", { + get: function() { + preIterVisible = true; + return false; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return true; + } else { + return false; + } + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(true), 1, 'arr.lastIndexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-29.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-29.js new file mode 100644 index 0000000000..8add4d3af8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-29.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side-effects are visible in + subsequent iterations on an Array-like object +---*/ + +var preIterVisible = false; +var obj = { + length: 3 +}; + +Object.defineProperty(obj, "2", { + get: function() { + preIterVisible = true; + return false; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return true; + } else { + return false; + } + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-3.js new file mode 100644 index 0000000000..9df7282978 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-3.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +Array.prototype[0] = Object; + +assert.sameValue([Object.prototype].lastIndexOf(Object.prototype), 0, '[Object.prototype].lastIndexOf(Object.prototype)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-30.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-30.js new file mode 100644 index 0000000000..15798087fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-30.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf terminates iteration on unhandled + exception on an Array +---*/ + +var accessed = false; +var arr = []; + +Object.defineProperty(arr, "2", { + get: function() { + throw new TypeError(); + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + accessed = true; + return true; + }, + configurable: true +}); +assert.throws(TypeError, function() { + arr.lastIndexOf(true); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-31.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-31.js new file mode 100644 index 0000000000..638b3f2537 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-31.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf terminates iteration on unhandled + exception on an Array-like object +---*/ + +var accessed = false; +var obj = { + length: 3 +}; + +Object.defineProperty(obj, "2", { + get: function() { + throw new TypeError(); + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + accessed = true; + return true; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.lastIndexOf.call(obj, true); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-4.js new file mode 100644 index 0000000000..9183e4d886 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-4.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +Object.prototype[0] = false; + +assert.sameValue(Array.prototype.lastIndexOf.call({ + 0: true, + 1: 1, + length: 2 +}, true), 0, 'Array.prototype.lastIndexOf.call({ 0: true, 1: 1, length: 2 }, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-5.js new file mode 100644 index 0000000000..bfabd45dfd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-5.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); + +assert.sameValue([Number].lastIndexOf(Number), 0, '[Number].lastIndexOf(Number)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-6.js new file mode 100644 index 0000000000..fb30292d7d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-6.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call({ + 0: true, + 1: 1, + length: 2 +}, true), 0, 'Array.prototype.lastIndexOf.call({ 0: true, 1: 1, length: 2 }, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-7.js new file mode 100644 index 0000000000..1b4eb1f2f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-7.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + data property on an Array +---*/ + +Array.prototype[0] = true; +Array.prototype[1] = false; +Array.prototype[2] = "true"; + +assert.sameValue([, , , ].lastIndexOf(true), 0, '[, , , ].lastIndexOf(true)'); +assert.sameValue([, , , ].lastIndexOf(false), 1, '[, , , ].lastIndexOf(false)'); +assert.sameValue([, , , ].lastIndexOf("true"), 2, '[, , , ].lastIndexOf("true")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-8.js new file mode 100644 index 0000000000..5e055929b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-8.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + data property on an Array-like object +---*/ + +Object.prototype[0] = true; +Object.prototype[1] = false; +Object.prototype[2] = "true"; + +assert.sameValue(Array.prototype.lastIndexOf.call({ + length: 3 +}, true), 0, 'Array.prototype.lastIndexOf.call({ length: 3 }, true)'); +assert.sameValue(Array.prototype.lastIndexOf.call({ + length: 3 +}, false), 1, 'Array.prototype.lastIndexOf.call({ length: 3 }, false)'); +assert.sameValue(Array.prototype.lastIndexOf.call({ + length: 3 +}, "true"), 2, 'Array.prototype.lastIndexOf.call({ length: 3 }, "true")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-9.js new file mode 100644 index 0000000000..89a0753d96 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-9.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property on an Array +---*/ + +var arr = [, , , ]; +Object.defineProperty(arr, "0", { + get: function() { + return 0; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +Object.defineProperty(arr, "2", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(0), 0, 'arr.lastIndexOf(0)'); +assert.sameValue(arr.lastIndexOf(1), 1, 'arr.lastIndexOf(1)'); +assert.sameValue(arr.lastIndexOf(2), 2, 'arr.lastIndexOf(2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-1.js new file mode 100644 index 0000000000..ab569337cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-1.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - type of array element is different + from type of search element +---*/ + +assert.sameValue(["true"].lastIndexOf(true), -1, '["true"].lastIndexOf(true)'); +assert.sameValue(["0"].lastIndexOf(0), -1, '["0"].lastIndexOf(0)'); +assert.sameValue([false].lastIndexOf(0), -1, '[false].lastIndexOf(0)'); +assert.sameValue([undefined].lastIndexOf(0), -1, '[undefined].lastIndexOf(0)'); +assert.sameValue([null].lastIndexOf(0), -1, '[null].lastIndexOf(0)'); +assert.sameValue([ + [] +].lastIndexOf(0), -1, '[[]].lastIndexOf(0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-10.js new file mode 100644 index 0000000000..5fb4e0ab8d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-10.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both array element and search + element are booleans, and they have same value +---*/ + +assert.sameValue([false, true].lastIndexOf(true), 1, '[false, true].lastIndexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-11.js new file mode 100644 index 0000000000..15d142a080 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-11.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both array element and search + element are Objects, and they refer to the same object +---*/ + +var obj1 = {}; +var obj2 = {}; +var obj3 = obj2; + +assert.sameValue([obj2, obj1].lastIndexOf(obj3), 0, '[obj2, obj1].lastIndexOf(obj3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-2.js new file mode 100644 index 0000000000..3c752a3b0c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both type of array element and type + of search element are Undefined +---*/ + +assert.sameValue([undefined].lastIndexOf(), 0, '[undefined].lastIndexOf()'); +assert.sameValue([undefined].lastIndexOf(undefined), 0, '[undefined].lastIndexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-3.js new file mode 100644 index 0000000000..8def039e6f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-3.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both type of array element and type + of search element are Null +---*/ + +assert.sameValue([null].lastIndexOf(null), 0, '[null].lastIndexOf(null)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-4.js new file mode 100644 index 0000000000..5d001f88a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-4.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - search element is NaN +---*/ + +assert.sameValue([+NaN, NaN, -NaN].lastIndexOf(NaN), -1, '[+NaN, NaN, -NaN].lastIndexOf(NaN)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-5.js new file mode 100644 index 0000000000..5d8ced85f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-5.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - search element is -NaN +---*/ + +assert.sameValue([+NaN, NaN, -NaN].lastIndexOf(-NaN), -1, '[+NaN, NaN, -NaN].lastIndexOf(-NaN)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-6.js new file mode 100644 index 0000000000..c6c71dd524 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-6.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - array element is +0 and search + element is -0 +---*/ + +assert.sameValue([+0].lastIndexOf(-0), 0, '[+0].lastIndexOf(-0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-7.js new file mode 100644 index 0000000000..a52c350499 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-7.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - array element is -0 and search + element is +0 +---*/ + +assert.sameValue([-0].lastIndexOf(+0), 0, '[-0].lastIndexOf(+0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-8.js new file mode 100644 index 0000000000..5a990835d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-8.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both array element and search + element are numbers, and they have same value +---*/ + +assert.sameValue([-1, 0, 1].lastIndexOf(-1), 0, '[-1, 0, 1].lastIndexOf(-1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-9.js new file mode 100644 index 0000000000..8a175e49bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-9.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both array element and search + element are strings, and they have exactly the same sequence of + characters +---*/ + +assert.sameValue(["abc", "ab", "bca", ""].lastIndexOf("abc"), 0, '["abc", "ab", "bca", ""].lastIndexOf("abc")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-1.js new file mode 100644 index 0000000000..66ca31475f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns index of last one when more + than two elements in array are eligible +---*/ + +assert.sameValue([2, 1, 2, 2, 1].lastIndexOf(2), 3, '[2, 1, 2, 2, 1].lastIndexOf(2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-2.js new file mode 100644 index 0000000000..c84939a8b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-2.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns without visiting subsequent + element once search value is found +---*/ + +var arr = [2, 1, , 1, 2]; +var elementFirstAccessed = false; +var elementThirdAccessed = false; + +Object.defineProperty(arr, "2", { + get: function() { + elementThirdAccessed = true; + return 2; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + elementFirstAccessed = true; + return 2; + }, + configurable: true +}); + +arr.lastIndexOf(2); + +assert.sameValue(elementThirdAccessed, false, 'elementThirdAccessed'); +assert.sameValue(elementFirstAccessed, false, 'elementFirstAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-1.js new file mode 100644 index 0000000000..eaa3df340e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf returns -1 for elements not present +---*/ + +var a = new Array(); +a[100] = 1; +a[99999] = ""; +a[10] = new Object(); +a[5555] = 5.5; +a[123456] = "str"; +a[5] = 1E+309; + +assert.sameValue(a.lastIndexOf(1), 100, 'a.lastIndexOf(1)'); +assert.sameValue(a.lastIndexOf(""), 99999, 'a.lastIndexOf("")'); +assert.sameValue(a.lastIndexOf("str"), 123456, 'a.lastIndexOf("str")'); +assert.sameValue(a.lastIndexOf(5.5), 5555, 'a.lastIndexOf(5.5)'); +assert.sameValue(a.lastIndexOf(1E+309), 5, 'a.lastIndexOf(1E+309)'); + +assert.sameValue(a.lastIndexOf(true), -1, 'a.lastIndexOf(true)'); +assert.sameValue(a.lastIndexOf(5), -1, 'a.lastIndexOf(5)'); +assert.sameValue(a.lastIndexOf("str1"), -1, 'a.lastIndexOf("str1")'); +assert.sameValue(a.lastIndexOf(null), -1, 'a.lastIndexOf(null)'); +assert.sameValue(a.lastIndexOf(new Object()), -1, 'a.lastIndexOf(new Object())'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-2.js new file mode 100644 index 0000000000..1ad6837c0f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-2.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 and does + not access any other properties +---*/ + +var accessed = false; +var f = { + length: 0 +}; +Object.defineProperty(f, "0", { + get: function() { + accessed = true; + return 1; + } +}); + +var i = Array.prototype.lastIndexOf.call(f, 1); + + +assert.sameValue(i, -1, 'i'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/browser.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/call-with-boolean.js new file mode 100644 index 0000000000..22c6b91a3f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/call-with-boolean.js @@ -0,0 +1,16 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastIndexOf +description: Array.prototype.lastIndexOf applied to boolean primitive +---*/ + +assert.sameValue(Array.prototype.lastIndexOf.call(true), -1, 'Array.prototype.lastIndexOf.call(true) must return -1'); +assert.sameValue( + Array.prototype.lastIndexOf.call(false), + -1, + 'Array.prototype.lastIndexOf.call(false) must return -1' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js new file mode 100644 index 0000000000..67a77465f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js @@ -0,0 +1,45 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Calls [[HasProperty]] on the prototype to check for existing elements. +info: | + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... + 4. If fromIndex is present, let n be ? ToInteger(fromIndex); else let n be len-1. + ... + 7. Repeat, while k ≥ 0 + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ... +includes: [proxyTrapsHelper.js] +features: [Proxy] +---*/ + +var array = [5, undefined, 7]; + +Object.setPrototypeOf(array, new Proxy(Array.prototype, allowProxyTraps({ + has: function(t, pk) { + return pk in t; + } +}))); + +var fromIndex = { + valueOf: function() { + // Zero the array's length. The loop in step 8 iterates over the original + // length value of 100, but the only prototype MOP method which should be + // called is [[HasProperty]]. + array.length = 0; + return 2; + } +}; + +Array.prototype.lastIndexOf.call(array, 100, fromIndex); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/fromindex-zero-conversion.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/fromindex-zero-conversion.js new file mode 100644 index 0000000000..6ee21c9d7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/fromindex-zero-conversion.js @@ -0,0 +1,18 @@ +// Copyright 2016 The V8 project authors. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.prototype.lastindexof +description: > + Return +0 when fromIndex is -0 and return index refers to the first position +info: | + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be min(n, len - 1). + ... +---*/ + +assert.sameValue(1 / [true].lastIndexOf(true, -0), +Infinity); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-near-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-near-integer-limit.js new file mode 100644 index 0000000000..a10493c771 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-near-integer-limit.js @@ -0,0 +1,37 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Elements are found in an array-like object + whose "length" property is near the integer limit. +info: | + Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + [...] + 7. Repeat, while k ≥ 0 + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ii. Let same be the result of performing Strict Equality Comparison searchElement === elementK. + iii. If same is true, return k. + [...] +---*/ + +var el = {}; +var elIndex = Number.MAX_SAFE_INTEGER - 3; +var fromIndex = Number.MAX_SAFE_INTEGER - 1; +var arrayLike = { + length: Number.MAX_SAFE_INTEGER, +}; + +arrayLike[elIndex] = el; + +var res = Array.prototype.lastIndexOf.call(arrayLike, el, fromIndex); + +assert.sameValue(res, elIndex); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-zero-returns-minus-one.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-zero-returns-minus-one.js new file mode 100644 index 0000000000..1ffa00c9a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-zero-returns-minus-one.js @@ -0,0 +1,24 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.lastindexof +description: > + Returns -1 if length is 0. +info: | + Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + 3. If len is 0, return -1. +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error("Length should be checked before ToInteger(fromIndex)."); + }, +}; + +assert.sameValue([].lastIndexOf(1), -1); +assert.sameValue([].lastIndexOf(2, fromIndex), -1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length.js new file mode 100644 index 0000000000..56b0fd7f8b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + The "length" property of Array.prototype.lastIndexOf +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.lastIndexOf.length, 1); + +verifyNotEnumerable(Array.prototype.lastIndexOf, 'length'); +verifyNotWritable(Array.prototype.lastIndexOf, 'length'); +verifyConfigurable(Array.prototype.lastIndexOf, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/name.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/name.js new file mode 100644 index 0000000000..1ab52079e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf.name is "lastIndexOf". +info: | + Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.lastIndexOf.name, "lastIndexOf"); + +verifyNotEnumerable(Array.prototype.lastIndexOf, "name"); +verifyNotWritable(Array.prototype.lastIndexOf, "name"); +verifyConfigurable(Array.prototype.lastIndexOf, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/not-a-constructor.js new file mode 100644 index 0000000000..e3d126b8f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/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: > + Array.prototype.lastIndexOf 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.lastIndexOf), + false, + 'isConstructor(Array.prototype.lastIndexOf) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.lastIndexOf(); +}, '`new Array.prototype.lastIndexOf()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/prop-desc.js new file mode 100644 index 0000000000..8b70501c5b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + "lastIndexOf" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.lastIndexOf, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "lastIndexOf"); +verifyWritable(Array.prototype, "lastIndexOf"); +verifyConfigurable(Array.prototype, "lastIndexOf"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/shell.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/shell.js new file mode 100644 index 0000000000..bc72493f03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/shell.js @@ -0,0 +1,33 @@ +// GENERATED, DO NOT EDIT +// file: proxyTrapsHelper.js +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Used to assert the correctness of object behavior in the presence + and context of Proxy objects. +defines: [allowProxyTraps] +---*/ + +function allowProxyTraps(overrides) { + function throwTest262Error(msg) { + return function () { throw new Test262Error(msg); }; + } + if (!overrides) { overrides = {}; } + return { + getPrototypeOf: overrides.getPrototypeOf || throwTest262Error('[[GetPrototypeOf]] trap called'), + setPrototypeOf: overrides.setPrototypeOf || throwTest262Error('[[SetPrototypeOf]] trap called'), + isExtensible: overrides.isExtensible || throwTest262Error('[[IsExtensible]] trap called'), + preventExtensions: overrides.preventExtensions || throwTest262Error('[[PreventExtensions]] trap called'), + getOwnPropertyDescriptor: overrides.getOwnPropertyDescriptor || throwTest262Error('[[GetOwnProperty]] trap called'), + has: overrides.has || throwTest262Error('[[HasProperty]] trap called'), + get: overrides.get || throwTest262Error('[[Get]] trap called'), + set: overrides.set || throwTest262Error('[[Set]] trap called'), + deleteProperty: overrides.deleteProperty || throwTest262Error('[[Delete]] trap called'), + defineProperty: overrides.defineProperty || throwTest262Error('[[DefineOwnProperty]] trap called'), + enumerate: throwTest262Error('[[Enumerate]] trap called: this trap has been removed'), + ownKeys: overrides.ownKeys || throwTest262Error('[[OwnPropertyKeys]] trap called'), + apply: overrides.apply || throwTest262Error('[[Call]] trap called'), + construct: overrides.construct || throwTest262Error('[[Construct]] trap called') + }; +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/length.js b/js/src/tests/test262/built-ins/Array/prototype/length.js new file mode 100644 index 0000000000..914fb17f83 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/length.js @@ -0,0 +1,26 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-the-array-prototype-object +description: > + Array.prototype has a length property +info: | + 22.1.3 Properties of the Array Prototype Object + + The Array prototype object is the intrinsic object %ArrayPrototype%. The Array + prototype object is an Array exotic object and has the internal methods specified + for such objects. It has a length property whose initial value is 0 and whose + attributes are { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: + false }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.length, 0); + +verifyNotEnumerable(Array.prototype, 'length'); +// specify the value so it avoids a RangeError while setting the length +verifyWritable(Array.prototype, 'length', false, 42); +verifyNotConfigurable(Array.prototype, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-1.js new file mode 100644 index 0000000000..0ea571497b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to undefined +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.map.call(undefined); // TypeError is thrown if value is undefined +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-10.js new file mode 100644 index 0000000000..c1552a42a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-10.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to the Math object +---*/ + +function callbackfn(val, idx, obj) { + return ('[object Math]' === Object.prototype.toString.call(obj)); +} + +Math.length = 1; +Math[0] = 1; +var testResult = Array.prototype.map.call(Math, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-11.js new file mode 100644 index 0000000000..5f7f0c64ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-11.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to Date object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Date; +} + +var obj = new Date(); +obj.length = 1; +obj[0] = 1; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-12.js new file mode 100644 index 0000000000..62a271b906 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-12.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to RegExp object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof RegExp; +} + +var obj = new RegExp(); +obj.length = 1; +obj[0] = 1; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-13.js new file mode 100644 index 0000000000..a975a4db11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-13.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to the JSON object +---*/ + +function callbackfn(val, idx, obj) { + return ('[object JSON]' === Object.prototype.toString.call(obj)); +} + +JSON.length = 1; +JSON[0] = 1; +var testResult = Array.prototype.map.call(JSON, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-14.js new file mode 100644 index 0000000000..7213155ad6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-14.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to Error object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Error; +} + +var obj = new Error(); +obj.length = 1; +obj[0] = 1; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-15.js new file mode 100644 index 0000000000..c04d46aa56 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-15.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to the Arguments object +---*/ + +function callbackfn(val, idx, obj) { + return ('[object Arguments]' === Object.prototype.toString.call(obj)); +} + +var obj = (function() { + return arguments; +}("a", "b")); + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[1], true, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-2.js new file mode 100644 index 0000000000..ebabd9732b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to null +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.map.call(null); // TypeError is thrown if value is null +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-3.js new file mode 100644 index 0000000000..542cda123c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-3.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to boolean primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Boolean; +} + +Boolean.prototype[0] = true; +Boolean.prototype.length = 1; + +var testResult = Array.prototype.map.call(false, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-4.js new file mode 100644 index 0000000000..443d496a32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-4.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to Boolean object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Boolean; +} + +var obj = new Boolean(true); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-5.js new file mode 100644 index 0000000000..aa0df3adde --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-5.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to number primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Number; +} + +Number.prototype[0] = 1; +Number.prototype.length = 1; + +var testResult = Array.prototype.map.call(2.5, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-6.js new file mode 100644 index 0000000000..196afbf53e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-6.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to Number object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Number; +} + +var obj = new Number(-128); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-7.js new file mode 100644 index 0000000000..52414c52bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-7.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to string primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof String; +} + +var testResult = Array.prototype.map.call("abc", callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); +assert.sameValue(testResult[2], true, 'testResult[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-8.js new file mode 100644 index 0000000000..48a3518958 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-8.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to String object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof String; +} + +var obj = new String("abc"); +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); +assert.sameValue(testResult[2], true, 'testResult[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-9.js new file mode 100644 index 0000000000..748536314b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-1-9.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to Function object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Function; +} + +var obj = function(a, b) { + return a + b; +}; +obj[0] = 11; +obj[1] = 9; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-1.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-1.js new file mode 100644 index 0000000000..9709ade6e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-1.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object when 'length' + is an own data property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2 +}; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult.length, 2, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-10.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-10.js new file mode 100644 index 0000000000..b535c59f80 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-10.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object, 'length' is an + inherited accessor property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +var testResult = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(testResult.length, 2, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-11.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-11.js new file mode 100644 index 0000000000..c11e5a4438 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-11.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object when 'length' + is an own accessor property without a get function +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult.length, 0, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-12.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-12.js new file mode 100644 index 0000000000..3bf9d64a9d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-12.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to the Array-like object when + 'length' is own accessor property without a get function that + overrides an inherited accessor property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var obj = { + 0: 12, + 1: 11 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult.length, 0, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-13.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-13.js new file mode 100644 index 0000000000..d1353167d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-13.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to the Array-like object when + 'length' is inherited accessor property without a get function +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 11; +child[1] = 12; + +var testResult = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(testResult.length, 0, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-14.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-14.js new file mode 100644 index 0000000000..932391c1d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-14.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to the Array-like object that + 'length' property doesn't exist +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + 0: 11, + 1: 12 +}; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult.length, 0, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-17.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-17.js new file mode 100644 index 0000000000..8e2f1fa94d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-17.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Arguments object, which + implements its own property get method +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var func = function(a, b) { + return Array.prototype.map.call(arguments, callbackfn); +}; + +var testResult = func(12, 11); + +assert.sameValue(testResult.length, 2, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-18.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-18.js new file mode 100644 index 0000000000..49a86d8de0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-18.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to String object, which implements + its own property get method +---*/ + +function callbackfn(val, idx, obj) { + return parseInt(val, 10) > 1; +} + +var str = new String("432"); + +String.prototype[3] = "1"; +var testResult = Array.prototype.map.call(str, callbackfn); + +assert.sameValue(testResult.length, 3, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-19.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-19.js new file mode 100644 index 0000000000..5661fd2d23 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-19.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Function object, which implements + its own property get method +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var fun = function(a, b) { + return a + b; +}; +fun[0] = 12; +fun[1] = 11; +fun[2] = 9; + +var testResult = Array.prototype.map.call(fun, callbackfn); + +assert.sameValue(testResult.length, 2, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-2.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-2.js new file mode 100644 index 0000000000..d049873a78 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-2.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - when 'length' is own data property on an + Array +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var testResult = [12, 11].map(callbackfn); + +assert.sameValue(testResult.length, 2, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-3.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-3.js new file mode 100644 index 0000000000..7b634b713f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-3.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object, 'length' is an + own data property that overrides an inherited data property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var proto = { + length: 3 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +child[0] = 12; +child[1] = 11; +child[2] = 9; + +var testResult = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(testResult.length, 2, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-4.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-4.js new file mode 100644 index 0000000000..21a362c330 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-4.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - when 'length' is own data property that + overrides an inherited data property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var arrProtoLen; + +arrProtoLen = Array.prototype.length; +Array.prototype.length = 0; +var testResult = [12, 11].map(callbackfn); + +assert.sameValue(testResult.length, 2, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-5.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-5.js new file mode 100644 index 0000000000..3ff3707018 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-5.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object, 'length' is an + own data property that overrides an inherited accessor property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +var testResult = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(testResult.length, 2, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-6.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-6.js new file mode 100644 index 0000000000..d23fac2644 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-6.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object, 'length' is an + inherited data property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var proto = { + length: 2 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +var testResult = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(testResult.length, 2, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-7.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-7.js new file mode 100644 index 0000000000..8e0399588a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-7.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object, 'length' is an + own accessor property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +obj[0] = 12; +obj[1] = 11; +obj[2] = 9; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult.length, 2, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-8.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-8.js new file mode 100644 index 0000000000..4a7c16f961 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-8.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object, 'length' is an + own accessor property that overrides an inherited data property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var proto = { + length: 3 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +child[0] = 12; +child[1] = 11; +child[2] = 9; + +var testResult = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(testResult.length, 2, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-9.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-9.js new file mode 100644 index 0000000000..2201158d2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-2-9.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object when 'length' + is an own accessor property that overrides an inherited accessor + property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +child[0] = 12; +child[1] = 11; +child[2] = 9; + +var testResult = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(testResult.length, 2, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-1.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-1.js new file mode 100644 index 0000000000..e1cf01f40b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-1.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - value of 'length' is undefined +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + length: undefined +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-10.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-10.js new file mode 100644 index 0000000000..45011bb9e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-10.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - value of 'length' is a number (value is NaN) +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var obj = { + 0: 9, + length: NaN +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-11.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-11.js new file mode 100644 index 0000000000..325b31daf0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-11.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'length' is a string containing a positive + number +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var obj = { + 0: 11, + 1: 9, + 2: 12, + length: "2" +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-12.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-12.js new file mode 100644 index 0000000000..81839023c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-12.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'length' is a string containing a negative + number +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var obj = { + 0: 11, + 1: 9, + 2: 12, + length: "-4294967294" +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-13.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-13.js new file mode 100644 index 0000000000..34057ca1b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-13.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is string that is able to + convert to number primitive (value is a decimal number) +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var obj = { + 0: 11, + 1: 9, + 2: 12, + length: "2.5" +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-14.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-14.js new file mode 100644 index 0000000000..40bce0b805 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-14.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - 'length' is a string containing Infinity +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var obj = { + 0: 9, + length: "Infinity" +}; +assert.throws(RangeError, function() { + Array.prototype.map.call(obj, callbackfn); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-15.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-15.js new file mode 100644 index 0000000000..63f9784f40 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-15.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'length' is a string containing an + exponential number +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var obj = { + 0: 11, + 1: 9, + 2: 12, + length: "2E0" +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-16.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-16.js new file mode 100644 index 0000000000..3a07eb3ca9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-16.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - 'length' is a string containing a hex number +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var obj = { + 0: 11, + 1: 9, + 2: 12, + length: "0x0002" +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-17.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-17.js new file mode 100644 index 0000000000..af377162ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-17.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - when 'length' is a string containing a + number with leading zeros +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var obj = { + 0: 11, + 1: 9, + 2: 12, + length: "0002.00" +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-18.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-18.js new file mode 100644 index 0000000000..88f21dd26e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-18.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is a string that can't + convert to a number +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + length: "asdf!_" +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-19.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-19.js new file mode 100644 index 0000000000..8db50263ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-19.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is an Object which has an + own toString method +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var obj = { + 0: 11, + 1: 9, + + length: { + toString: function() { + return '2'; + } + } +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-2.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-2.js new file mode 100644 index 0000000000..b22cf94134 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-2.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map on an Array-like object if 'length' is 1 + (length overridden to true(type conversion)) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + 0: 11, + length: true +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 1, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-20.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-20.js new file mode 100644 index 0000000000..d8d3139101 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-20.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is an Object which has an + own valueOf method +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var obj = { + 0: 11, + 1: 9, + + length: { + valueOf: function() { + return 2; + } + } +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-21.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-21.js new file mode 100644 index 0000000000..a42cd67a1e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-21.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'length' is an object that has an own + valueOf method that returns an object and toString method that + returns a string +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var firstStepOccured = false; +var secondStepOccured = false; +var obj = { + 0: 11, + 1: 9, + + length: { + valueOf: function() { + firstStepOccured = true; + return {}; + }, + toString: function() { + secondStepOccured = true; + return '2'; + } + } +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert(firstStepOccured, 'firstStepOccured !== true'); +assert(secondStepOccured, 'secondStepOccured !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-22.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-22.js new file mode 100644 index 0000000000..d30ac3af39 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-22.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map throws TypeError exception when 'length' is an + object with toString and valueOf methods that don�t return + primitive values +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + 1: 11, + 2: 12, + + length: { + valueOf: function() { + return {}; + }, + toString: function() { + return {}; + } + } +}; +assert.throws(TypeError, function() { + Array.prototype.map.call(obj, callbackfn); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-23.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-23.js new file mode 100644 index 0000000000..1191410b6c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-23.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map uses inherited valueOf method when 'length' is + an object with an own toString and inherited valueOf methods +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var valueOfAccessed = false; +var toStringAccessed = false; + +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +child.toString = function() { + toStringAccessed = true; + return '1'; +}; + +var obj = { + 0: 11, + 1: 9, + length: child +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-24.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-24.js new file mode 100644 index 0000000000..1e3c720dc2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-24.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is a positive non-integer, + ensure truncation occurs in the proper direction +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var obj = { + 0: 11, + 1: 9, + length: 2.685 +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-25.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-25.js new file mode 100644 index 0000000000..c06e0a27cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-25.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - value of 'length' is a negative non-integer +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var obj = { + 0: 11, + 1: 9, + length: -4294967294.5 +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-28.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-28.js new file mode 100644 index 0000000000..0af3c40eff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-28.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - value of 'length' is boundary value (2^32) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + 0: 12, + length: 4294967296 +}; +assert.throws(RangeError, function() { + var newArr = Array.prototype.map.call(obj, callbackfn); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-29.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-29.js new file mode 100644 index 0000000000..f836bb3de6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-29.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is boundary value (2^32 + + 1) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + 0: 11, + 1: 9, + length: 4294967297 +}; +assert.throws(RangeError, function() { + var newArr = Array.prototype.map.call(obj, callbackfn); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-3.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-3.js new file mode 100644 index 0000000000..b789a59aa9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-3.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - value of 'length' is a number (value is 0) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + 0: 11, + length: 0 +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-4.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-4.js new file mode 100644 index 0000000000..02f5960536 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-4.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - value of 'length' is a number (value is +0) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + 0: 11, + length: +0 +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-5.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-5.js new file mode 100644 index 0000000000..e240877063 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-5.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - value of 'length' is a number (value is -0) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + 0: 11, + length: -0 +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-6.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-6.js new file mode 100644 index 0000000000..5577a5386b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-6.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'length' is a string containing a positive + number +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + 0: 10, + 1: 12, + 2: 9, + length: 2 +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 2, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-7.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-7.js new file mode 100644 index 0000000000..c333b5f132 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-7.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'length' is a string containing a negative + number +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + 0: 10, + 1: 12, + 2: 9, + length: -4294967294 +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-8.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-8.js new file mode 100644 index 0000000000..911ea03c59 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-8.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is a number (value is + Infinity) +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var obj = { + 0: 9, + length: Infinity +}; +assert.throws(RangeError, function() { + Array.prototype.map.call(obj, callbackfn); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-9.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-9.js new file mode 100644 index 0000000000..6151c30485 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-3-9.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is a number (value is + -Infinity) +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} + +var obj = { + 0: 9, + length: -Infinity +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr.length, 0, 'newArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-1.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-1.js new file mode 100644 index 0000000000..e308770942 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map throws TypeError if callbackfn is undefined +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.map(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-10.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-10.js new file mode 100644 index 0000000000..4855d9ef99 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-10.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - the exception is not thrown if exception was + thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.map.call(obj, undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-11.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-11.js new file mode 100644 index 0000000000..9d6b88db92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-11.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - the exception is not thrown if exception was + thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.map.call(obj, undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-12.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-12.js new file mode 100644 index 0000000000..c9740e30db --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-12.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - 'callbackfn' is a function +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var testResult = [11, 9].map(callbackfn); + +assert.sameValue(testResult.length, 2, 'testResult.length'); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], false, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-15.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-15.js new file mode 100644 index 0000000000..053030ae86 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-15.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - calling with no callbackfn is the same as + passing undefined for callbackfn +---*/ + +var obj = { + 10: 10 +}; +var lengthAccessed = false; +var loopAccessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + lengthAccessed = true; + return 20; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + loopAccessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.map.call(obj); +}); +assert(lengthAccessed, 'lengthAccessed !== true'); +assert.sameValue(loopAccessed, false, 'loopAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-2.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-2.js new file mode 100644 index 0000000000..4aaa316ab0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-2.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map throws ReferenceError if callbackfn is + unreferenced +---*/ + +var arr = new Array(10); +assert.throws(ReferenceError, function() { + arr.map(foo); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-3.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-3.js new file mode 100644 index 0000000000..38fb216606 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-3.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map throws TypeError if callbackfn is null +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.map(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-4.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-4.js new file mode 100644 index 0000000000..080f4dd2cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-4.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map throws TypeError if callbackfn is boolean +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.map(true); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-5.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-5.js new file mode 100644 index 0000000000..86494fcadf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-5.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map throws TypeError if callbackfn is number +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.map(5); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-6.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-6.js new file mode 100644 index 0000000000..88b7f8203f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-6.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map throws TypeError if callbackfn is string +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.map("abc"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-7.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-7.js new file mode 100644 index 0000000000..84b3497ee3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-7.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map throws TypeError if callbackfn is Object + without Call internal method +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.map(new Object()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-8.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-8.js new file mode 100644 index 0000000000..2c668ec0ad --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-8.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - Side effects produced by step 2 are visible + when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.map.call(obj, null); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-9.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-9.js new file mode 100644 index 0000000000..26a58da4f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-4-9.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - Side effects produced by step 3 are visible + when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.map.call(obj, null); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-1-s.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-1-s.js new file mode 100644 index 0000000000..426a7e16bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-1-s.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - thisArg not passed to strict callbackfn +flags: [noStrict] +---*/ + +var innerThisCorrect = false; + +function callbackfn(val, idx, obj) { + "use strict"; + innerThisCorrect = this === undefined; + return true; +} + +[1].map(callbackfn); + +assert(innerThisCorrect, 'innerThisCorrect !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-1.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-1.js new file mode 100644 index 0000000000..34d5e3a8e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-1.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - thisArg not passed +flags: [noStrict] +---*/ + +this._15_4_4_19_5_1 = true; + +(function() { + var _15_4_4_19_5_1 = false; + + function callbackfn(val, idx, obj) { + return this._15_4_4_19_5_1; + } + var srcArr = [1]; + var resArr = srcArr.map(callbackfn); + + assert.sameValue(resArr[0], true, 'resArr[0]'); + +})(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-10.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-10.js new file mode 100644 index 0000000000..b189ce82a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-10.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - Array object can be used as thisArg +---*/ + +var objArray = new Array(2); + +function callbackfn(val, idx, obj) { + return this === objArray; +} + +var testResult = [11].map(callbackfn, objArray); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-11.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-11.js new file mode 100644 index 0000000000..a050635a19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-11.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - String object can be used as thisArg +---*/ + +var objString = new String(); + +function callbackfn(val, idx, obj) { + return this === objString; +} + +var testResult = [11].map(callbackfn, objString); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-12.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-12.js new file mode 100644 index 0000000000..7e73d6c6a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-12.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - Boolean object can be used as thisArg +---*/ + +var objBoolean = new Boolean(); + +function callbackfn(val, idx, obj) { + return this === objBoolean; +} + +var testResult = [11].map(callbackfn, objBoolean); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-13.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-13.js new file mode 100644 index 0000000000..9909a7e011 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-13.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - Number object can be used as thisArg +---*/ + +var objNumber = new Number(); + +function callbackfn(val, idx, obj) { + return this === objNumber; +} + +var testResult = [11].map(callbackfn, objNumber); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-14.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-14.js new file mode 100644 index 0000000000..4169cb195b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-14.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - the Math object can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this === Math; +} + +var testResult = [11].map(callbackfn, Math); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-15.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-15.js new file mode 100644 index 0000000000..aab1605cf7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-15.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - Date object can be used as thisArg +---*/ + +var objDate = new Date(); + +function callbackfn(val, idx, obj) { + return this === objDate; +} + +var testResult = [11].map(callbackfn, objDate); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-16.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-16.js new file mode 100644 index 0000000000..1b8aa1ebfd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-16.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - RegExp object can be used as thisArg +---*/ + +var objRegExp = new RegExp(); + +function callbackfn(val, idx, obj) { + return this === objRegExp; +} + +var testResult = [11].map(callbackfn, objRegExp); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-17.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-17.js new file mode 100644 index 0000000000..f0dffa2e01 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-17.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - the JSON object can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this === JSON; +} + +var testResult = [11].map(callbackfn, JSON); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-18.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-18.js new file mode 100644 index 0000000000..4e3f20c309 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-18.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - Error object can be used as thisArg +---*/ + +var objError = new RangeError(); + +function callbackfn(val, idx, obj) { + return this === objError; +} + +var testResult = [11].map(callbackfn, objError); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-19.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-19.js new file mode 100644 index 0000000000..92b496daae --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-19.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - the Arguments object can be used as thisArg +---*/ + +var arg; + +function callbackfn(val, idx, obj) { + return this === arg; +} + +arg = (function() { + return arguments; +}(1, 2, 3)); + +var testResult = [11].map(callbackfn, arg); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-2.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-2.js new file mode 100644 index 0000000000..f0a4c212e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-2.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - thisArg is Object +---*/ + +var res = false; +var o = new Object(); +o.res = true; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +var srcArr = [1]; +var resArr = srcArr.map(callbackfn, o); + +assert.sameValue(resArr[0], true, 'resArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-21.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-21.js new file mode 100644 index 0000000000..413f938cc9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-21.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - the global object can be used as thisArg +---*/ + +var global = this; + +function callbackfn(val, idx, obj) { + return this === global; +} + +var testResult = [11].map(callbackfn, this); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-22.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-22.js new file mode 100644 index 0000000000..0287d0cff3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-22.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - boolean primitive can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === false; +} + +var testResult = [11].map(callbackfn, false); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-23.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-23.js new file mode 100644 index 0000000000..19223554d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-23.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - number primitive can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === 101; +} + +var testResult = [11].map(callbackfn, 101); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-24.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-24.js new file mode 100644 index 0000000000..13b937def9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-24.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - string primitive can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === "abc"; +} + +var testResult = [11].map(callbackfn, "abc"); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-3.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-3.js new file mode 100644 index 0000000000..753782044d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-3.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - thisArg is Array +---*/ + +var res = false; +var a = new Array(); +a.res = true; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +var srcArr = [1]; +var resArr = srcArr.map(callbackfn, a); + +assert.sameValue(resArr[0], true, 'resArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-4.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-4.js new file mode 100644 index 0000000000..c98291e316 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-4.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - thisArg is object from object + template(prototype) +---*/ + +var res = false; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +function foo() {} +foo.prototype.res = true; +var f = new foo(); + +var srcArr = [1]; +var resArr = srcArr.map(callbackfn, f); + +assert.sameValue(resArr[0], true, 'resArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-5.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-5.js new file mode 100644 index 0000000000..b747af3ea8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-5.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - thisArg is object from object template +---*/ + +var res = false; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +function foo() {} +var f = new foo(); +f.res = true; + +var srcArr = [1]; +var resArr = srcArr.map(callbackfn, f); + +assert.sameValue(resArr[0], true, 'resArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-6.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-6.js new file mode 100644 index 0000000000..185f7992df --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-6.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - thisArg is function +---*/ + +var res = false; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +function foo() {} +foo.res = true; + +var srcArr = [1]; +var resArr = srcArr.map(callbackfn, foo); + +assert.sameValue(resArr[0], true, 'resArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-7.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-7.js new file mode 100644 index 0000000000..00daa1ecf7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-7.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - built-in functions can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this === eval; +} + +var testResult = [11].map(callbackfn, eval); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-9.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-9.js new file mode 100644 index 0000000000..4be0013d44 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-5-9.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - Function object can be used as thisArg +---*/ + +var objFunction = function() {}; + +function callbackfn(val, idx, obj) { + return this === objFunction; +} + +var testResult = [11].map(callbackfn, objFunction); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-6-1.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-6-1.js new file mode 100644 index 0000000000..4d5df81ed1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-6-1.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - Array.isArray returns true when input + argument is the ourput array +---*/ + +var newArr = [11].map(function() {}); + +assert(Array.isArray(newArr), 'Array.isArray(newArr) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-6-2.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-6-2.js new file mode 100644 index 0000000000..c0cd468392 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-6-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - the returned array is instanceof Array +---*/ + +var newArr = [11].map(function() {}); + +assert(newArr instanceof Array, 'newArr instanceof Array !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-1.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-1.js new file mode 100644 index 0000000000..794370ca56 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-1.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map doesn't consider new elements added to array + after it is called +---*/ + +function callbackfn(val, idx, obj) +{ + srcArr[2] = 3; + srcArr[5] = 6; + return 1; +} + +var srcArr = [1, 2, , 4, 5]; +var resArr = srcArr.map(callbackfn); + +assert.sameValue(resArr.length, 5, 'resArr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-2.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-2.js new file mode 100644 index 0000000000..51c5a09cf1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-2.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map considers new value of elements in array after + it is called +---*/ + +function callbackfn(val, idx, obj) +{ + srcArr[4] = -1; + if (val > 0) + return 1; + else + return 0; +} + +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.map(callbackfn); + +assert.sameValue(resArr.length, 5, 'resArr.length'); +assert.sameValue(resArr[4], 0, 'resArr[4]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-3.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-3.js new file mode 100644 index 0000000000..75836fb0f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-3.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map doesn't visit deleted elements in array after + the call +---*/ + +function callbackfn(val, idx, obj) +{ + delete srcArr[4]; + if (val > 0) + return 1; + else + return 0; + +} + +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.map(callbackfn); + +assert.sameValue(resArr.length, 5, 'resArr.length'); +assert.sameValue(resArr[4], undefined, 'resArr[4]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-4.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-4.js new file mode 100644 index 0000000000..44642c47e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-4.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map doesn't visit deleted elements when + Array.length is decreased +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + srcArr.length = 2; + callCnt++; + return 1; +} + +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.map(callbackfn); + +assert.sameValue(resArr.length, 5, 'resArr.length'); +assert.sameValue(callCnt, 2, 'callCnt'); +assert.sameValue(resArr[2], undefined, 'resArr[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-5.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-5.js new file mode 100644 index 0000000000..d4f8874cc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-5.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map doesn't consider newly added elements in + sparse array +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + srcArr[1000] = 3; + callCnt++; + return val; +} + +var srcArr = new Array(10); +srcArr[1] = 1; +srcArr[2] = 2; +var resArr = srcArr.map(callbackfn); + +assert.sameValue(resArr.length, 10, 'resArr.length'); +assert.sameValue(callCnt, 2, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-6.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-6.js new file mode 100644 index 0000000000..99c7db12b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-6.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map visits deleted element in array after the call + when same index is also present in prototype +---*/ + +function callbackfn(val, idx, obj) +{ + delete srcArr[4]; + if (val > 0) + return 1; + else + return 0; + +} + +Array.prototype[4] = 5; +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.map(callbackfn); +delete Array.prototype[4]; + +assert.sameValue(resArr.length, 5, 'resArr.length'); +assert.sameValue(resArr[4], 1, 'resArr[4]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-7.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-7.js new file mode 100644 index 0000000000..6d203fceba --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-7.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map successful to delete the object in callbackfn +---*/ + +var obj = {}; +obj.srcArr = [1, 2, 3, 4, 5]; + +function callbackfn(val, idx, obj) { + delete obj.srcArr; + if (val > 0) + return 1; + else + return 0; +} + +var resArr = obj.srcArr.map(callbackfn); + +assert.sameValue(resArr.toString(), "1,1,1,1,1", 'resArr.toString()'); +assert.sameValue(obj.hasOwnProperty("arr"), false, 'obj.hasOwnProperty("arr")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-8.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-8.js new file mode 100644 index 0000000000..4d2849e7a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-8.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - no observable effects occur if length is 0 + on an Array-like object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + 1: 12, + length: 0 +}; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult.length, 0, 'testResult.length'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-9.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-9.js new file mode 100644 index 0000000000..96f92f7287 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-9.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - modifications to length don't change number + of iterations on an Array +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called += 1; + return val > 10; +} + +var arr = [9, , 12]; + +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 8; + }, + configurable: true +}); + +var testResult = arr.map(callbackfn); + +assert.sameValue(testResult.length, 3, 'testResult.length'); +assert.sameValue(called, 2, 'called'); +assert.sameValue(typeof testResult[2], "undefined", 'typeof testResult[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-1.js new file mode 100644 index 0000000000..96bac90e72 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-1.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - callbackfn not called for indexes never been + assigned values +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + callCnt++; + return 1; +} + +var srcArr = new Array(10); +srcArr[1] = undefined; //explicitly assigning a value +var resArr = srcArr.map(callbackfn); + +assert.sameValue(resArr.length, 10, 'resArr.length'); +assert.sameValue(callCnt, 1, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-10.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-10.js new file mode 100644 index 0000000000..b8261636f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-10.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - deleting property of prototype causes + prototype index property not to be visited on an Array-like Object +---*/ + +function callbackfn(val, idx, obj) { + return idx === 1 && typeof val === "undefined"; +} +var obj = { + 2: 2, + length: 20 +}; + +Object.defineProperty(obj, "0", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult.length, 20, 'testResult.length'); +assert.sameValue(typeof testResult[1], "undefined", 'typeof testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-11.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-11.js new file mode 100644 index 0000000000..996812f874 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-11.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - deleting property of prototype causes + prototype index property not to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + return idx === 1 && typeof val === "undefined"; +} +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + delete Array.prototype[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; +var testResult = arr.map(callbackfn); + +assert.sameValue(testResult.length, 3, 'testResult.length'); +assert.sameValue(typeof testResult[1], "undefined", 'typeof testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-12.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-12.js new file mode 100644 index 0000000000..0056170142 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-12.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 3) { + return false; + } else { + return true; + } +} +var obj = { + 0: 0, + 1: 1, + 2: 2, + length: 10 +}; + +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 3; +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[1], false, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-13.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-13.js new file mode 100644 index 0000000000..38bd89b4f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-13.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 3) { + return false; + } else { + return true; + } +} +var arr = [0, 1, 2]; + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 3; +var testResult = arr.map(callbackfn); + +assert.sameValue(testResult[1], false, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-14.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-14.js new file mode 100644 index 0000000000..af2a27140b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-14.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - decreasing length of array causes index + property not to be visited +---*/ + +function callbackfn(val, idx, obj) { + return idx === 3 && typeof val === "undefined"; +} + +var arr = [0, 1, 2, "last"]; + +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); + +var testResult = arr.map(callbackfn); + +assert.sameValue(typeof testResult[3], "undefined", 'typeof testResult[3]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-15.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-15.js new file mode 100644 index 0000000000..4ce783a642 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-15.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - decreasing length of array with prototype + property causes prototype index property to be visited +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "prototype") { + return false; + } else { + return true; + } +} +var arr = [0, 1, 2]; + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +var testResult = arr.map(callbackfn); + +assert.sameValue(testResult.length, 3, 'testResult.length'); +assert.sameValue(testResult[2], false, 'testResult[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-16.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-16.js new file mode 100644 index 0000000000..3d08371488 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-16.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - decreasing length of array does not delete + non-configurable properties +flags: [noStrict] +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "unconfigurable") { + return false; + } else { + return true; + } +} + +var arr = [0, 1, 2]; + +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); + +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +var testResult = arr.map(callbackfn); + +assert.sameValue(testResult.length, 3, 'testResult.length'); +assert.sameValue(testResult[2], false, 'testResult[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-2.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-2.js new file mode 100644 index 0000000000..38cc439de5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-2.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - added properties in step 2 are visible here +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "length") { + return false; + } else { + return true; + } +} + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + obj[2] = "length"; + return 3; + }, + configurable: true +}); + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[2], false, 'testResult[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-3.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-3.js new file mode 100644 index 0000000000..447ccaaf55 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-3.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - deleted properties in step 2 are visible here +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2) { + return false; + } else { + return true; + } +} +var obj = { + 2: 6.99, + 8: 19 +}; + +Object.defineProperty(obj, "length", { + get: function() { + delete obj[2]; + return 10; + }, + configurable: true +}); + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(typeof testResult[2], "undefined", 'typeof testResult[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-4.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-4.js new file mode 100644 index 0000000000..6ee5723eeb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-4.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - properties added into own object after + current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return false; + } else { + return true; + } +} + +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(obj, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], false, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-5.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-5.js new file mode 100644 index 0000000000..67b6db527d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-5.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - properties added into own object after + current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return false; + } else { + return true; + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +var testResult = arr.map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], false, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-6.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-6.js new file mode 100644 index 0000000000..3c0f54cee6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-6.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - properties can be added to prototype after + current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + return false; + } else { + return true; + } +} +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], false, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-7.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-7.js new file mode 100644 index 0000000000..a0c8e0cc58 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-7.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - properties can be added to prototype after + current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + return false; + } else { + return true; + } +} +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(Array.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +var testResult = arr.map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], false, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-8.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-8.js new file mode 100644 index 0000000000..71b66dd49f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-8.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - deleting own property causes index property + not to be visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return false; + } else { + return true; + } +} +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); + +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(typeof testResult[1], "undefined", 'typeof testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-9.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-9.js new file mode 100644 index 0000000000..0566ab03a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-b-9.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - deleting own property causes index property + not to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return false; + } else { + return true; + } +} +var arr = [1, 2]; + +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +var testResult = arr.map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(typeof testResult[1], "undefined", 'typeof testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-1.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-1.js new file mode 100644 index 0000000000..9bc5233ea0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own data property + on an Array-like object +---*/ + +var kValue = {}; + +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val === kValue; + } + return false; +} + +var obj = { + 5: kValue, + length: 100 +}; + +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr[5], true, 'newArr[5]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-10.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-10.js new file mode 100644 index 0000000000..ac3500c645 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-10.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property on an Array +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} + +var arr = []; + +Object.defineProperty(arr, "0", { + get: function() { + return kValue; + }, + configurable: true +}); + +var testResult = arr.map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-11.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-11.js new file mode 100644 index 0000000000..0da168ded4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-11.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} + +var proto = { + 0: 5, + length: 2 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "0", { + get: function() { + return kValue; + }, + configurable: true +}); + +var testResult = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-12.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-12.js new file mode 100644 index 0000000000..70cfd46a89 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-12.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} + +var arr = []; + +Array.prototype[0] = 11; + +Object.defineProperty(arr, "0", { + get: function() { + return kValue; + }, + configurable: true +}); + +var testResult = arr.map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-13.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-13.js new file mode 100644 index 0000000000..d1966dfe3e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-13.js @@ -0,0 +1,48 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} + +var proto = { + length: 2 +}; + +Object.defineProperty(proto, "0", { + get: function() { + return 5; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "0", { + get: function() { + return kValue; + }, + configurable: true +}); + +var testResult = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-14.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-14.js new file mode 100644 index 0000000000..0616985011 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-14.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} + +var arr = []; + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 11; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + return kValue; + }, + configurable: true +}); + +var testResult = arr.map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-15.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-15.js new file mode 100644 index 0000000000..76caaacb11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-15.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} + +var proto = { + length: 2 +}; + +Object.defineProperty(proto, "0", { + get: function() { + return kValue; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +var testResult = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-16.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-16.js new file mode 100644 index 0000000000..6a2aaf5ee1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-16.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is inherited + accessor property on an Array +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return kValue; + }, + configurable: true +}); + +var testResult = [, ].map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-17.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-17.js new file mode 100644 index 0000000000..010092b6a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-17.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return typeof val === "undefined"; + } + return false; +} + +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[1], true, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-18.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-18.js new file mode 100644 index 0000000000..c9f40cc933 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-18.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return typeof val === "undefined"; + } + return false; +} + +var arr = []; + +Object.defineProperty(arr, "1", { + set: function() {}, + configurable: true +}); + +var testResult = arr.map(callbackfn); + +assert.sameValue(testResult[1], true, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-19.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-19.js new file mode 100644 index 0000000000..90db2b70b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-19.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return typeof val === "undefined"; + } + return false; +} + +var arr = []; + +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 100; + }, + configurable: true +}); + +var testResult = arr.map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-2.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-2.js new file mode 100644 index 0000000000..706d750f9d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-2.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own data property + on an Array +---*/ + +var kValue = {}; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} + +var arr = [kValue]; + +var newArr = arr.map(callbackfn); + +assert.sameValue(newArr[0], true, 'newArr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-20.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-20.js new file mode 100644 index 0000000000..49d31a2ba3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-20.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return typeof val === "undefined"; + } + return false; +} + +var proto = {}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; + +Object.defineProperty(child, "0", { + set: function() {}, + configurable: true +}); + +Object.defineProperty(proto, "0", { + get: function() { + return 100; + }, + configurable: true +}); + +var testResult = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-21.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-21.js new file mode 100644 index 0000000000..5ee917eb66 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-21.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return typeof val === "undefined"; + } + return false; +} + +var proto = { + length: 2 +}; +Object.defineProperty(proto, "0", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +var testResult = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-22.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-22.js new file mode 100644 index 0000000000..cec20409a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-22.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return typeof val === "undefined"; + } + return false; +} + +Object.defineProperty(Array.prototype, "0", { + set: function() {}, + configurable: true +}); + +var testResult = [, ].map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-25.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-25.js new file mode 100644 index 0000000000..2312cf7e56 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-25.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - This object is the Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 9; + } else { + return false; + } +} + +var func = function(a, b) { + return Array.prototype.map.call(arguments, callbackfn); +}; + +var testResult = func(9); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-26.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-26.js new file mode 100644 index 0000000000..b93d2676d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-26.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - This object is the Arguments object which + implements its own property get method (number of arguments equals + number of parameters) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 9; + } else if (idx === 1) { + return val === 11; + } else { + return false; + } +} + +var func = function(a, b) { + return Array.prototype.map.call(arguments, callbackfn); +}; + +var testResult = func(9, 11); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-27.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-27.js new file mode 100644 index 0000000000..0d082d7d80 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-27.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - This object is the Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 9; + } else if (idx === 1) { + return val === 11; + } else if (idx === 2) { + return val === 12; + } else { + return false; + } + +} + +var func = function(a, b) { + return Array.prototype.map.call(arguments, callbackfn); +}; + +var testResult = func(9, 11, 12); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); +assert.sameValue(testResult[2], true, 'testResult[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-28.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-28.js new file mode 100644 index 0000000000..cf82881c11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-28.js @@ -0,0 +1,48 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element changed by getter on previous + iterations is observed on an Array +---*/ + +var preIterVisible = false; +var arr = []; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } else if (idx === 1) { + return val === 9; + } else { + return false; + } +} + +Object.defineProperty(arr, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 11; + } + }, + configurable: true +}); + +var testResult = arr.map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-29.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-29.js new file mode 100644 index 0000000000..047a791cbd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-29.js @@ -0,0 +1,50 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element changed by getter on previous + iterations is observed on an Array-like object +---*/ + +var preIterVisible = false; +var obj = { + length: 2 +}; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } else if (idx === 1) { + return val === 9; + } else { + return false; + } +} + +Object.defineProperty(obj, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 11; + } + }, + configurable: true +}); + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-3.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-3.js new file mode 100644 index 0000000000..d7a6011c47 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-3.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own data property + that overrides an inherited data property on an Array-like object +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val === kValue; + } + return false; +} + +var proto = { + 5: 12, + length: 10 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[5] = kValue; + +var testResult = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(testResult[5], true, 'testResult[5]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-30.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-30.js new file mode 100644 index 0000000000..f056c41aa2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-30.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - unhandled exceptions happened in getter + terminate iteration on an Array-like object +---*/ + +var obj = { + 0: 11, + 5: 10, + 10: 8, + length: 20 +}; +var accessed = false; + +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } +} + +Object.defineProperty(obj, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); + +Object.defineProperty(obj, "2", { + get: function() { + accessed = true; + return 100; + }, + configurable: true +}); +assert.throws(RangeError, function() { + Array.prototype.map.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-31.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-31.js new file mode 100644 index 0000000000..19590755a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-31.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - unhandled exceptions happened in getter + terminate iteration on an Array +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } +} + +var arr = []; +arr[5] = 10; +arr[10] = 100; + +Object.defineProperty(arr, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); + +Object.defineProperty(arr, "2", { + get: function() { + accessed = true; + return 100; + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.map(callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-4.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-4.js new file mode 100644 index 0000000000..f3c5c531b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-4.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own data property + that overrides an inherited data property on an Array +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} + +Array.prototype[0] = 11; + +var testResult = [kValue].map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-5.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-5.js new file mode 100644 index 0000000000..e56d98dfb3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-5.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own data property + that overrides an inherited accessor property on an Array-like + object +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val === kValue; + } + return false; +} + +var proto = {}; + +Object.defineProperty(proto, "5", { + get: function() { + return 11; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 10; +Object.defineProperty(child, "5", { + value: kValue, + configurable: true +}); + +var testResult = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(testResult[5], true, 'testResult[5]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-6.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-6.js new file mode 100644 index 0000000000..e45f5ae86b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-6.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own data property + that overrides an inherited accessor property on an Array +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 9; + }, + configurable: true +}); + +var testResult = [kValue].map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-7.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-7.js new file mode 100644 index 0000000000..db5a058191 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-7.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is inherited data + property on an Array-like object +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val === kValue; + } + return false; +} + +var proto = { + 5: kValue, + length: 10 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +var newArr = Array.prototype.map.call(child, callbackfn); + +assert.sameValue(newArr[5], true, 'newArr[5]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-8.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-8.js new file mode 100644 index 0000000000..d4f90ed45e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-8.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is inherited data + property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === 13; + } + return false; +} + +Array.prototype[1] = 13; + +var newArr = [, , , ].map(callbackfn); + +assert.sameValue(newArr[1], true, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-9.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-9.js new file mode 100644 index 0000000000..84f5388fa0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-i-9.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property on an Array-like object +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} + +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "0", { + get: function() { + return kValue; + }, + configurable: true +}); + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-1.js new file mode 100644 index 0000000000..137bdc3e3a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-1.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - callbackfn called with correct parameters +---*/ + +var bPar = true; +var bCalled = false; + +function callbackfn(val, idx, obj) +{ + bCalled = true; + if (obj[idx] !== val) + bPar = false; +} + +var srcArr = [0, 1, true, null, new Object(), "five"]; +srcArr[999999] = -6.6; +var resArr = srcArr.map(callbackfn); + + +assert.sameValue(bCalled, true, 'bCalled'); +assert.sameValue(bPar, true, 'bPar'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-10.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-10.js new file mode 100644 index 0000000000..3642d53770 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-10.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - callbackfn is called with 1 formal parameter +---*/ + +function callbackfn(val) { + return val > 10; +} + +var testResult = [11].map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-11.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-11.js new file mode 100644 index 0000000000..90a43f7de5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-11.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - callbackfn is called with 2 formal parameters +---*/ + +function callbackfn(val, idx) { + return (val > 10 && arguments[2][idx] === val); +} + +var testResult = [11].map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-12.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-12.js new file mode 100644 index 0000000000..fb6b879d6e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-12.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - callbackfn is called with 3 formal parameters +---*/ + +function callbackfn(val, idx, obj) { + return (val > 10 && obj[idx] === val); +} + +var testResult = [11].map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-13.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-13.js new file mode 100644 index 0000000000..4a86a55968 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-13.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - callbackfn that uses arguments object to get + parameter value +---*/ + +function callbackfn() { + return arguments[2][arguments[1]] === arguments[0]; +} + +var testResult = [11].map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-16.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-16.js new file mode 100644 index 0000000000..9eef633abb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-16.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'this' object when T is not an object (T is + a boolean primitive) +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === false; +} + +var obj = { + 0: 11, + length: 2 +}; + +var testResult = Array.prototype.map.call(obj, callbackfn, false); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-17.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-17.js new file mode 100644 index 0000000000..dfa2008c0a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-17.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'this' object when T is not an object (T is + a number) +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === 5; +} + +var obj = { + 0: 11, + length: 2 +}; + +var testResult = Array.prototype.map.call(obj, callbackfn, 5); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-18.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-18.js new file mode 100644 index 0000000000..515cfda4dc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-18.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'this' object when T is not an object (T is + a string primitive) +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === "hello!"; +} + +var obj = { + 0: 11, + length: 2 +}; + +var testResult = Array.prototype.map.call(obj, callbackfn, "hello!"); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-19.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-19.js new file mode 100644 index 0000000000..6dbba43000 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-19.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - non-indexed properties are not called. +---*/ + +var called = 0; +var result = false; + +function callbackfn(val, idx, obj) { + called++; + if (val === 11) { + result = true; + } + return true; +} + +var obj = { + 0: 9, + non_index_property: 11, + length: 20 +}; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(result, false, 'result'); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(called, 1, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-2.js new file mode 100644 index 0000000000..0f23cc97fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-2.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - callbackfn takes 3 arguments +---*/ + +var parCnt = 3; +var bCalled = false + +function callbackfn(val, idx, obj) +{ + bCalled = true; + if (arguments.length !== 3) + parCnt = arguments.length; //verify if callbackfn was called with 3 parameters +} + +var srcArr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +var resArr = srcArr.map(callbackfn); + +assert.sameValue(bCalled, true, 'bCalled'); +assert.sameValue(parCnt, 3, 'parCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-20.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-20.js new file mode 100644 index 0000000000..02dbdfcfa3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-20.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - callbackfn called with correct parameters + (thisArg is correct) +---*/ + +function callbackfn(val, idx, obj) { + return this.threshold === 10; +} + +var thisArg = { + threshold: 10 +}; + +var obj = { + 0: 11, + 1: 9, + length: 2 +}; + +var testResult = Array.prototype.map.call(obj, callbackfn, thisArg); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-21.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-21.js new file mode 100644 index 0000000000..3f33cd7778 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-21.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - callbackfn called with correct parameters + (kValue is correct) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } + + if (idx === 1) { + return val === 12; + } + + return false; +} + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-22.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-22.js new file mode 100644 index 0000000000..9f5e480683 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-22.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - callbackfn called with correct parameters + (the index k is correct) +---*/ + +function callbackfn(val, idx, obj) { + if (val === 11) { + return idx === 0; + } + + if (val === 12) { + return idx === 1; + } + + return false; +} + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-23.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-23.js new file mode 100644 index 0000000000..4ed80de5e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-23.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - callbackfn called with correct parameters + (this object O is correct) +---*/ + +var obj = { + 0: 11, + length: 2 +}; + +function callbackfn(val, idx, o) { + return obj === o; +} + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-4.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-4.js new file mode 100644 index 0000000000..a561076362 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-4.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - k values are passed in acending numeric order +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +var lastIdx = 0; +var called = 0; +var result = true; + +function callbackfn(val, idx, o) { + called++; + if (lastIdx !== idx) { + result = false; + } else { + lastIdx++; + } +} + +arr.map(callbackfn); + +assert(result, 'result !== true'); +assert.sameValue(arr.length, called, 'arr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-5.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-5.js new file mode 100644 index 0000000000..738c50cab5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-5.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - k values are accessed during each iteration + and not prior to starting the loop. +---*/ + +var kIndex = []; + +//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(val, idx, obj) { + //Each position should be visited one time, which means k is accessed one time during iterations. + if (typeof kIndex[idx] === "undefined") { + //when current position is visited, its previous index should has been visited. + if (idx !== 0 && typeof kIndex[idx - 1] === "undefined") { + return true; + } + kIndex[idx] = 1; + return false; + } else { + return true; + } +} + +var testResult = [11, 12, 13, 14].map(callbackfn); + +assert.sameValue(testResult.length, 4, 'testResult.length'); +assert.sameValue(testResult[0], false, 'testResult[0]'); +assert.sameValue(testResult[1], false, 'testResult[1]'); +assert.sameValue(testResult[2], false, 'testResult[2]'); +assert.sameValue(testResult[3], false, 'testResult[3]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-6.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-6.js new file mode 100644 index 0000000000..56aabf82e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-6.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - arguments to callbackfn are self consistent. +---*/ + +var obj = { + 0: 11, + length: 1 +}; +var thisArg = {}; + +function callbackfn() { + return this === thisArg && + arguments[0] === 11 && + arguments[1] === 0 && + arguments[2] === obj; +} + +var testResult = Array.prototype.map.call(obj, callbackfn, thisArg); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-7.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-7.js new file mode 100644 index 0000000000..4defb5c313 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-7.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - unhandled exceptions happened in callbackfn + terminate iteration +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + if (idx > 0) { + accessed = true; + } + if (idx === 0) { + throw new Error("Exception occurred in callbackfn"); + } +} + +var obj = { + 0: 11, + 4: 10, + 10: 8, + length: 20 +}; +assert.throws(Error, function() { + Array.prototype.map.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-8.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-8.js new file mode 100644 index 0000000000..fdb6b40003 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-8.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element changed by callbackfn on previous + iterations is observed +---*/ + +var obj = { + 0: 9, + 1: 12, + length: 2 +}; + +function callbackfn(val, idx, o) { + if (idx === 0) { + obj[idx + 1] = 8; + } + return val > 10; +} + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult[1], false, 'testResult[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-9.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-9.js new file mode 100644 index 0000000000..3064557e85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-ii-9.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - callbackfn with 0 formal parameter +---*/ + +function callbackfn() { + return true; +} + +var testResult = [11].map(callbackfn); + +assert.sameValue(testResult[0], true, 'testResult[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-1.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-1.js new file mode 100644 index 0000000000..14ec4f6fd2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - getOwnPropertyDescriptor(all true) of + returned array element +---*/ + +function callbackfn(val, idx, obj) { + if (val % 2) + return (2 * val + 1); + else + return (val / 2); +} +var srcArr = [0, 1, 2, 3, 4]; +var resArr = srcArr.map(callbackfn); + +assert(resArr.length > 0, 'resArr.length > 0'); + +var desc = Object.getOwnPropertyDescriptor(resArr, 1); + +assert.sameValue(desc.value, 3, 'desc.value'); //srcArr[1] = 2*1+1 = 3 +assert.sameValue(desc.writable, true, 'desc.writable'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-2.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-2.js new file mode 100644 index 0000000000..42433e4f87 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-2.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of returned array element equals to + 'mappedValue' +---*/ + +function callbackfn(val, idx, obj) { + return val; +} + +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +var newArr = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(newArr[0], obj[0], 'newArr[0]'); +assert.sameValue(newArr[1], obj[1], 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-3.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-3.js new file mode 100644 index 0000000000..f10267fe44 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-3.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of returned array element can be + overwritten +---*/ + +function callbackfn(val, idx, obj) { + return 11; +} + +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +var newArr = Array.prototype.map.call(obj, callbackfn); + +var tempVal = newArr[1]; +newArr[1] += 1; + +assert.notSameValue(newArr[1], tempVal, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-4.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-4.js new file mode 100644 index 0000000000..4d9b9ec42b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-4.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of returned array element can be + enumerated +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 0: 11, + length: 2 +}; +var newArr = Array.prototype.map.call(obj, callbackfn); + +var prop; +var enumerable = false; +for (prop in newArr) { + if (newArr.hasOwnProperty(prop)) { + if (prop === "0") { + enumerable = true; + } + } +} + +assert(enumerable, 'enumerable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-5.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-5.js new file mode 100644 index 0000000000..00ad77685f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-8-c-iii-5.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of returned array element can be + changed or deleted +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +var newArr = Array.prototype.map.call(obj, callbackfn); + +var tempVal = newArr[1]; +delete newArr[1]; + +assert.notSameValue(tempVal, undefined, 'tempVal'); +assert.sameValue(newArr[1], undefined, 'newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-1.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-1.js new file mode 100644 index 0000000000..8103784cce --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-1.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map doesn't mutate the Array on which it is called + on +---*/ + +function callbackfn(val, idx, obj) +{ + return true; +} +var srcArr = [1, 2, 3, 4, 5]; +srcArr.map(callbackfn); + +assert.sameValue(srcArr[0], 1, 'srcArr[0]'); +assert.sameValue(srcArr[1], 2, 'srcArr[1]'); +assert.sameValue(srcArr[2], 3, 'srcArr[2]'); +assert.sameValue(srcArr[3], 4, 'srcArr[3]'); +assert.sameValue(srcArr[4], 5, 'srcArr[4]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-10.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-10.js new file mode 100644 index 0000000000..e3daa4d151 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-10.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - empty array to be returned if 'length' is 0 + (subclassed Array, length overridden with obj with valueOf) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var Foo = function() {}; +Foo.prototype = [1, 2, 3]; +var obj = new Foo(); +obj.length = { + valueOf: function() { + return 0; + } +}; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult.length, 0, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-11.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-11.js new file mode 100644 index 0000000000..9a5dab55a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-11.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - returns an empty array if 'length' is 0 + (subclassed Array, length overridden with obj w/o valueOf + (toString)) +---*/ + +function Foo() {} +Foo.prototype = [1, 2, 3]; + +var f = new Foo(); + +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. + +function cb() {} +var a = Array.prototype.map.call(f, cb); + +assert(Array.isArray(a), 'Array.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-12.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-12.js new file mode 100644 index 0000000000..06631cb716 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-12.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - returns an empty array if 'length' is 0 + (subclassed Array, length overridden with []) +---*/ + +function Foo() {} +Foo.prototype = [1, 2, 3]; +var f = new Foo(); + +f.length = []; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. + +function cb() {} +var a = Array.prototype.map.call(f, cb); + +assert(Array.isArray(a), 'Array.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-13.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-13.js new file mode 100644 index 0000000000..a6baff3583 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-13.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - if there are no side effects of the + functions, O is unmodified +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + return val > 2; +} + +var arr = [1, 2, 3, 4]; + +arr.map(callbackfn); + +assert.sameValue(arr[0], 1, 'arr[0]'); +assert.sameValue(arr[1], 2, 'arr[1]'); +assert.sameValue(arr[2], 3, 'arr[2]'); +assert.sameValue(arr[3], 4, 'arr[3]'); +assert.sameValue(called, 4, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-2.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-2.js new file mode 100644 index 0000000000..4e420cde77 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-2.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map returns new Array with same number of elements + and values the result of callbackfn +---*/ + +function callbackfn(val, idx, obj) +{ + return val + 10; +} +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.map(callbackfn); + +assert.sameValue(resArr[0], 11, 'resArr[0]'); +assert.sameValue(resArr[1], 12, 'resArr[1]'); +assert.sameValue(resArr[2], 13, 'resArr[2]'); +assert.sameValue(resArr[3], 14, 'resArr[3]'); +assert.sameValue(resArr[4], 15, 'resArr[4]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-3.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-3.js new file mode 100644 index 0000000000..4831adaca2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-3.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - subclassed array when length is reduced +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 1; + +function cb() {} +var a = f.map(cb); + + +assert(Array.isArray(a), 'Array.isArray(a) !== true'); +assert.sameValue(a.length, 1, 'a.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-4.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-4.js new file mode 100644 index 0000000000..09f4e1a7b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-4.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map doesn't visit expandos +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + callCnt++; +} +var srcArr = [1, 2, 3, 4, 5]; +srcArr["i"] = 10; +srcArr[true] = 11; + +var resArr = srcArr.map(callbackfn); + +assert.sameValue(callCnt, 5, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-5.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-5.js new file mode 100644 index 0000000000..e4ec7cb36b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-5.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - empty array to be returned if 'length' is 0 + (empty array) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var obj = { + 0: 9, + 1: 8, + length: 0 +}; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult.length, 0, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-6.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-6.js new file mode 100644 index 0000000000..b595c9646c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-6.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - empty array to be returned if 'length' is 0 + (subclassed Array, length overridden to null (type conversion)) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +var Foo = function() {}; +Foo.prototype = [1, 2, 3]; +var obj = new Foo(); +obj.length = null; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult.length, 0, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-7.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-7.js new file mode 100644 index 0000000000..6611e60e60 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-7.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - empty array to be returned if 'length' is 0 + (subclassed Array, length overridden to false (type conversion)) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var Foo = function() {}; +Foo.prototype = [1, 2, 3]; +var obj = new Foo(); +obj.length = false; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult.length, 0, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-8.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-8.js new file mode 100644 index 0000000000..45b51ef3fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-8.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - empty array to be returned if 'length' is 0 + (subclassed Array, length overridden to 0 (type conversion)) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var Foo = function() {}; +Foo.prototype = [1, 2, 3]; +var obj = new Foo(); +obj.length = 0; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult.length, 0, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-9.js b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-9.js new file mode 100644 index 0000000000..281707b4cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/15.4.4.19-9-9.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - empty array to be returned if 'length' is 0 + (subclassed Array, length overridden to '0' (type conversion)) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var Foo = function() {}; +Foo.prototype = [1, 2, 3]; +var obj = new Foo(); +obj.length = '0'; + +var testResult = Array.prototype.map.call(obj, callbackfn); + +assert.sameValue(testResult.length, 0, 'testResult.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/browser.js b/js/src/tests/test262/built-ins/Array/prototype/map/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/map/call-with-boolean.js new file mode 100644 index 0000000000..b9c8ffe85b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/call-with-boolean.js @@ -0,0 +1,21 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map applied to boolean primitive +includes: [compareArray.js] +---*/ + +assert.compareArray( + Array.prototype.map.call(true, () => {}), + [], + 'Array.prototype.map.call(true, () => {}) must return []' +); +assert.compareArray( + Array.prototype.map.call(false, () => {}), + [], + 'Array.prototype.map.call(false, () => {}) must return []' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/map/callbackfn-resize-arraybuffer.js new file mode 100644 index 0000000000..ec8caa847e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/callbackfn-resize-arraybuffer.js @@ -0,0 +1,78 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.map +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var finalResult, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.map.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + finalResult = undefined; + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + finalResult = 2; + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + + return index; + }); + + assert.compareArray(elements, expectedElements, 'elements (shrink)'); + assert.compareArray(indices, expectedIndices, 'indices (shrink)'); + assert.compareArray(arrays, expectedArrays, 'arrays (shrink)'); + assert.compareArray(result, [0, 1, finalResult], 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.map.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + + return index; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.compareArray(result, expectedIndices, 'result (grow)'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-ctor-non-object.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-ctor-non-object.js new file mode 100644 index 0000000000..d5ea3a6c51 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-ctor-non-object.js @@ -0,0 +1,53 @@ +// 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-array.prototype.map +description: > + Behavior when `constructor` property is neither an Object nor undefined +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 9. If IsConstructor(C) is false, throw a TypeError exception. +---*/ + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 0; +}; + +a.constructor = null; +assert.throws(TypeError, function() { + a.map(cb); +}, 'null value'); +assert.sameValue(callCount, 0, 'callback not invoked (null value)'); + +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.map(cb); +}, 'number value'); +assert.sameValue(callCount, 0, 'callback not invoked (number value)'); + +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.map(cb); +}, 'string value'); +assert.sameValue(callCount, 0, 'callback not invoked (string value)'); + +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.map(cb); +}, 'boolean value'); +assert.sameValue(callCount, 0, 'callback not invoked (boolean value)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-ctor-poisoned.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-ctor-poisoned.js new file mode 100644 index 0000000000..1a1e9d46d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-ctor-poisoned.js @@ -0,0 +1,34 @@ +// 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-array.prototype.map +description: Abrupt completion from `constructor` property access +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). +---*/ + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 1; +}; + +Object.defineProperty(a, 'constructor', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + a.map(cb); +}); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-non-array-invalid-len.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-non-array-invalid-len.js new file mode 100644 index 0000000000..7fe8312574 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-non-array-invalid-len.js @@ -0,0 +1,41 @@ +// 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-array.prototype.map +description: Abrupt completion from creating a new array +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). + + 9.4.2.2 ArrayCreate + + [...] + 3. If length>232-1, throw a RangeError exception. +---*/ + +var callCount = 0; +var obj = { + length: Math.pow(2, 32) +}; +var cb = function() { + callCount += 1; +}; + +assert.throws(RangeError, function() { + Array.prototype.map.call(obj, cb); +}); + +assert.sameValue( + callCount, + 0, + 'RangeError thrown during array creation, not property modification' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-non-array.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-non-array.js new file mode 100644 index 0000000000..1ec3a66d97 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-non-array.js @@ -0,0 +1,35 @@ +// 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-array.prototype.map +description: Constructor is ignored for non-Array values +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). +---*/ + +var obj = { + length: 0 +}; +var callCount = 0; +var result; +Object.defineProperty(obj, 'constructor', { + get: function() { + callCount += 1; + } +}); + +result = Array.prototype.map.call(obj, function() {}); + +assert.sameValue(callCount, 0, '`constructor` property not accessed'); +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert(Array.isArray(result), 'result is an Array exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-proto-from-ctor-realm-array.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-proto-from-ctor-realm-array.js new file mode 100644 index 0000000000..47f97d04c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-proto-from-ctor-realm-array.js @@ -0,0 +1,45 @@ +// 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-array.prototype.map +description: Prefer Array constructor of current realm record +info: | + 1. Let O be ? ToObject(this value). + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C + be undefined. + [...] +features: [cross-realm, Symbol.species] +---*/ + +var array = []; +var callCount = 0; +var OArray = $262.createRealm().global.Array; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OArray; + +Object.defineProperty(Array, Symbol.species, speciesDesc); +Object.defineProperty(OArray, Symbol.species, speciesDesc); + +result = array.map(function() {}); + +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert.sameValue(callCount, 0, 'Species constructor is not referenced'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-proto-from-ctor-realm-non-array.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-proto-from-ctor-realm-non-array.js new file mode 100644 index 0000000000..94e6730e73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-proto-from-ctor-realm-non-array.js @@ -0,0 +1,46 @@ +// 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-array.prototype.map +description: Accept non-Array constructors from other realms +info: | + 1. Let O be ? ToObject(this value). + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C + be undefined. + [...] +features: [cross-realm, Symbol.species] +---*/ + +var array = []; +var callCount = 0; +var CustomCtor = function() {}; +var OObject = $262.createRealm().global.Object; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OObject; +OObject[Symbol.species] = CustomCtor; + +Object.defineProperty(Array, Symbol.species, speciesDesc); + +result = array.map(function() {}); + +assert.sameValue(Object.getPrototypeOf(result), CustomCtor.prototype); +assert.sameValue(callCount, 0, 'Array species constructor is not referenced'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-proxy.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-proxy.js new file mode 100644 index 0000000000..30b932c079 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-proxy.js @@ -0,0 +1,41 @@ +// 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-array.prototype.map +description: Species constructor of a Proxy object whose target is an array +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + 8. Return A. + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + + 7.2.2 IsArray + + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is + null, throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy, Symbol.species] +---*/ + +var array = []; +var proxy = new Proxy(new Proxy(array, {}), {}); +var Ctor = function() {}; +var result; + +array.constructor = function() {}; +array.constructor[Symbol.species] = Ctor; + +result = Array.prototype.map.call(proxy, function() {}); + +assert.sameValue(Object.getPrototypeOf(result), Ctor.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-revoked-proxy.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-revoked-proxy.js new file mode 100644 index 0000000000..03d9ee6e65 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-revoked-proxy.js @@ -0,0 +1,46 @@ +// 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-array.prototype.map +description: Abrupt completion from constructor that is a revoked Proxy object +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + + 7.2.2 IsArray + + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is + null, throw a TypeError exception. +features: [Proxy] +---*/ + +var o = Proxy.revocable([], {}); +var ctorCount = 0; +var cbCount = 0; +var cb = function() { + cbCount += 1; +}; + +Object.defineProperty(o.proxy, 'constructor', { + get: function() { + ctorCount += 1; + } +}); +o.revoke(); + +assert.throws(TypeError, function() { + Array.prototype.map.call(o.proxy, cb); +}); + +assert.sameValue(ctorCount, 0, '`constructor` property not accessed'); +assert.sameValue(cbCount, 0, 'callback not invoked'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-species-abrupt.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-species-abrupt.js new file mode 100644 index 0000000000..d6504a2c0f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-species-abrupt.js @@ -0,0 +1,40 @@ +// 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-array.prototype.map +description: Species constructor returns an abrupt completion +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var Ctor = function() { + throw new Test262Error(); +}; +var callCount = 0; +var cb = function() { + callCount += 1; +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; + +assert.throws(Test262Error, function() { + a.map(cb); +}); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-species-non-ctor.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-species-non-ctor.js new file mode 100644 index 0000000000..35d80e9cd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-species-non-ctor.js @@ -0,0 +1,46 @@ +// 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-array.prototype.map +description: > + Behavior when the @@species attribute is a non-constructor object +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 9. If IsConstructor(C) is false, throw a TypeError exception. +includes: [isConstructor.js] +features: [Symbol.species, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(parseInt), + false, + 'precondition: isConstructor(parseInt) must return false' +); + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 1; +}; + +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; + +assert.throws(TypeError, function() { + a.map(cb); +}, 'a.map(cb) throws a TypeError exception'); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-species-null.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-species-null.js new file mode 100644 index 0000000000..18aecb654e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-species-null.js @@ -0,0 +1,35 @@ +// 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-array.prototype.map +description: > + A null value for the @@species constructor is interpreted as `undefined` +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). +features: [Symbol.species] +---*/ + +var a = []; +var result; + +a.constructor = {}; +a.constructor[Symbol.species] = null; + +result = a.map(function() {}); + +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert(Array.isArray(result), 'result is an Array exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-species-poisoned.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-species-poisoned.js new file mode 100644 index 0000000000..d398b3207c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-species-poisoned.js @@ -0,0 +1,39 @@ +// 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-array.prototype.map +description: Abrupt completion from `@@species` property access +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). +features: [Symbol.species] +---*/ + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 1; +}; +a.constructor = {}; + +Object.defineProperty(a.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + a.map(cb); +}); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-species-undef-invalid-len.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-species-undef-invalid-len.js new file mode 100644 index 0000000000..e3e1f1e7e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-species-undef-invalid-len.js @@ -0,0 +1,61 @@ +// 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-array.prototype.map +description: > + An undefined value for the @@species constructor triggers the creation of + an Array exotic object +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). + + 9.4.2.2 ArrayCreate + + [...] + 3. If length>232-1, throw a RangeError exception. +features: [Proxy] +---*/ + +var array = []; +var maxLength = Math.pow(2, 32); +var cbCount = 0; +var setCount = 0; +var cb = function() { + cbCount += 1; +}; +var proxy = new Proxy(array, { + get: function(_, name) { + if (name === 'length') { + return maxLength; + } + return array[name]; + }, + set: function() { + setCount += 1; + return true; + } +}); + +assert.throws(RangeError, function() { + Array.prototype.map.call(proxy, cb); +}); + +assert.sameValue( + setCount, + 0, + 'RangeError thrown during array creation, not property modification' +); +assert.sameValue(cbCount, 0, 'callback function not invoked'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-species-undef.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-species-undef.js new file mode 100644 index 0000000000..42bff93c06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-species-undef.js @@ -0,0 +1,36 @@ +// 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-array.prototype.map +description: > + An undefined value for the @@species constructor triggers the creation of + an Array exotic object +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). +features: [Symbol.species] +---*/ + +var a = []; +var result; + +a.constructor = {}; +a.constructor[Symbol.species] = undefined; + +result = a.map(function() {}); + +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert(Array.isArray(result), 'result is an Array exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/create-species.js b/js/src/tests/test262/built-ins/Array/prototype/map/create-species.js new file mode 100644 index 0000000000..082a0fd684 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-species.js @@ -0,0 +1,45 @@ +// 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-array.prototype.map +description: Species constructor is used to create a new instance +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, len). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var thisValue, args, result; +var callCount = 0; +var instance = []; +var Ctor = function() { + callCount += 1; + thisValue = this; + args = arguments; + return instance; +}; +var a = [1, 2, 3, 4, 5]; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; + +result = a.map(function() {}); + +assert.sameValue(callCount, 1, 'Constructor invoked exactly once'); +assert.sameValue(Object.getPrototypeOf(thisValue), Ctor.prototype); +assert.sameValue(args.length, 1, 'Constructor invoked with a single argument'); +assert.sameValue(args[0], 5); +assert.sameValue(result, instance); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/length.js b/js/src/tests/test262/built-ins/Array/prototype/map/length.js new file mode 100644 index 0000000000..f0402be9c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + The "length" property of Array.prototype.map +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.map.length, 1); + +verifyNotEnumerable(Array.prototype.map, 'length'); +verifyNotWritable(Array.prototype.map, 'length'); +verifyConfigurable(Array.prototype.map, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/name.js b/js/src/tests/test262/built-ins/Array/prototype/map/name.js new file mode 100644 index 0000000000..75a94bbb83 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map.name is "map". +info: | + Array.prototype.map ( callbackfn [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.map.name, "map"); + +verifyNotEnumerable(Array.prototype.map, "name"); +verifyNotWritable(Array.prototype.map, "name"); +verifyConfigurable(Array.prototype.map, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/map/not-a-constructor.js new file mode 100644 index 0000000000..98945bd366 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/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: > + Array.prototype.map 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, arrow-function] +---*/ + +assert.sameValue(isConstructor(Array.prototype.map), false, 'isConstructor(Array.prototype.map) must return false'); + +assert.throws(TypeError, () => { + new Array.prototype.map(() => {}); +}, '`new Array.prototype.map(() => {})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/map/prop-desc.js new file mode 100644 index 0000000000..e99759506b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + "map" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.map, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "map"); +verifyWritable(Array.prototype, "map"); +verifyConfigurable(Array.prototype, "map"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/shell.js b/js/src/tests/test262/built-ins/Array/prototype/map/shell.js new file mode 100644 index 0000000000..05fecd6ef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/shell.js @@ -0,0 +1,161 @@ +// GENERATED, DO NOT EDIT +// file: testTypedArray.js +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - floatArrayConstructors + - nonClampedIntArrayConstructors + - intArrayConstructors + - typedArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - nonAtomicsFriendlyTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +var floatArrayConstructors = [ + Float64Array, + Float32Array +]; + +var nonClampedIntArrayConstructors = [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array +]; + +var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]); + +// Float16Array is a newer feature +// adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it +if (typeof Float16Array !== 'undefined') { + floatArrayConstructors.push(Float16Array); +} + +/** + * Array containing every non-bigint typed array constructor. + */ + +var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]); +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} + +/** + * Checks if the given argument is one of the float-based TypedArray constructors. + * + * @param {constructor} ctor - the value to check + * @returns {boolean} + */ +function isFloatTypedArrayConstructor(arg) { + return floatArrayConstructors.indexOf(arg) !== -1; +} + +/** + * Determines the precision of the given float-based TypedArray constructor. + * + * @param {constructor} ctor - the value to check + * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively. + */ +function floatTypedArrayConstructorPrecision(FA) { + if (typeof Float16Array !== "undefined" && FA === Float16Array) { + return "half"; + } else if (FA === Float32Array) { + return "single"; + } else if (FA === Float64Array) { + return "double"; + } else { + throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray"); + } +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/target-array-non-extensible.js b/js/src/tests/test262/built-ins/Array/prototype/map/target-array-non-extensible.js new file mode 100644 index 0000000000..b090aa6942 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/target-array-non-extensible.js @@ -0,0 +1,41 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible) +info: | + Array.prototype.map ( callbackfn [ , thisArg ] ) + + [...] + 6. Repeat, while k < len + [...] + c. If kPresent is true, then + [...] + iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; + +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.map(function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/target-array-with-non-configurable-property.js b/js/src/tests/test262/built-ins/Array/prototype/map/target-array-with-non-configurable-property.js new file mode 100644 index 0000000000..f3f563674f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/target-array-with-non-configurable-property.js @@ -0,0 +1,43 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable) +info: | + Array.prototype.map ( callbackfn [ , thisArg ] ) + + [...] + 6. Repeat, while k < len + [...] + c. If kPresent is true, then + [...] + iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + set: function(_value) {}, + configurable: false, + }); +}; + +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.map(function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/target-array-with-non-writable-property.js b/js/src/tests/test262/built-ins/Array/prototype/map/target-array-with-non-writable-property.js new file mode 100644 index 0000000000..c8761fb5d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/target-array-with-non-writable-property.js @@ -0,0 +1,38 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Non-writable properties are overwritten by CreateDataPropertyOrThrow. +info: | + 22.1.3.16 Array.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat, while k < len + ... + c. If kPresent is true, then + ... + iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue). + ... +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var a = [1]; +a.constructor = {}; +a.constructor[Symbol.species] = function(len) { + var q = new Array(0); + Object.defineProperty(q, 0, { + value: 0, writable: false, configurable: true, enumerable: false, + }); + return q; +}; + +var r = a.map(function(){ return 2; }); + +verifyProperty(r, 0, { + value: 2, writable: true, configurable: true, enumerable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/methods-called-as-functions.js b/js/src/tests/test262/built-ins/Array/prototype/methods-called-as-functions.js new file mode 100644 index 0000000000..7130ad549d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/methods-called-as-functions.js @@ -0,0 +1,205 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-the-array-prototype-object +description: > + Array.prototype methods resolve `this` value using strict mode semantics, + throwing TypeError if called as top-level function. +info: | + Array.prototype.concat ( ...items ) + + 1. Let O be ? ToObject(this value). + + ToObject ( argument ) + + Argument Type: Undefined + Result: Throw a TypeError exception. +features: [Symbol, Symbol.isConcatSpreadable, Symbol.iterator, Symbol.species, Array.prototype.flat, Array.prototype.flatMap, Array.prototype.includes] +---*/ + +["constructor", "length", "0", Symbol.isConcatSpreadable, Symbol.species].forEach(function(key) { + Object.defineProperty(this, key, { + get: function() { + throw new Test262Error(String(key) + " lookup should not be performed"); + }, + }); +}, this); + +function callback() { + throw new Test262Error("callback should not be called"); +} + +var index = { + get valueOf() { + throw new Test262Error("index should not be coerced to number"); + }, +}; + +var separator = { + get toString() { + throw new Test262Error("separator should not be coerced to string"); + }, +}; + +var concat = Array.prototype.concat; +assert.throws(TypeError, function() { + concat(); +}, "concat"); + +var copyWithin = Array.prototype.copyWithin; +assert.throws(TypeError, function() { + copyWithin(index, index); +}, "copyWithin"); + +var entries = Array.prototype.entries; +assert.throws(TypeError, function() { + entries(); +}, "entries"); + +var every = Array.prototype.every; +assert.throws(TypeError, function() { + every(callback); +}, "every"); + +var fill = Array.prototype.fill; +assert.throws(TypeError, function() { + fill(0); +}, "fill"); + +var filter = Array.prototype.filter; +assert.throws(TypeError, function() { + filter(callback); +}, "filter"); + +var find = Array.prototype.find; +assert.throws(TypeError, function() { + find(callback); +}, "find"); + +var findIndex = Array.prototype.findIndex; +assert.throws(TypeError, function() { + findIndex(callback); +}, "findIndex"); + +var flat = Array.prototype.flat; +assert.throws(TypeError, function() { + flat(index); +}, "flat"); + +var flatMap = Array.prototype.flatMap; +assert.throws(TypeError, function() { + flatMap(callback); +}, "flatMap"); + +var forEach = Array.prototype.forEach; +assert.throws(TypeError, function() { + forEach(callback); +}, "forEach"); + +var includes = Array.prototype.includes; +assert.throws(TypeError, function() { + includes(0, index); +}, "includes"); + +var indexOf = Array.prototype.indexOf; +assert.throws(TypeError, function() { + indexOf(0, index); +}, "indexOf"); + +var join = Array.prototype.join; +assert.throws(TypeError, function() { + join(separator); +}, "join"); + +var keys = Array.prototype.keys; +assert.throws(TypeError, function() { + keys(); +}, "keys"); + +var lastIndexOf = Array.prototype.lastIndexOf; +assert.throws(TypeError, function() { + lastIndexOf(0, index); +}, "lastIndexOf"); + +var map = Array.prototype.map; +assert.throws(TypeError, function() { + map(callback); +}, "map"); + +var pop = Array.prototype.pop; +assert.throws(TypeError, function() { + pop(); +}, "pop"); + +var push = Array.prototype.push; +assert.throws(TypeError, function() { + push(); +}, "push"); + +var reduce = Array.prototype.reduce; +assert.throws(TypeError, function() { + reduce(callback, 0); +}, "reduce"); + +var reduceRight = Array.prototype.reduceRight; +assert.throws(TypeError, function() { + reduceRight(callback, 0); +}, "reduceRight"); + +var reverse = Array.prototype.reverse; +assert.throws(TypeError, function() { + reverse(); +}, "reverse"); + +var shift = Array.prototype.shift; +assert.throws(TypeError, function() { + shift(); +}, "shift"); + +var slice = Array.prototype.slice; +assert.throws(TypeError, function() { + slice(index, index); +}, "slice"); + +var some = Array.prototype.some; +assert.throws(TypeError, function() { + some(callback); +}, "some"); + +var sort = Array.prototype.sort; +assert.throws(TypeError, function() { + sort(callback); +}, "sort"); + +var splice = Array.prototype.splice; +assert.throws(TypeError, function() { + splice(index, index); +}, "splice"); + +var toLocaleString = Array.prototype.toLocaleString; +assert.throws(TypeError, function() { + toLocaleString(); +}, "toLocaleString"); + +var toString = Array.prototype.toString; +assert.throws(TypeError, function() { + toString(); +}, "toString"); + +var unshift = Array.prototype.unshift; +assert.throws(TypeError, function() { + unshift(); +}, "unshift"); + +var values = Array.prototype.values; +assert.throws(TypeError, function() { + values(); +}, "values"); + +var iterator = Array.prototype[Symbol.iterator]; +assert.throws(TypeError, function() { + iterator(); +}, "Symbol.iterator"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A1.1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A1.1_T1.js new file mode 100644 index 0000000000..6463da32cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A1.1_T1.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If length equal zero, call the [[Put]] method of this object + with arguments "length" and 0 and return undefined +esid: sec-array.prototype.pop +description: Checking this algorithm +---*/ + +var x = new Array(); +var pop = x.pop(); +if (pop !== undefined) { + throw new Test262Error('#1: var x = new Array(); x.pop() === undefined. Actual: ' + (pop)); +} + +if (x.length !== 0) { + throw new Test262Error('#2: var x = new Array(); x.pop(); x.length === 0. Actual: ' + (x.length)); +} + +var x = Array(1, 2, 3); +x.length = 0; +var pop = x.pop(); +if (pop !== undefined) { + throw new Test262Error('#2: var x = Array(1,2,3); x.length = 0; x.pop() === undefined. Actual: ' + (pop)); +} + +if (x.length !== 0) { + throw new Test262Error('#4: var x = new Array(1,2,3); x.length = 0; x.pop(); x.length === 0. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A1.2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A1.2_T1.js new file mode 100644 index 0000000000..97cab3dc1e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A1.2_T1.js @@ -0,0 +1,60 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The last element of the array is removed from the array + and returned +esid: sec-array.prototype.pop +description: Checking this use new Array() and [] +---*/ + +var x = new Array(0, 1, 2, 3); +var pop = x.pop(); +if (pop !== 3) { + throw new Test262Error('#1: x = new Array(0,1,2,3); x.pop() === 3. Actual: ' + (pop)); +} + +if (x.length !== 3) { + throw new Test262Error('#2: x = new Array(0,1,2,3); x.pop(); x.length == 3'); +} + +if (x[3] !== undefined) { + throw new Test262Error('#3: x = new Array(0,1,2,3); x.pop(); x[3] == undefined'); +} + +if (x[2] !== 2) { + throw new Test262Error('#4: x = new Array(0,1,2,3); x.pop(); x[2] == 2'); +} + +x = []; +x[0] = 0; +x[3] = 3; +var pop = x.pop(); +if (pop !== 3) { + throw new Test262Error('#5: x = []; x[0] = 0; x[3] = 3; x.pop() === 3. Actual: ' + (pop)); +} + +if (x.length !== 3) { + throw new Test262Error('#6: x = []; x[0] = 0; x[3] = 3; x.pop(); x.length == 3'); +} + +if (x[3] !== undefined) { + throw new Test262Error('#7: x = []; x[0] = 0; x[3] = 3; x.pop(); x[3] == undefined'); +} + +if (x[2] !== undefined) { + throw new Test262Error('#8: x = []; x[0] = 0; x[3] = 3; x.pop(); x[2] == undefined'); +} + +x.length = 1; +var pop = x.pop(); +if (pop !== 0) { + throw new Test262Error('#9: x = []; x[0] = 0; x[3] = 3; x.pop(); x.length = 1; x.pop() === 0. Actual: ' + (pop)); +} + +if (x.length !== 0) { + throw new Test262Error('#10: x = []; x[0] = 0; x[3] = 3; x.pop(); x.length = 1; x.pop(); x.length === 0. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T1.js new file mode 100644 index 0000000000..9961c4733a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T1.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The pop function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.pop +description: > + If ToUint32(length) equal zero, call the [[Put]] method of this + object with arguments "length" and 0 and return undefined +---*/ + +var obj = {}; +obj.pop = Array.prototype.pop; + +if (obj.length !== undefined) { + throw new Test262Error('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + var pop = obj.pop(); + if (pop !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); + } + if (obj.length !== 0) { + throw new Test262Error('#2: var obj = {}; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); + } +} + +obj.length = undefined; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#3: var obj = {}; obj.length = undefined; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +if (obj.length !== 0) { + throw new Test262Error('#4: var obj = {}; obj.length = undefined; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} + +obj.length = null +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.length = null; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +if (obj.length !== 0) { + throw new Test262Error('#6: var obj = {}; obj.length = null; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T2.js new file mode 100644 index 0000000000..f414f4d00a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T2.js @@ -0,0 +1,81 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The pop function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.pop +description: > + If ToUint32(length) equal zero, call the [[Put]] method of this + object with arguments "length" and 0 and return undefined +---*/ + +var obj = {}; +obj.pop = Array.prototype.pop; + +obj.length = NaN; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.length = NaN; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +if (obj.length !== 0) { + throw new Test262Error('#2: var obj = {}; obj.length = NaN; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} + +obj.length = Number.POSITIVE_INFINITY; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#3: var obj = {}; obj.length = Number.POSITIVE_INFINITY; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +if (obj.length !== 9007199254740990) { + throw new Test262Error('#4: var obj = {}; obj.length = Number.POSITIVE_INFINITY; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 9007199254740990. Actual: ' + (obj.length)); +} + +obj.length = Number.NEGATIVE_INFINITY; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +if (obj.length !== 0) { + throw new Test262Error('#6: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} + +obj.length = -0; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#7: var obj = {}; obj.length = -0; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +if (obj.length !== 0) { + throw new Test262Error('#8: var obj = {}; obj.length = -0; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} else { + if (1 / obj.length !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#8: var obj = {}; obj.length = -0; obj.pop = Array.prototype.pop; obj.pop(); obj.length === +0. Actual: ' + (obj.length)); + } +} + +obj.length = 0.5; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#9: var obj = {}; obj.length = 0.5; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +if (obj.length !== 0) { + throw new Test262Error('#10: var obj = {}; obj.length = 0.5; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} + +obj.length = new Number(0); +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#11: var obj = {}; obj.length = new Number(0); obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +if (obj.length !== 0) { + throw new Test262Error('#12: var obj = {}; obj.length = new Number(0); obj.pop = Array.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T3.js b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T3.js new file mode 100644 index 0000000000..74df6b3500 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T3.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The pop function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.pop +description: > + The last element ToUint32(length) - 1 of the array is removed from + the array and returned +---*/ + +var obj = {}; +obj.pop = Array.prototype.pop; + +obj.length = 2.5; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.length = 2.5; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +if (obj.length !== 1) { + throw new Test262Error('#2: var obj = {}; obj.length = 2.5; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 1. Actual: ' + (obj.length)); +} + +obj.length = new Number(2); +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#11: var obj = {}; obj.length = new Number(2); obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +if (obj.length !== 1) { + throw new Test262Error('#12: var obj = {}; obj.length = new Number(2); obj.pop = Array.prototype.pop; obj.pop(); obj.length === 1. Actual: ' + (obj.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T4.js b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T4.js new file mode 100644 index 0000000000..d37f8024d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T4.js @@ -0,0 +1,126 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The pop function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.pop +description: > + Operator use ToNumber from length. If Type(value) is Object, + evaluate ToPrimitive(value, Number) +---*/ + +var obj = {}; +obj.pop = Array.prototype.pop; + +obj[0] = -1; +obj.length = { + valueOf() { + return 1 + } +}; +var pop = obj.pop(); +assert.sameValue(pop, -1, 'The value of pop is expected to be -1'); + +obj[0] = -1; +obj.length = { + valueOf() { + return 1 + }, + toString() { + return 0 + } +}; +var pop = obj.pop(); +assert.sameValue(pop, -1, 'The value of pop is expected to be -1'); + +obj[0] = -1; +obj.length = { + valueOf() { + return 1 + }, + toString() { + return {} + } +}; +var pop = obj.pop(); +assert.sameValue(pop, -1, 'The value of pop is expected to be -1'); + +try { + obj[0] = -1; + obj.length = { + valueOf() { + return 1 + }, + toString() { + throw "error" + } + }; + var pop = obj.pop(); + assert.sameValue(pop, -1, 'The value of pop is expected to be -1'); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} + +obj[0] = -1; +obj.length = { + toString() { + return 0 + } +}; +var pop = obj.pop(); +assert.sameValue(pop, undefined, 'The value of pop is expected to equal undefined'); + +obj[0] = -1; +obj.length = { + valueOf() { + return {} + }, + toString() { + return 0 + } +} +var pop = obj.pop(); +assert.sameValue(pop, undefined, 'The value of pop is expected to equal undefined'); + +try { + obj[0] = -1; + obj.length = { + valueOf() { + throw "error" + }, + toString() { + return 0 + } + }; + var pop = obj.pop(); + throw new Test262Error('#7.1: obj[0] = -1; obj.length = {valueOf() {throw "error"}, toString() {return 0}}; obj.pop() throw "error". Actual: ' + (pop)); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} + +try { + obj[0] = -1; + obj.length = { + valueOf() { + return {} + }, + toString() { + return {} + } + }; + var pop = obj.pop(); + throw new Test262Error('#8.1: obj[0] = -1; obj.length = {valueOf() {return {}}, toString() {return {}}} obj.pop() throw TypeError. Actual: ' + (pop)); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A3_T1.js b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A3_T1.js new file mode 100644 index 0000000000..7c0ce497dc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A3_T1.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.pop +description: length = 4294967296 +---*/ + +var obj = {}; +obj.pop = Array.prototype.pop; +obj[0] = "x"; +obj[4294967295] = "y"; +obj.length = 4294967296; + +var pop = obj.pop(); +if (pop !== "y") { + throw new Test262Error('#1: var obj = {}; obj.pop = Array.prototype.pop; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; obj.pop() === "y". Actual: ' + (pop)); +} + +if (obj.length !== 4294967295) { + throw new Test262Error('#2: var obj = {}; obj.pop = Array.prototype.pop; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; obj.pop(); obj.length === 4294967295. Actual: ' + (obj.length)); +} + +if (obj[0] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.pop = Array.prototype.pop; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; obj.pop(); obj[0] === "x". Actual: ' + (obj[0])); +} + +if (obj[4294967295] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.pop = Array.prototype.pop; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; obj.pop(); obj[4294967295] === undefined. Actual: ' + (obj[4294967295])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A3_T2.js b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A3_T2.js new file mode 100644 index 0000000000..b6de632743 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A3_T2.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.pop +description: length = 4294967297 +---*/ + +var obj = {}; +obj.pop = Array.prototype.pop; +obj[0] = "x"; +obj[4294967296] = "y"; +obj.length = 4294967297; + +var pop = obj.pop(); +if (pop !== "y") { + throw new Test262Error('#1: var obj = {}; obj.pop = Array.prototype.pop; obj[0] = "x"; obj[4294967296] = "y"; obj.length = 4294967297; obj.pop() === "y". Actual: ' + (pop)); +} + +if (obj.length !== 4294967296) { + throw new Test262Error('#2: var obj = {}; obj.pop = Array.prototype.pop; obj[0] = "x"; obj[4294967296] = "y"; obj.length = 4294967297; obj.pop(); obj.length === 4294967296. Actual: ' + (obj.length)); +} + +if (obj[0] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.pop = Array.prototype.pop; obj[0] = "x"; obj[4294967296] = "y"; obj.length = 4294967297; obj.pop(); obj[0] === "x". Actual: ' + (obj[0])); +} + +if (obj[4294967296] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.pop = Array.prototype.pop; obj[0] = "x"; obj[4294967296] = "y"; obj.length = 4294967297; obj.pop(); obj[4294967296] === undefined. Actual: ' + (obj[4294967296])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A3_T3.js b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A3_T3.js new file mode 100644 index 0000000000..7086832284 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A3_T3.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.pop +description: length = -1 +---*/ + +var obj = {}; +obj.pop = Array.prototype.pop; +obj[4294967294] = "x"; +obj.length = -1; + +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.pop = Array.prototype.pop; obj[4294967294] = "x"; obj.length = -1; obj.pop() === undefined. Actual: ' + (pop)); +} + +if (obj.length !== 0) { + throw new Test262Error('#2: var obj = {}; obj.pop = Array.prototype.pop; obj[4294967294] = "x"; obj.length = -1; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} + +if (obj[4294967294] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.pop = Array.prototype.pop; obj[4294967294] = "x"; obj.length = -1; obj.pop(); obj[4294967294] === "x". Actual: ' + (obj[4294967294])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A4_T1.js b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A4_T1.js new file mode 100644 index 0000000000..454bd58b98 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A4_T1.js @@ -0,0 +1,50 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.pop +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Array.prototype[1] = 1; +var x = [0]; +x.length = 2; + +var pop = x.pop(); +if (pop !== 1) { + throw new Test262Error('#1: Array.prototype[1] = 1; x = [0]; x.length = 2; x.pop() === 1. Actual: ' + (pop)); +} + +if (x[1] !== 1) { + throw new Test262Error('#2: Array.prototype[1] = 1; x = [0]; x.length = 2; x.pop(); x[1] === 1. Actual: ' + (x[1])); +} + +Object.prototype[1] = 1; +Object.prototype.length = 2; +Object.prototype.pop = Array.prototype.pop; +x = { + 0: 0 +}; + +var pop = x.pop(); +if (pop !== 1) { + throw new Test262Error('#3: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.pop = Array.prototype.pop; x = {0:0}; x.pop() === 1. Actual: ' + (pop)); +} + +if (x[1] !== 1) { + throw new Test262Error('#4: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.pop = Array.prototype.pop; x = {0:0}; x.pop(); x[1] === 1. Actual: ' + (x[1])); +} + +if (x.length !== 1) { + throw new Test262Error('#6: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.pop = Array.prototype.pop; x = {0:0}; x.pop(); x.length === 1. Actual: ' + (x.length)); +} + +delete x.length; +if (x.length !== 2) { + throw new Test262Error('#7: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.pop = Array.prototype.pop; x = {0:0}; x.pop(); delete x; x.length === 2. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A4_T2.js b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A4_T2.js new file mode 100644 index 0000000000..51ed4692cf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A4_T2.js @@ -0,0 +1,51 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.pop +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Array.prototype[1] = -1; +var x = [0, 1]; +x.length = 2; + +var pop = x.pop(); +if (pop !== 1) { + throw new Test262Error('#1: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.pop() === 1. Actual: ' + (pop)); +} + +if (x[1] !== -1) { + throw new Test262Error('#2: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.pop(); x[1] === -1. Actual: ' + (x[1])); +} + +Object.prototype[1] = -1; +Object.prototype.length = 2; +Object.prototype.pop = Array.prototype.pop; +x = { + 0: 0, + 1: 1 +}; + +var pop = x.pop(); +if (pop !== 1) { + throw new Test262Error('#3: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.pop = Array.prototype.pop; x = {0:0,1:1}; x.pop() === 1. Actual: ' + (pop)); +} + +if (x[1] !== -1) { + throw new Test262Error('#4: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.pop = Array.prototype.pop; x = {0:0,1:1}; x.pop(); x[1] === -1. Actual: ' + (x[1])); +} + +if (x.length !== 1) { + throw new Test262Error('#6: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.pop = Array.prototype.pop; x = {0:0,1:1}; x.pop(); x.length === 1. Actual: ' + (x.length)); +} + +delete x.length; +if (x.length !== 2) { + throw new Test262Error('#7: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.pop = Array.prototype.pop; x = {0:0,1:1}; x.pop(); delete x; x.length === 2. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/browser.js b/js/src/tests/test262/built-ins/Array/prototype/pop/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/pop/call-with-boolean.js new file mode 100644 index 0000000000..024b63e892 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/call-with-boolean.js @@ -0,0 +1,12 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.pop +description: Array.prototype.pop applied to boolean primitive +---*/ + +assert.sameValue(Array.prototype.pop.call(true), undefined, 'Array.prototype.pop.call(true) must return undefined'); +assert.sameValue(Array.prototype.pop.call(false), undefined, 'Array.prototype.pop.call(false) must return undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/clamps-to-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/pop/clamps-to-integer-limit.js new file mode 100644 index 0000000000..4f0b10b147 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/clamps-to-integer-limit.js @@ -0,0 +1,38 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.pop +description: > + Length values exceeding 2^53-1 are clamped to 2^53-1. +info: | + 1. ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... + 4. Else len > 0, + a. Let newLen be len-1. + ... + e. Perform ? Set(O, "length", newLen, true). + ... +features: [exponentiation] +---*/ + +var arrayLike = {}; + +arrayLike.length = 2 ** 53 - 1; +Array.prototype.pop.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 2, "Length is 2**53 - 1"); + +arrayLike.length = 2 ** 53; +Array.prototype.pop.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 2, "Length is 2**53"); + +arrayLike.length = 2 ** 53 + 2; +Array.prototype.pop.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 2, "Length is 2**53 + 2"); + +arrayLike.length = Infinity; +Array.prototype.pop.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 2, "Length is Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/length-near-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/pop/length-near-integer-limit.js new file mode 100644 index 0000000000..65cb4b0132 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/length-near-integer-limit.js @@ -0,0 +1,46 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.pop +description: > + A value is removed from an array-like object whose length property is near the integer limit. +info: | + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... + 4. Else len > 0, + a. Let newLen be len-1. + b. Let index be ! ToString(newLen). + c. Let element be ? Get(O, index). + d. Perform ? DeletePropertyOrThrow(O, index). + e. Perform ? Set(O, "length", newLen, true). + f. Return element. +features: [exponentiation] +---*/ + +var arrayLike = { + "9007199254740989": "9007199254740989", + "9007199254740990": "9007199254740990", + "9007199254740991": "9007199254740991", + length: 2 ** 53 - 1 +}; + +var value = Array.prototype.pop.call(arrayLike); + +assert.sameValue(value, "9007199254740990", + "arrayLike['9007199254740990'] is returned from pop()"); + +assert.sameValue(arrayLike.length, 2 ** 53 - 2, + "New arrayLike.length is 2**53 - 2"); + +assert.sameValue(arrayLike["9007199254740989"], "9007199254740989", + "arrayLike['9007199254740989'] is unchanged"); + +assert.sameValue("9007199254740990" in arrayLike, false, + "arrayLike['9007199254740990'] is removed"); + +assert.sameValue(arrayLike["9007199254740991"], "9007199254740991", + "arrayLike['9007199254740991'] is unchanged"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/length.js b/js/src/tests/test262/built-ins/Array/prototype/pop/length.js new file mode 100644 index 0000000000..6285c752f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.pop +description: > + The "length" property of Array.prototype.pop +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.pop.length, 0); + +verifyNotEnumerable(Array.prototype.pop, 'length'); +verifyNotWritable(Array.prototype.pop, 'length'); +verifyConfigurable(Array.prototype.pop, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/name.js b/js/src/tests/test262/built-ins/Array/prototype/pop/name.js new file mode 100644 index 0000000000..891fb91858 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.pop +description: > + Array.prototype.pop.name is "pop". +info: | + Array.prototype.pop ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.pop.name, "pop"); + +verifyNotEnumerable(Array.prototype.pop, "name"); +verifyNotWritable(Array.prototype.pop, "name"); +verifyConfigurable(Array.prototype.pop, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/pop/not-a-constructor.js new file mode 100644 index 0000000000..849c2b3305 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/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: > + Array.prototype.pop 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, arrow-function] +---*/ + +assert.sameValue(isConstructor(Array.prototype.pop), false, 'isConstructor(Array.prototype.pop) must return false'); + +assert.throws(TypeError, () => { + new Array.prototype.pop(); +}, '`new Array.prototype.pop()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/pop/prop-desc.js new file mode 100644 index 0000000000..c39724bd1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.pop +description: > + "pop" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.pop, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "pop"); +verifyWritable(Array.prototype, "pop"); +verifyConfigurable(Array.prototype, "pop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/set-length-array-is-frozen.js b/js/src/tests/test262/built-ins/Array/prototype/pop/set-length-array-is-frozen.js new file mode 100644 index 0000000000..d083e0eb19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/set-length-array-is-frozen.js @@ -0,0 +1,49 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.pop +description: > + A TypeError is thrown when "length" is [[Set]] on a frozen array. +info: | + Array.prototype.pop ( ) + + [...] + 4. Else, + a. Assert: len > 0. + b. Let newLen be 𝔽(len - 1). + c. Let index be ! ToString(newLen). + d. Let element be ? Get(O, index). + e. Perform ? DeletePropertyOrThrow(O, index). + f. Perform ? Set(O, "length", newLen, true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = new Array(1); +var arrayPrototypeGet0Calls = 0; + +Object.defineProperty(Array.prototype, "0", { + get() { + Object.freeze(array); + arrayPrototypeGet0Calls++; + }, +}); + +assert.throws(TypeError, function() { + array.pop(); +}); + +assert.sameValue(array.length, 1); +assert.sameValue(arrayPrototypeGet0Calls, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/set-length-array-length-is-non-writable.js b/js/src/tests/test262/built-ins/Array/prototype/pop/set-length-array-length-is-non-writable.js new file mode 100644 index 0000000000..b53a73d867 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/set-length-array-length-is-non-writable.js @@ -0,0 +1,49 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.pop +description: > + A TypeError is thrown when "length" is [[Set]] on an array with non-writable "length". +info: | + Array.prototype.pop ( ) + + [...] + 4. Else, + a. Assert: len > 0. + b. Let newLen be 𝔽(len - 1). + c. Let index be ! ToString(newLen). + d. Let element be ? Get(O, index). + e. Perform ? DeletePropertyOrThrow(O, index). + f. Perform ? Set(O, "length", newLen, true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = new Array(1); +var arrayPrototypeGet0Calls = 0; + +Object.defineProperty(Array.prototype, "0", { + get() { + Object.defineProperty(array, "length", { writable: false }); + arrayPrototypeGet0Calls++; + }, +}); + +assert.throws(TypeError, function() { + array.pop(); +}); + +assert.sameValue(array.length, 1); +assert.sameValue(arrayPrototypeGet0Calls, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/set-length-zero-array-is-frozen.js b/js/src/tests/test262/built-ins/Array/prototype/pop/set-length-zero-array-is-frozen.js new file mode 100644 index 0000000000..a4fc043959 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/set-length-zero-array-is-frozen.js @@ -0,0 +1,34 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.pop +description: > + A TypeError is thrown when "length" is [[Set]] on an empty frozen array. +info: | + Array.prototype.pop ( ) + + [...] + 3. If len = 0, then + a. Perform ? Set(O, "length", +0𝔽, true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = []; +Object.freeze(array); + +assert.throws(TypeError, function() { + array.pop(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/set-length-zero-array-length-is-non-writable.js b/js/src/tests/test262/built-ins/Array/prototype/pop/set-length-zero-array-length-is-non-writable.js new file mode 100644 index 0000000000..36664bc495 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/set-length-zero-array-length-is-non-writable.js @@ -0,0 +1,34 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.pop +description: > + A TypeError is thrown when "length" is [[Set]] on an empty array with non-writable "length". +info: | + Array.prototype.pop ( ) + + [...] + 3. If len = 0, then + a. Perform ? Set(O, "length", +0𝔽, true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = []; +Object.defineProperty(array, "length", { writable: false }); + +assert.throws(TypeError, function() { + array.pop(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/shell.js b/js/src/tests/test262/built-ins/Array/prototype/pop/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/throws-with-string-receiver.js b/js/src/tests/test262/built-ins/Array/prototype/pop/throws-with-string-receiver.js new file mode 100644 index 0000000000..4c2bfa1bff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/throws-with-string-receiver.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Sony Interactive Entertainment Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.pop +description: > + Array#pop throws TypeError upon attempting to modify a string +info: | + Array.prototype.pop ( ) + ... + 3. If len is zero, then + a. Perform ? Set(O, "length", 0, true). + ... + 4. Else, + ... + f. Perform ? Set(O, "length", newLen, true). + + Set ( O, P, V, Throw ) + ... + 4. Let success be ? O.[[Set]](P, V, O). + 5. If success is false and Throw is true, throw a TypeError exception. +---*/ + +assert.throws(TypeError, () => { + Array.prototype.pop.call(''); +}, "Array.prototype.pop.call('')"); + +assert.throws(TypeError, () => { + Array.prototype.pop.call('abc'); +}, "Array.prototype.pop.call('abc')"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/prop-desc.js new file mode 100644 index 0000000000..5b3084aec5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/prop-desc.js @@ -0,0 +1,22 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype +description: > + The property descriptor of Array.prototype +info: | + 22.1.2.4 Array.prototype + + The value of Array.prototype is %ArrayPrototype%, the intrinsic Array prototype object. + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Array, 'prototype'); +verifyNotWritable(Array, 'prototype'); +verifyNotConfigurable(Array, 'prototype'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/proto.js b/js/src/tests/test262/built-ins/Array/prototype/proto.js new file mode 100644 index 0000000000..9d65c83869 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/proto.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-the-array-prototype-object +description: > + The [[Prototype]] of Array.prototype is Object.Prototype. +info: | + 22.1.3 Properties of the Array Prototype Object + + The value of the [[Prototype]] internal slot of the Array prototype object is + the intrinsic object %ObjectPrototype%. +---*/ + +assert.sameValue(Object.getPrototypeOf(Array.prototype), Object.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A1_T1.js new file mode 100644 index 0000000000..e8b82b1e15 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A1_T1.js @@ -0,0 +1,45 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The arguments are appended to the end of the array, in + the order in which they appear. The new length of the array is returned + as the result of the call +esid: sec-array.prototype.push +description: Checking case when push is given no arguments or one argument +---*/ + +var x = new Array(); +var push = x.push(1); +if (push !== 1) { + throw new Test262Error('#1: x = new Array(); x.push(1) === 1. Actual: ' + (push)); +} + +if (x[0] !== 1) { + throw new Test262Error('#2: x = new Array(); x.push(1); x[0] === 1. Actual: ' + (x[0])); +} + +var push = x.push(); +if (push !== 1) { + throw new Test262Error('#3: x = new Array(); x.push(1); x.push() === 1. Actual: ' + (push)); +} + +if (x[1] !== undefined) { + throw new Test262Error('#4: x = new Array(); x.push(1); x.push(); x[1] === unedfined. Actual: ' + (x[1])); +} + +var push = x.push(-1); +if (push !== 2) { + throw new Test262Error('#5: x = new Array(); x.push(1); x.push(); x.push(-1) === 2. Actual: ' + (push)); +} + +if (x[1] !== -1) { + throw new Test262Error('#6: x = new Array(); x.push(1); x.push(-1); x[1] === -1. Actual: ' + (x[1])); +} + +if (x.length !== 2) { + throw new Test262Error('#7: x = new Array(); x.push(1); x.push(); x.push(-1); x.length === 2. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A1_T2.js b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A1_T2.js new file mode 100644 index 0000000000..602b34e1b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A1_T2.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The arguments are appended to the end of the array, in + the order in which they appear. The new length of the array is returned + as the result of the call +esid: sec-array.prototype.push +description: Checking case when push is given many arguments +---*/ + +var x = []; +if (x.length !== 0) { + throw new Test262Error('#1: x = []; x.length === 0. Actual: ' + (x.length)); +} + +x[0] = 0; +var push = x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); +if (push !== 6) { + throw new Test262Error('#2: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1) === 6. Actual: ' + (push)); +} + +if (x[0] !== 0) { + throw new Test262Error('#3: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== true) { + throw new Test262Error('#4: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[1] === true. Actual: ' + (x[1])); +} + +if (x[2] !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#5: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[2] === Number.POSITIVE_INFINITY. Actual: ' + (x[2])); +} + +if (x[3] !== "NaN") { + throw new Test262Error('#6: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[3] === "NaN". Actual: ' + (x[3])); +} + +if (x[4] !== "1") { + throw new Test262Error('#7: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[4] === "1". Actual: ' + (x[4])); +} + +if (x[5] !== -1) { + throw new Test262Error('#8: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[5] === -1. Actual: ' + (x[5])); +} + +if (x.length !== 6) { + throw new Test262Error('#9: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x.length === 6. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_T1.js new file mode 100644 index 0000000000..2e5e878a92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_T1.js @@ -0,0 +1,61 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The push function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.push +description: > + The arguments are appended to the end of the array, in the order + in which they appear. The new length of the array is returned as + the result of the call +---*/ + +var obj = {}; +obj.push = Array.prototype.push; + +if (obj.length !== undefined) { + throw new Test262Error('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + var push = obj.push(-1); + if (push !== 1) { + throw new Test262Error('#1: var obj = {}; obj.push = Array.prototype.push; obj.push(-1) === 1. Actual: ' + (push)); + } + if (obj.length !== 1) { + throw new Test262Error('#2: var obj = {}; obj.push = Array.prototype.push; obj.push(-1); obj.length === 1. Actual: ' + (obj.length)); + } + if (obj["0"] !== -1) { + throw new Test262Error('#3: var obj = {}; obj.push = Array.prototype.push; obj.push(-1); obj["0"] === -1. Actual: ' + (obj["0"])); + } +} + +obj.length = undefined; +var push = obj.push(-4); +if (push !== 1) { + throw new Test262Error('#4: var obj = {}; obj.length = undefined; obj.push = Array.prototype.push; obj.push(-4) === 1. Actual: ' + (push)); +} + +if (obj.length !== 1) { + throw new Test262Error('#5: var obj = {}; obj.length = undefined; obj.push = Array.prototype.push; obj.push(-4); obj.length === 1. Actual: ' + (obj.length)); +} + +if (obj["0"] !== -4) { + throw new Test262Error('#6: var obj = {}; obj.length = undefined; obj.push = Array.prototype.push; obj.push(-4); obj["0"] === -4. Actual: ' + (obj["0"])); +} + +obj.length = null +var push = obj.push(-7); +if (push !== 1) { + throw new Test262Error('#7: var obj = {}; obj.length = null; obj.push = Array.prototype.push; obj.push(-7) === 1. Actual: ' + (push)); +} + +if (obj.length !== 1) { + throw new Test262Error('#8: var obj = {}; obj.length = null; obj.push = Array.prototype.push; obj.push(-7); obj.length === 1. Actual: ' + (obj.length)); +} + +if (obj["0"] !== -7) { + throw new Test262Error('#9: var obj = {}; obj.length = null; obj.push = Array.prototype.push; obj.push(-7); obj["0"] === -7. Actual: ' + (obj["0"])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_T2.js new file mode 100644 index 0000000000..2e35207c02 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_T2.js @@ -0,0 +1,101 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The push function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.push +description: > + The arguments are appended to the end of the array, in the order + in which they appear. The new length of the array is returned as + the result of the call +---*/ + +var obj = {}; +obj.push = Array.prototype.push; + +obj.length = NaN; +var push = obj.push(-1); +if (push !== 1) { + throw new Test262Error('#1: var obj = {}; obj.length = NaN; obj.push = Array.prototype.push; obj.push(-1) === 1. Actual: ' + (push)); +} + +if (obj.length !== 1) { + throw new Test262Error('#2: var obj = {}; obj.length = NaN; obj.push = Array.prototype.push; obj.push(-1); obj.length === 1. Actual: ' + (obj.length)); +} + +if (obj["0"] !== -1) { + throw new Test262Error('#3: var obj = {}; obj.length = NaN; obj.push = Array.prototype.push; obj.push(-1); obj["0"] === -1. Actual: ' + (obj["0"])); +} + +obj.length = Number.POSITIVE_INFINITY; +assert.throws(TypeError, function() { + obj.push(-4); +}); + +if (obj.length !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#6: var obj = {}; obj.length = Number.POSITIVE_INFINITY; obj.push = Array.prototype.push; obj.push(-4); obj.length === Number.POSITIVE_INFINITY. Actual: ' + (obj.length)); +} + +if (obj[9007199254740991] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.length = Number.POSITIVE_INFINITY; obj.push = Array.prototype.push; obj.push(-4); obj[9007199254740991] === undefined. Actual: ' + (obj["9007199254740991"])); +} + +obj.length = Number.NEGATIVE_INFINITY; +var push = obj.push(-7); +if (push !== 1) { + throw new Test262Error('#7: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.push = Array.prototype.push; obj.push(-7) === 1. Actual: ' + (push)); +} + +if (obj.length !== 1) { + throw new Test262Error('#8: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.push = Array.prototype.push; obj.push(-7); obj.length === 1. Actual: ' + (obj.length)); +} + +if (obj["0"] !== -7) { + throw new Test262Error('#9: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.push = Array.prototype.push; obj.push(-7); obj["0"] === -7. Actual: ' + (obj["0"])); +} + +obj.length = 0.5; +var push = obj.push(-10); +if (push !== 1) { + throw new Test262Error('#10: var obj = {}; obj.length = 0.5; obj.push = Array.prototype.push; obj.push(-10) === 1. Actual: ' + (push)); +} + +if (obj.length !== 1) { + throw new Test262Error('#11: var obj = {}; obj.length = 0.5; obj.push = Array.prototype.push; obj.push(-10); obj.length === 1. Actual: ' + (obj.length)); +} + +if (obj["0"] !== -10) { + throw new Test262Error('#12: var obj = {}; obj.length = 0.5; obj.push = Array.prototype.push; obj.push(-10); obj["0"] === -10. Actual: ' + (obj["0"])); +} + +obj.length = 1.5; +var push = obj.push(-13); +if (push !== 2) { + throw new Test262Error('#13: var obj = {}; obj.length = 1.5; obj.push = Array.prototype.push; obj.push(-13) === 2. Actual: ' + (push)); +} + +if (obj.length !== 2) { + throw new Test262Error('#14: var obj = {}; obj.length = 1.5; obj.push = Array.prototype.push; obj.push(-13); obj.length === 2. Actual: ' + (obj.length)); +} + +if (obj["1"] !== -13) { + throw new Test262Error('#15: var obj = {}; obj.length = 1.5; obj.push = Array.prototype.push; obj.push(-13); obj["1"] === -13. Actual: ' + (obj["1"])); +} + +obj.length = new Number(0); +var push = obj.push(-16); +if (push !== 1) { + throw new Test262Error('#16: var obj = {}; obj.length = new Number(0); obj.push = Array.prototype.push; obj.push(-16) === 1. Actual: ' + (push)); +} + +if (obj.length !== 1) { + throw new Test262Error('#17: var obj = {}; obj.length = new Number(0); obj.push = Array.prototype.push; obj.push(-16); obj.length === 1. Actual: ' + (obj.length)); +} + +if (obj["0"] !== -16) { + throw new Test262Error('#18: var obj = {}; obj.length = new Number(0); obj.push = Array.prototype.push; obj.push(-16); obj["0"] === -16. Actual: ' + (obj["0"])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_T3.js b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_T3.js new file mode 100644 index 0000000000..cec90447f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_T3.js @@ -0,0 +1,120 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The push function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.push +description: > + Operator use ToNumber from length. If Type(value) is Object, + evaluate ToPrimitive(value, Number) +---*/ + +var obj = {}; +obj.push = Array.prototype.push; + +obj.length = { + valueOf() { + return 3 + } +}; +var push = obj.push(); +assert.sameValue(push, 3, 'The value of push is expected to be 3'); + +obj.length = { + valueOf() { + return 3 + }, + toString() { + return 1 + } +}; +var push = obj.push(); +assert.sameValue(push, 3, 'The value of push is expected to be 3'); + +obj.length = { + valueOf() { + return 3 + }, + toString() { + return {} + } +}; +var push = obj.push(); +assert.sameValue(push, 3, 'The value of push is expected to be 3'); + +try { + obj.length = { + valueOf() { + return 3 + }, + toString() { + throw "error" + } + }; + var push = obj.push(); + assert.sameValue(push, 3, 'The value of push is expected to be 3'); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} + +obj.length = { + toString() { + return 1 + } +}; +var push = obj.push(); +assert.sameValue(push, 1, 'The value of push is expected to be 1'); + +obj.length = { + valueOf() { + return {} + }, + toString() { + return 1 + } +} +var push = obj.push(); +assert.sameValue(push, 1, 'The value of push is expected to be 1'); + +try { + + obj.length = { + valueOf() { + throw "error" + }, + toString() { + return 1 + } + }; + var push = obj.push(); + throw new Test262Error('#7.1: obj.length = {valueOf() {throw "error"}, toString() {return 1}}; obj.push() throw "error". Actual: ' + (push)); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} + +try { + + obj.length = { + valueOf() { + return {} + }, + toString() { + return {} + } + }; + var push = obj.push(); + throw new Test262Error('#8.1: obj.length = {valueOf() {return {}}, toString() {return {}}} obj.push() throw TypeError. Actual: ' + (push)); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A3.js b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A3.js new file mode 100644 index 0000000000..cd918e0180 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A3.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for Array object +esid: sec-array.prototype.push +description: If ToUint32(length) !== length, throw RangeError +---*/ + +var x = []; +x.length = 4294967295; + +var push = x.push(); +assert.sameValue(push, 4294967295, 'The value of push is expected to be 4294967295'); + +try { + x.push("x"); + throw new Test262Error('#2.1: x = []; x.length = 4294967295; x.push("x") throw RangeError. Actual: ' + (push)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} + +assert.sameValue(x[4294967295], "x", 'The value of x[4294967295] is expected to be "x"'); +assert.sameValue(x.length, 4294967295, 'The value of x.length is expected to be 4294967295'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A4_T1.js b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A4_T1.js new file mode 100644 index 0000000000..4561b952fb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A4_T1.js @@ -0,0 +1,60 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.push +description: length = 4294967296 +---*/ + +var obj = {}; +obj.push = Array.prototype.push; +obj.length = 4294967296; + +var push = obj.push("x", "y", "z"); +if (push !== 4294967299) { + throw new Test262Error('#1: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z") === 4294967299. Actual: ' + (push)); +} + +if (obj.length !== 4294967299) { + throw new Test262Error('#2: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj.length === 4294967299. Actual: ' + (obj.length)); +} + +if (obj[0] !== undefined) { + throw new Test262Error('#3: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[0] === undefined. Actual: ' + (obj[0])); +} + +if (obj[1] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[1] === undefined. Actual: ' + (obj[1])); +} + +if (obj[2] !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[2] === undefined. Actual: ' + (obj[2])); +} + +if (obj[4294967296] !== "x") { + throw new Test262Error('#6: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[4294967296] === "x". Actual: ' + (obj[4294967296])); +} + +if (obj[4294967297] !== "y") { + throw new Test262Error('#7: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[4294967297] === "y". Actual: ' + (obj[4294967297])); +} + +if (obj[4294967298] !== "z") { + throw new Test262Error('#8: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[4294967298] === "z". Actual: ' + (obj[4294967298])); +} + +var obj = {}; +obj.push = Array.prototype.push; +obj.length = 4294967296; + +var push = obj.push(); +if (push !== 4294967296) { + throw new Test262Error('#9: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push() === 4294967296. Actual: ' + (push)); +} + +if (obj.length !== 4294967296) { + throw new Test262Error('#10: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push(); obj.length === 4294967296. Actual: ' + (obj.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A4_T2.js b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A4_T2.js new file mode 100644 index 0000000000..4beecec82a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A4_T2.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.push +description: length = 4294967295 +---*/ + +var obj = {}; +obj.push = Array.prototype.push; +obj.length = 4294967295; + +var push = obj.push("x", "y", "z"); +if (push !== 4294967298) { + throw new Test262Error('#1: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z") === 4294967298. Actual: ' + (push)); +} + +if (obj.length !== 4294967298) { + throw new Test262Error('#2: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z"); obj.length === 4294967298. Actual: ' + (obj.length)); +} + +if (obj[4294967295] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z"); obj[4294967295] === "x". Actual: ' + (obj[4294967295])); +} + +if (obj[4294967296] !== "y") { + throw new Test262Error('#4: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z"); obj[4294967296] === "y". Actual: ' + (obj[4294967296])); +} + +if (obj[4294967297] !== "z") { + throw new Test262Error('#5: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z"); obj[4294967297] === "z". Actual: ' + (obj[4294967297])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A4_T3.js b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A4_T3.js new file mode 100644 index 0000000000..54fd4df676 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A4_T3.js @@ -0,0 +1,47 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.push +description: length = -1 +---*/ + +var obj = {}; +obj.push = Array.prototype.push; +obj.length = -1; + +var push = obj.push("x", "y", "z"); +if (push !== 3) { + throw new Test262Error('#1: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z") === 3. Actual: ' + (push)); +} + +if (obj.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj.length === 3. Actual: ' + (obj.length)); +} + +if (obj[4294967295] !== undefined) { + throw new Test262Error('#3: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[4294967295] === undefined. Actual: ' + (obj[4294967295])); +} + +if (obj[4294967296] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[4294967296] === undefined. Actual: ' + (obj[4294967296])); +} + +if (obj[4294967297] !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[4294967297] === undefined. Actual: ' + (obj[4294967297])); +} + +if (obj[0] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[0] === "x". Actual: ' + (obj[0])); +} + +if (obj[1] !== "y") { + throw new Test262Error('#4: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[1] === "y". Actual: ' + (obj[1])); +} + +if (obj[2] !== "z") { + throw new Test262Error('#5: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[2] === "z". Actual: ' + (obj[2])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A5_T1.js b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A5_T1.js new file mode 100644 index 0000000000..d124babebf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A5_T1.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]] from not an inherited property" +esid: sec-array.prototype.push +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Object.prototype[1] = -1; +Object.prototype.length = 1; +Object.prototype.push = Array.prototype.push; +var x = { + 0: 0 +}; + +var push = x.push(1); +if (push !== 2) { + throw new Test262Error('#1: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; x.push(1) === 2. Actual: ' + (push)); +} + +if (x.length !== 2) { + throw new Test262Error('#2: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; x.push(1); x.length === 2. Actual: ' + (x.length)); +} + +if (x[1] !== 1) { + throw new Test262Error('#3: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; x.push(1); x[1] === 1. Actual: ' + (x[1])); +} + +delete x[1]; +if (x[1] !== -1) { + throw new Test262Error('#4: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; x.push(1); delete x[1]; x[1] === -1. Actual: ' + (x[1])); +} + +delete x.length; +if (x.length !== 1) { + throw new Test262Error('#5: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; delete x; x.push(1); x.length === 1. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/browser.js b/js/src/tests/test262/built-ins/Array/prototype/push/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/push/call-with-boolean.js new file mode 100644 index 0000000000..d6831e0a89 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/call-with-boolean.js @@ -0,0 +1,12 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.push +description: Array.prototype.push applied to boolean primitive +---*/ + +assert.sameValue(Array.prototype.push.call(true), 0, 'Array.prototype.push.call(true) must return 0'); +assert.sameValue(Array.prototype.push.call(false), 0, 'Array.prototype.push.call(false) must return 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/clamps-to-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/push/clamps-to-integer-limit.js new file mode 100644 index 0000000000..6466a0a5e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/clamps-to-integer-limit.js @@ -0,0 +1,38 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.push +description: > + Length values exceeding 2^53-1 are clamped to 2^53-1. +info: | + 1. ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let items be a List whose elements are, in left to right order, the arguments + that were passed to this function invocation. + 4. Let argCount be the number of elements in items. + ... + 7. Perform ? Set(O, "length", len, true). + ... +features: [exponentiation] +---*/ + +var arrayLike = {}; + +arrayLike.length = 2 ** 53 - 1; +Array.prototype.push.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53 - 1"); + +arrayLike.length = 2 ** 53; +Array.prototype.push.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53"); + +arrayLike.length = 2 ** 53 + 2; +Array.prototype.push.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53 + 2"); + +arrayLike.length = Infinity; +Array.prototype.push.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/length-near-integer-limit-set-failure.js b/js/src/tests/test262/built-ins/Array/prototype/push/length-near-integer-limit-set-failure.js new file mode 100644 index 0000000000..8ecd9486cb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/length-near-integer-limit-set-failure.js @@ -0,0 +1,49 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.push +description: > + A value is inserted in an array-like object whose length property is near the integer limit. + Unsuccessful [[Set]] raises a TypeError. +info: | + Array.prototype.push ( ...items ) + + [...] + 2. Let len be ? LengthOfArrayLike(O). + [...] + 4. Let argCount be the number of elements in items. + [...] + 6. Repeat, while items is not empty, + a. Remove the first element from items and let E be the value of the element. + b. Perform ? Set(O, ! ToString(len), E, true). + c. Set len to len + 1. + [...] + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 3. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. +---*/ + +var arrayLike = { + length: Number.MAX_SAFE_INTEGER - 3, +}; + +Object.defineProperty(arrayLike, Number.MAX_SAFE_INTEGER - 1, { + value: 33, + writable: false, + enumerable: true, + configurable: true, +}); + +assert.throws(TypeError, function() { + Array.prototype.push.call(arrayLike, 1, 2, 3); +}); + +assert.sameValue(arrayLike[Number.MAX_SAFE_INTEGER - 3], 1); +assert.sameValue(arrayLike[Number.MAX_SAFE_INTEGER - 2], 2); +assert.sameValue(arrayLike[Number.MAX_SAFE_INTEGER - 1], 33); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/length-near-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/push/length-near-integer-limit.js new file mode 100644 index 0000000000..a947b29bad --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/length-near-integer-limit.js @@ -0,0 +1,42 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.push +description: > + A value is inserted in an array-like object whose length property is near the integer limit. +info: | + ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let items be a List whose elements are, in left to right order, the + arguments that were passed to this function invocation. + ... + 5. Repeat, while items is not empty + ... + 7. Perform ? Set(O, "length", len, true). + ... +features: [exponentiation] +---*/ + +var arrayLike = { + "9007199254740989": "9007199254740989", + /* "9007199254740990": empty */ + "9007199254740991": "9007199254740991", + length: 2 ** 53 - 2 +}; + +Array.prototype.push.call(arrayLike, "new-value"); + +assert.sameValue(arrayLike.length, 2 ** 53 - 1, + "New arrayLike.length is 2**53 - 1"); + +assert.sameValue(arrayLike["9007199254740989"], "9007199254740989", + "arrayLike['9007199254740989'] is unchanged"); + +assert.sameValue(arrayLike["9007199254740990"], "new-value", + "arrayLike['9007199254740990'] has new value"); + +assert.sameValue(arrayLike["9007199254740991"], "9007199254740991", + "arrayLike['9007199254740991'] is unchanged"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/length.js b/js/src/tests/test262/built-ins/Array/prototype/push/length.js new file mode 100644 index 0000000000..d503ab3cfa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.push +description: > + The "length" property of Array.prototype.push +info: | + 22.1.3.18 Array.prototype.push ( ...items ) + + The length property of the push method is 1. + + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.push.length, 1); + +verifyNotEnumerable(Array.prototype.push, 'length'); +verifyNotWritable(Array.prototype.push, 'length'); +verifyConfigurable(Array.prototype.push, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/name.js b/js/src/tests/test262/built-ins/Array/prototype/push/name.js new file mode 100644 index 0000000000..42e2e96314 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.push +description: > + Array.prototype.push.name is "push". +info: | + Array.prototype.push ( ...items ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.push.name, "push"); + +verifyNotEnumerable(Array.prototype.push, "name"); +verifyNotWritable(Array.prototype.push, "name"); +verifyConfigurable(Array.prototype.push, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/push/not-a-constructor.js new file mode 100644 index 0000000000..291b72867d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/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: > + Array.prototype.push 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, arrow-function] +---*/ + +assert.sameValue(isConstructor(Array.prototype.push), false, 'isConstructor(Array.prototype.push) must return false'); + +assert.throws(TypeError, () => { + new Array.prototype.push(); +}, '`new Array.prototype.push()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/push/prop-desc.js new file mode 100644 index 0000000000..4f739aa30a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.push +description: > + "push" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.push, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "push"); +verifyWritable(Array.prototype, "push"); +verifyConfigurable(Array.prototype, "push"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/set-length-array-is-frozen.js b/js/src/tests/test262/built-ins/Array/prototype/push/set-length-array-is-frozen.js new file mode 100644 index 0000000000..09aa72f52f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/set-length-array-is-frozen.js @@ -0,0 +1,47 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.push +description: > + A TypeError is thrown when "length" is [[Set]] on a frozen array. +info: | + Array.prototype.push ( ...items ) + + [...] + 5. For each element E of items, do + a. Perform ? Set(O, ! ToString(𝔽(len)), E, true). + b. Set len to len + 1. + 6. Perform ? Set(O, "length", 𝔽(len), true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = []; +var arrayPrototypeSet0Calls = 0; + +Object.defineProperty(Array.prototype, "0", { + set(_val) { + Object.freeze(array); + arrayPrototypeSet0Calls++; + }, +}); + +assert.throws(TypeError, function() { + array.push(1); +}); + +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); +assert.sameValue(arrayPrototypeSet0Calls, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/set-length-array-length-is-non-writable.js b/js/src/tests/test262/built-ins/Array/prototype/push/set-length-array-length-is-non-writable.js new file mode 100644 index 0000000000..4e8ba1d821 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/set-length-array-length-is-non-writable.js @@ -0,0 +1,47 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.push +description: > + A TypeError is thrown when "length" is [[Set]] on an array with non-writable "length". +info: | + Array.prototype.push ( ...items ) + + [...] + 5. For each element E of items, do + a. Perform ? Set(O, ! ToString(𝔽(len)), E, true). + b. Set len to len + 1. + 6. Perform ? Set(O, "length", 𝔽(len), true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = []; +var arrayPrototypeSet0Calls = 0; + +Object.defineProperty(Array.prototype, "0", { + set(_val) { + Object.defineProperty(array, "length", { writable: false }); + arrayPrototypeSet0Calls++; + }, +}); + +assert.throws(TypeError, function() { + array.push(1); +}); + +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); +assert.sameValue(arrayPrototypeSet0Calls, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/set-length-zero-array-is-frozen.js b/js/src/tests/test262/built-ins/Array/prototype/push/set-length-zero-array-is-frozen.js new file mode 100644 index 0000000000..a2bb89fa1f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/set-length-zero-array-is-frozen.js @@ -0,0 +1,38 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.push +description: > + A TypeError is thrown when "length" is [[Set]] on an empty frozen array. +info: | + Array.prototype.push ( ...items ) + + [...] + 2. Let len be ? LengthOfArrayLike(O). + [...] + 6. Perform ? Set(O, "length", 𝔽(len), true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = []; +Object.freeze(array); + +assert.throws(TypeError, function() { + array.push(); +}); + +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/set-length-zero-array-length-is-non-writable.js b/js/src/tests/test262/built-ins/Array/prototype/push/set-length-zero-array-length-is-non-writable.js new file mode 100644 index 0000000000..43527e8569 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/set-length-zero-array-length-is-non-writable.js @@ -0,0 +1,38 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.push +description: > + A TypeError is thrown when "length" is [[Set]] on an empty array with non-writable "length". +info: | + Array.prototype.push ( ...items ) + + [...] + 2. Let len be ? LengthOfArrayLike(O). + [...] + 6. Perform ? Set(O, "length", 𝔽(len), true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = []; +Object.defineProperty(array, "length", { writable: false }); + +assert.throws(TypeError, function() { + array.push(); +}); + +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/shell.js b/js/src/tests/test262/built-ins/Array/prototype/push/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/throws-if-integer-limit-exceeded.js b/js/src/tests/test262/built-ins/Array/prototype/push/throws-if-integer-limit-exceeded.js new file mode 100644 index 0000000000..f2dbabc549 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/throws-if-integer-limit-exceeded.js @@ -0,0 +1,41 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.push +description: > + A TypeError is thrown if the new length exceeds 2^53-1. +info: | + 1. ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let items be a List whose elements are, in left to right order, the arguments + that were passed to this function invocation. + 4. Let argCount be the number of elements in items. + 5. If len + argCount > 2^53-1, throw a TypeError exception. + ... +features: [exponentiation] +---*/ + +var arrayLike = {}; + +arrayLike.length = 2 ** 53 - 1; +assert.throws(TypeError, function() { + Array.prototype.push.call(arrayLike, null); +}, "Length is 2**53 - 1"); + +arrayLike.length = 2 ** 53; +assert.throws(TypeError, function() { + Array.prototype.push.call(arrayLike, null); +}, "Length is 2**53"); + +arrayLike.length = 2 ** 53 + 2; +assert.throws(TypeError, function() { + Array.prototype.push.call(arrayLike, null); +}, "Length is 2**53 + 2"); + +arrayLike.length = Infinity; +assert.throws(TypeError, function() { + Array.prototype.push.call(arrayLike, null); +}, "Length is Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/throws-with-string-receiver.js b/js/src/tests/test262/built-ins/Array/prototype/push/throws-with-string-receiver.js new file mode 100644 index 0000000000..23805127a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/throws-with-string-receiver.js @@ -0,0 +1,38 @@ +// Copyright (C) 2020 Sony Interactive Entertainment Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.push +description: > + Array#push throws TypeError upon attempting to modify a string +info: | + Array.prototype.push ( ...items ) + ... + 6. Repeat, while items is not empty + ... + b. Perform ? Set(O, ! ToString(len), E, true). + ... + 7. Perform ? Set(O, "length", len, true). + + Set ( O, P, V, Throw ) + ... + 4. Let success be ? O.[[Set]](P, V, O). + 5. If success is false and Throw is true, throw a TypeError exception. +---*/ + +assert.throws(TypeError, () => { + Array.prototype.push.call(''); +}, "Array.prototype.push.call('')"); + +assert.throws(TypeError, () => { + Array.prototype.push.call('', 1); +}, "Array.prototype.push.call('', 1)"); + +assert.throws(TypeError, () => { + Array.prototype.push.call('abc'); +}, "Array.prototype.push.call('abc')"); + +assert.throws(TypeError, () => { + Array.prototype.push.call('abc', 1); +}, "Array.prototype.push.call('abc', 1)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-1.js new file mode 100644 index 0000000000..f602de688b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to undefined +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.reduce.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-10.js new file mode 100644 index 0000000000..356831c93f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-10.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to the Math object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return ('[object Math]' === Object.prototype.toString.call(obj)); +} + +Math.length = 1; +Math[0] = 1; + +assert(Array.prototype.reduce.call(Math, callbackfn, 1), 'Array.prototype.reduce.call(Math, callbackfn, 1) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-11.js new file mode 100644 index 0000000000..e7c228f2fa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-11.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to Date object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof Date; +} + +var obj = new Date(); +obj.length = 1; +obj[0] = 1; + +assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-12.js new file mode 100644 index 0000000000..7b9841d843 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-12.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to RegExp object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof RegExp; +} + +var obj = new RegExp(); +obj.length = 1; +obj[0] = 1; + +assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-13.js new file mode 100644 index 0000000000..e336ea2370 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-13.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to the JSON object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return ('[object JSON]' === Object.prototype.toString.call(obj)); +} + +JSON.length = 1; +JSON[0] = 1; + +assert(Array.prototype.reduce.call(JSON, callbackfn, 1), 'Array.prototype.reduce.call(JSON, callbackfn, 1) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-14.js new file mode 100644 index 0000000000..0265a4209e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-14.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to Error object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof Error; +} + +var obj = new Error(); +obj.length = 1; +obj[0] = 1; + +assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-15.js new file mode 100644 index 0000000000..38f7254600 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-15.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to the Arguments object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return ('[object Arguments]' === Object.prototype.toString.call(obj)); +} + +var obj = (function() { + return arguments; +}("a", "b")); + +assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-2.js new file mode 100644 index 0000000000..71a935eda1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to null +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.reduce.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-3.js new file mode 100644 index 0000000000..7288e5a23d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to boolean primitive +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof Boolean; +} + +Boolean.prototype[0] = true; +Boolean.prototype.length = 1; + +assert(Array.prototype.reduce.call(false, callbackfn, 1), 'Array.prototype.reduce.call(false, callbackfn, 1) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-4.js new file mode 100644 index 0000000000..a8026dec51 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-4.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to Boolean object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof Boolean; +} + +var obj = new Boolean(true); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; + +assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-5.js new file mode 100644 index 0000000000..48c2e67a3f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-5.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to number primitive +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof Number; +} + +Number.prototype[0] = 1; +Number.prototype.length = 1; + +assert(Array.prototype.reduce.call(2.5, callbackfn, 1), 'Array.prototype.reduce.call(2.5, callbackfn, 1) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-6.js new file mode 100644 index 0000000000..174051b42b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-6.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to Number object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof Number; +} + +var obj = new Number(-128); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; + +assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-7.js new file mode 100644 index 0000000000..a49a2f72d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-7.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to string primitive +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof String; +} + +assert(Array.prototype.reduce.call("abc", callbackfn, 1), 'Array.prototype.reduce.call("abc", callbackfn, 1) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-8.js new file mode 100644 index 0000000000..3bd7f04768 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-8.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to String object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof String; +} + +var obj = new String("abc"); + +assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-9.js new file mode 100644 index 0000000000..f4d55a0b8f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-9.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to Function object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof Function; +} + +var obj = function(a, b) { + return a + b; +}; +obj[0] = 11; +obj[1] = 9; + +assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-1.js new file mode 100644 index 0000000000..ab069463b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-1.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce doesn't mutate the Array on which it is + called on +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + return 1; +} +var srcArr = [1, 2, 3, 4, 5]; +srcArr.reduce(callbackfn); + +assert.sameValue(srcArr[0], 1, 'srcArr[0]'); +assert.sameValue(srcArr[1], 2, 'srcArr[1]'); +assert.sameValue(srcArr[2], 3, 'srcArr[2]'); +assert.sameValue(srcArr[3], 4, 'srcArr[3]'); +assert.sameValue(srcArr[4], 5, 'srcArr[4]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-2.js new file mode 100644 index 0000000000..7ed501c653 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-2.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce reduces the array in ascending order of + indices +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + return prevVal + curVal; +} +var srcArr = ['1', '2', '3', '4', '5']; + +assert.sameValue(srcArr.reduce(callbackfn), '12345', 'srcArr.reduce(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-3.js new file mode 100644 index 0000000000..7a91f97074 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - subclassed array of length 1 +---*/ + +foo.prototype = [1]; + +function foo() {} +var f = new foo(); + +function cb() {} + +assert.sameValue(f.reduce(cb), 1, 'f.reduce(cb)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-4.js new file mode 100644 index 0000000000..9670ccae3d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-4.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - subclassed array with length more than 1 +---*/ + +foo.prototype = new Array(1, 2, 3, 4); + +function foo() {} +var f = new foo(); + +function cb(prevVal, curVal, idx, obj) { + return prevVal + curVal; +} + +assert.sameValue(f.reduce(cb), 10, 'f.reduce(cb)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-5.js new file mode 100644 index 0000000000..c29ea02ed1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-5.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce reduces the array in ascending order of + indices(initialvalue present) +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + return prevVal + curVal; +} +var srcArr = ['1', '2', '3', '4', '5']; + +assert.sameValue(srcArr.reduce(callbackfn, '0'), '012345', 'srcArr.reduce(callbackfn,"0")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-6.js new file mode 100644 index 0000000000..d007e84a0a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-6.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - subclassed array when initialvalue + provided +---*/ + +foo.prototype = [1, 2, 3, 4]; + +function foo() {} +var f = new foo(); + +function cb(prevVal, curVal, idx, obj) { + return prevVal + curVal; +} + +assert.sameValue(f.reduce(cb, -1), 9, 'f.reduce(cb,-1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-7.js new file mode 100644 index 0000000000..3e3e1b039e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-7.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - subclassed array with length 1 and + initialvalue provided +---*/ + +foo.prototype = [1]; + +function foo() {} +var f = new foo(); + +function cb(prevVal, curVal, idx, obj) { + return prevVal + curVal; +} + +assert.sameValue(f.reduce(cb, -1), 0, 'f.reduce(cb,-1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-8.js new file mode 100644 index 0000000000..a13c8c6f39 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-8.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce doesn't visit expandos +---*/ + +var callCnt = 0; + +function callbackfn(prevVal, curVal, idx, obj) +{ + callCnt++; + return curVal; +} +var srcArr = ['1', '2', '3', '4', '5']; +srcArr["i"] = 10; +srcArr[true] = 11; +srcArr.reduce(callbackfn); + +assert.sameValue(callCnt, 4, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-1.js new file mode 100644 index 0000000000..b45ecf4a0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-1.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is own data property on an + Array-like object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-10.js new file mode 100644 index 0000000000..a73d8c2115 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-10.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object, 'length' is + an inherited accessor property +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-11.js new file mode 100644 index 0000000000..26a9bded1c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-11.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object, 'length' is + an own accessor property without a get function +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-12.js new file mode 100644 index 0000000000..7496112e3b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-12.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is own accessor property without + a get function that overrides an inherited accessor property on an + Array +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} + +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var obj = { + 0: 12, + 1: 11 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-13.js new file mode 100644 index 0000000000..fdcedaf33f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-13.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object that 'length' + is inherited accessor property without a get function +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} + +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 11; +child[1] = 12; + +assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), 1, 'Array.prototype.reduce.call(child, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-14.js new file mode 100644 index 0000000000..a399b536e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-14.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to the Array-like object that + 'length' property doesn't exist +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} + +var obj = { + 0: 11, + 1: 12 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-17.js new file mode 100644 index 0000000000..db35b46d4d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-17.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to the Arguments object, which + implements its own property get method +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} + +var func = function(a, b) { + arguments[2] = 9; + return Array.prototype.reduce.call(arguments, callbackfn, 1); +}; + +assert.sameValue(func(12, 11), true, 'func(12, 11)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-18.js new file mode 100644 index 0000000000..cf6c09d672 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-18.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to String object, which implements + its own property get method +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 3); +} + +var str = new String("012"); + +assert.sameValue(Array.prototype.reduce.call(str, callbackfn, 1), true, 'Array.prototype.reduce.call(str, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-19.js new file mode 100644 index 0000000000..dd0066d782 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-19.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Function object, which + implements its own property get method +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} + +var fun = function(a, b) { + return a + b; +}; +fun[0] = 12; +fun[1] = 11; +fun[2] = 9; + +assert.sameValue(Array.prototype.reduce.call(fun, callbackfn, 1), true, 'Array.prototype.reduce.call(fun, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-2.js new file mode 100644 index 0000000000..949641eda5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-2.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - 'length' is own data property on an Array +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} + +assert.sameValue([12, 11].reduce(callbackfn, 1), true, '[12, 11].reduce(callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-3.js new file mode 100644 index 0000000000..6d4aed1c5e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-3.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is an own data property that + overrides an inherited data property on an Array-like object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} + +var proto = { + length: 3 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-4.js new file mode 100644 index 0000000000..042b286c01 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-4.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is own data property that + overrides an inherited data property on an Array +---*/ + +var storeProtoLength; + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} + +storeProtoLength = Array.prototype.length; +Array.prototype.length = 0; + +assert.sameValue([12, 11].reduce(callbackfn, 1), true, '[12, 11].reduce(callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-5.js new file mode 100644 index 0000000000..f2143fdd03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-5.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object, 'length' is + an own data property that overrides an inherited accessor property +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-6.js new file mode 100644 index 0000000000..9419869526 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-6.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object, 'length' is + an inherited data property +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} + +var proto = { + length: 2 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-7.js new file mode 100644 index 0000000000..fc1f9989f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-7.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object, 'length' is + an own accessor property +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +obj[0] = 12; +obj[1] = 11; +obj[2] = 9; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-8.js new file mode 100644 index 0000000000..7f42726b4d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-8.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object, 'length' is + an own accessor property that overrides an inherited data property +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} + +var proto = { + length: 3 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-9.js new file mode 100644 index 0000000000..1d074a9b15 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-9.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object, 'length' is + an own accessor property that overrides an inherited accessor + property +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-1.js new file mode 100644 index 0000000000..2ec0cf620b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-1.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - value of 'length' is undefined +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return 2; +} + +var obj = { + 0: 0, + 1: 1, + length: undefined +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-10.js new file mode 100644 index 0000000000..a1804686f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-10.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is number primitive + (value is NaN) +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return 2; +} + +var obj = { + 0: 9, + length: NaN +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-11.js new file mode 100644 index 0000000000..3cbf90142b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-11.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is a string containing a + positive number +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} + +var obj = { + 1: 11, + 2: 9, + length: "2" +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-12.js new file mode 100644 index 0000000000..ffe6c68194 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-12.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is a string containing a + negative number +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} + +var obj = { + 1: 11, + 2: 9, + length: "-4294967294" +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-13.js new file mode 100644 index 0000000000..7e1c114565 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-13.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is a string containing a decimal + number +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} + +var obj = { + 1: 11, + 2: 9, + length: "2.5" +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-14.js new file mode 100644 index 0000000000..d1499f13bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-14.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - 'length' is a string containing -Infinity +---*/ + +var accessed2 = false; + +function callbackfn2(prevVal, curVal, idx, obj) { + accessed2 = true; + return 2; +} + +var obj2 = { + 0: 9, + length: "-Infinity" +}; + +assert.sameValue(Array.prototype.reduce.call(obj2, callbackfn2, 1), 1, 'Array.prototype.reduce.call(obj2, callbackfn2, 1)'); +assert.sameValue(accessed2, false, 'accessed2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-15.js new file mode 100644 index 0000000000..b4c5e25ea6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-15.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is a string containing an + exponential number +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} + +var obj = { + 1: 11, + 2: 9, + length: "2E0" +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-16.js new file mode 100644 index 0000000000..7928a8df66 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-16.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is a string containing a hex + number +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} + +var obj = { + 1: 11, + 2: 9, + length: "0x0002" +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-17.js new file mode 100644 index 0000000000..1911ddb867 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-17.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is a string containing a number + with leading zeros +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} + +var obj = { + 1: 11, + 2: 9, + length: "0002.00" +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-18.js new file mode 100644 index 0000000000..8b2401ca82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-18.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a string that can't + convert to a number +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return 2; +} + +var obj = { + 0: 9, + length: "asdf!_" +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-19.js new file mode 100644 index 0000000000..06f303dd40 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-19.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is an Object which has + an own toString method +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} + +var obj = { + 1: 11, + 2: 9, + length: { + toString: function() { + return '2'; + } + } +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-2.js new file mode 100644 index 0000000000..d06dfa1602 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-2.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a boolean (value is + true) +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 0); +} + +var obj = { + 0: 11, + 1: 9, + length: true +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-20.js new file mode 100644 index 0000000000..32acae269e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-20.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is an object which has + an own valueOf method +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} + +var obj = { + 1: 11, + 2: 9, + length: { + valueOf: function() { + return 2; + } + } +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-21.js new file mode 100644 index 0000000000..1b7b79d77d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-21.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is an object that has an own + valueOf method that returns an object and toString method that + returns a string +---*/ + +var valueOfOccured = false; +var toStringOccured = false; + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} + +var obj = { + 1: 11, + 2: 9, + length: { + valueOf: function() { + valueOfOccured = true; + return {}; + }, + toString: function() { + toStringOccured = true; + return '2'; + } + } +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); +assert(valueOfOccured, 'valueOfOccured !== true'); +assert(toStringOccured, 'toStringOccured !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-22.js new file mode 100644 index 0000000000..bc8c06a453 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-22.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError exception - 'length' is an + object with toString and valueOf methods that don�t return + primitive values +---*/ + +var accessed = false; +var valueOfAccessed = false; +var toStringAccessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return true; +} + +var obj = { + 1: 11, + 2: 12, + + length: { + valueOf: function() { + valueOfAccessed = true; + return {}; + }, + toString: function() { + toStringAccessed = true; + return {}; + } + } +}; +assert.throws(TypeError, function() { + Array.prototype.reduce.call(obj, callbackfn, 1); +}); +assert.sameValue(accessed, false, 'accessed'); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-23.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-23.js new file mode 100644 index 0000000000..3080520795 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-23.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce uses inherited valueOf method - 'length' is + an object with an own toString and inherited valueOf methods +---*/ + +var valueOfAccessed = false; +var toStringAccessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} + +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +child.toString = function() { + toStringAccessed = true; + return '1'; +}; + +var obj = { + 1: 11, + 2: 9, + length: child +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-24.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-24.js new file mode 100644 index 0000000000..7c26c88bfd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-24.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} + +var obj = { + 1: 11, + 2: 9, + length: 2.685 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-25.js new file mode 100644 index 0000000000..8f78496005 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-25.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a negative + non-integer +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} + +var obj = { + 1: 11, + 2: 9, + length: -4294967294.5 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-3.js new file mode 100644 index 0000000000..9e21add920 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-3.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - value of 'length' is a number (value is 0) +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return 2; +} + +var obj = { + 0: 1, + 1: 1, + length: 0 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-4.js new file mode 100644 index 0000000000..fa4858f288 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-4.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a number (value is + +0) +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return 2; +} + +var obj = { + 0: 11, + length: +0 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-5.js new file mode 100644 index 0000000000..27702d5054 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-5.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a number (value is + -0) +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return 2; +} + +var obj = { + 0: 11, + length: -0 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-6.js new file mode 100644 index 0000000000..e9de26b232 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-6.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a number (value is + positive) +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} + +var obj = { + 1: 11, + 2: 9, + length: 2 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-7.js new file mode 100644 index 0000000000..1cd375b0e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-7.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a number (value is + negative) +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} + +var obj = { + 1: 11, + 2: 9, + length: -4294967294 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-9.js new file mode 100644 index 0000000000..adc4a1728c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-9.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a number (value is + -Infinity) +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} + +var obj = { + 0: 9, + length: -Infinity +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-1.js new file mode 100644 index 0000000000..138fd34848 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce throws TypeError if callbackfn is undefined +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.reduce(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-10.js new file mode 100644 index 0000000000..14b99fc322 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-10.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the exception is not thrown if exception + was thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.reduce.call(obj, undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-11.js new file mode 100644 index 0000000000..d073715f5a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-11.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the exception is not thrown if exception + was thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.reduce.call(obj, undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-12.js new file mode 100644 index 0000000000..9389b2b64c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-12.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - 'callbackfn' is a function +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return curVal > 10; +} + +assert.sameValue([11, 9].reduce(callbackfn, 1), false, '[11, 9].reduce(callbackfn, 1)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-15.js new file mode 100644 index 0000000000..4b4237e65d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-15.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - calling with no callbackfn is the same as + passing undefined for callbackfn +---*/ + +var obj = { + 10: 10 +}; +var lengthAccessed = false; +var loopAccessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + lengthAccessed = true; + return 20; + }, + configurable: true +}); + +Object.defineProperty(obj, "0", { + get: function() { + loopAccessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.reduce.call(obj); +}); +assert(lengthAccessed, 'lengthAccessed !== true'); +assert.sameValue(loopAccessed, false, 'loopAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-2.js new file mode 100644 index 0000000000..9bea9ce912 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-2.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws ReferenceError if callbackfn is + unreferenced +---*/ + +var arr = new Array(10); +assert.throws(ReferenceError, function() { + arr.reduce(foo); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-3.js new file mode 100644 index 0000000000..b9232b42ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-3.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce throws TypeError if callbackfn is null +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.reduce(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-4.js new file mode 100644 index 0000000000..e0a4572124 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-4.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce throws TypeError if callbackfn is boolean +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.reduce(true); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-5.js new file mode 100644 index 0000000000..7fb3d394d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-5.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce throws TypeError if callbackfn is number +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.reduce(5); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-6.js new file mode 100644 index 0000000000..7a47ca27b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-6.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce throws TypeError if callbackfn is string +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.reduce("abc"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-7.js new file mode 100644 index 0000000000..57a4a96a02 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-7.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if callbackfn is Object + without [[Call]] internal method +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.reduce(new Object()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-8.js new file mode 100644 index 0000000000..54061e6426 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-8.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.reduce.call(obj, null); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-9.js new file mode 100644 index 0000000000..f5b1c92d75 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-9.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.reduce.call(obj, null); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-1.js new file mode 100644 index 0000000000..c665eff2ab --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-1.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 (empty + array), no initVal +---*/ + +function cb() {} +assert.throws(TypeError, function() { + [].reduce(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-10.js new file mode 100644 index 0000000000..d59f525060 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-10.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - if exception occurs, it occurs after any + side-effects that might be produced by step 2 +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal > 10); +} + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 0; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.reduce.call(obj, callbackfn); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-11.js new file mode 100644 index 0000000000..672956e033 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-11.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - if the exception occurs, it occurs after + any side-effects that might be produced by step 3 +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal > 10); +} + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "0"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.reduce.call(obj, callbackfn); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-12.js new file mode 100644 index 0000000000..db3cb0f5d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-12.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the exception is not thrown if exception + was thrown by step 2 +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal > 10); +} + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.reduce.call(obj, callbackfn); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-13.js new file mode 100644 index 0000000000..20f6727d71 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-13.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the exception is not thrown if exception + was thrown by step 3 +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal > 10); +} + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.reduce.call(obj, callbackfn); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-2.js new file mode 100644 index 0000000000..4f9fe2d884 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-2.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 + (subclassed Array, length overridden to null (type conversion)), + no initVal +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = null; + +function cb() {} +assert.throws(TypeError, function() { + f.reduce(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-3.js new file mode 100644 index 0000000000..54fbaf0e0c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-3.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 + (subclassed Array, length overridden to false (type conversion)), + no initVal +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = false; + +function cb() {} +assert.throws(TypeError, function() { + f.reduce(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-4.js new file mode 100644 index 0000000000..c1873c8b9f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-4.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 + (subclassed Array, length overridden to 0 (type conversion)), no + initVal +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 0; + +function cb() {} +assert.throws(TypeError, function() { + f.reduce(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-5.js new file mode 100644 index 0000000000..6ae8488fb8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-5.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 + (subclassed Array, length overridden to '0' (type conversion)), no + initVal +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = '0'; + +function cb() {} +assert.throws(TypeError, function() { + f.reduce(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-6.js new file mode 100644 index 0000000000..9dd7b8e094 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-6.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 + (subclassed Array, length overridden with obj with valueOf), no + initVal +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; + +function cb() {} +assert.throws(TypeError, function() { + f.reduce(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-7.js new file mode 100644 index 0000000000..b6777f6da2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-7.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 + (subclassed Array, length overridden with obj w/o valueOf + (toString)), no initVal +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. + +function cb() {} +assert.throws(TypeError, function() { + f.reduce(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-8.js new file mode 100644 index 0000000000..c49b1f8484 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-8.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 + (subclassed Array, length overridden with []), no initVal +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +f.length = []; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. + +function cb() {} +assert.throws(TypeError, function() { + f.reduce(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-9.js new file mode 100644 index 0000000000..4b21500a96 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-9.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'initialValue' is returned if 'len' is 0 + and 'initialValue' is present +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} + +assert.sameValue([].reduce(callbackfn, 3), 3, '[].reduce(callbackfn, 3)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-1.js new file mode 100644 index 0000000000..841d275bd8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (empty array) +---*/ + +function cb() {} +assert.sameValue([].reduce(cb, 1), 1, '[].reduce(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-10.js new file mode 100644 index 0000000000..f21f2f1247 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-10.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - 'initialValue' is present +---*/ + +var str = "initialValue is present"; + +assert.sameValue([].reduce(function() {}, str), str, '[].reduce(function () { }, str)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-11.js new file mode 100644 index 0000000000..4e2a9f7495 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-11.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - 'initialValue' is not present +---*/ + +var str = "initialValue is not present"; + +assert.sameValue([str].reduce(function() {}), str, '[str].reduce(function () { })'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-2.js new file mode 100644 index 0000000000..6ecd4b1d9b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-2.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden to + null (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = null; + +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-3.js new file mode 100644 index 0000000000..66e92ed670 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-3.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden to + false (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = false; + +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-4.js new file mode 100644 index 0000000000..7100e153bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-4.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden to 0 + (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 0; + +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-5.js new file mode 100644 index 0000000000..56027062b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-5.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden to + '0' (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = '0'; + +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-6.js new file mode 100644 index 0000000000..b70cb41afb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-6.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden with + obj with valueOf) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; + +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-7.js new file mode 100644 index 0000000000..4b97710d3b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-7.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden with + obj w/o valueOf (toString)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. + +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-8.js new file mode 100644 index 0000000000..f9ca7bb91e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-8.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden with + []) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +f.length = []; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. + +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-9.js new file mode 100644 index 0000000000..4df53a76ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-9.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden with + [0]) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +f.length = [0]; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. + +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-1.js new file mode 100644 index 0000000000..7c1604fef4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - no observable effects occur if 'len' is 0 +---*/ + +var accessed = false; + +var obj = { + length: 0 +}; + +Object.defineProperty(obj, "0", { + get: function() { + accessed = true; + return 10; + }, + configurable: true +}); + +assert.throws(TypeError, function() { + Array.prototype.reduce.call(obj, function() {}); +}); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-2.js new file mode 100644 index 0000000000..f53cc471bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-2.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - modifications to length don't change + number of iterations in step 9 +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return idx; +} + +var obj = { + 3: 12, + 4: 9, + length: 4 +}; + +Object.defineProperty(obj, "2", { + get: function() { + obj.length = 10; + return 11; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn), 3, 'Array.prototype.reduce.call(obj, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-3.js new file mode 100644 index 0000000000..c55ae70d3a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-3.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - loop is broken once 'kPresent' is true +---*/ + +var called = 0; +var testResult = false; +var firstCalled = 0; +var secondCalled = 0; + +function callbackfn(prevVal, val, idx, obj) { + if (called === 0) { + testResult = (idx === 1); + } + called++; +} + +var arr = [, , ]; + +Object.defineProperty(arr, "0", { + get: function() { + firstCalled++; + return 11; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + secondCalled++; + return 9; + }, + configurable: true +}); + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); +assert.sameValue(firstCalled, 1, 'firstCalled'); +assert.sameValue(secondCalled, 1, 'secondCalled'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-1.js new file mode 100644 index 0000000000..6bc328baf5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-1.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - added properties in step 2 are visible + here +---*/ + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + obj[1] = "accumulator"; + return 3; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.reduce.call(obj, function() {}), "accumulator", 'Array.prototype.reduce.call(obj, function () { })'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-2.js new file mode 100644 index 0000000000..735d8bf329 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-2.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleted properties in step 2 are visible + here +---*/ + +var obj = { + 1: "accumulator", + 2: "another" +}; + +Object.defineProperty(obj, "length", { + get: function() { + delete obj[1]; + return 3; + }, + configurable: true +}); + +assert.notSameValue(Array.prototype.reduce.call(obj, function() {}), "accumulator", 'Array.prototype.reduce.call(obj, function () { })'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-1.js new file mode 100644 index 0000000000..cc6bba40cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} + +var obj = { + 0: 0, + 1: 1, + 2: 2, + length: 2 +}; +Array.prototype.reduce.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-10.js new file mode 100644 index 0000000000..fab5c23ddf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-10.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - when element to be retrieved is own + accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} + +var arr = [, 1, 2]; + +Object.defineProperty(arr, "0", { + get: function() { + return 0; + }, + configurable: true +}); + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-11.js new file mode 100644 index 0000000000..f56f6cb024 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-11.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "9"); + } +} + +var proto = { + 0: 0, + 1: 1, + 2: 2 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Object.defineProperty(child, "0", { + get: function() { + return "9"; + }, + configurable: true +}); + +Array.prototype.reduce.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-12.js new file mode 100644 index 0000000000..4e58b106d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-12.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "9"); + } +} + +Array.prototype[0] = 0; +var arr = [, 1, 2]; + +Object.defineProperty(arr, "0", { + get: function() { + return "9"; + }, + configurable: true +}); + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-13.js new file mode 100644 index 0000000000..928bdb2c49 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-13.js @@ -0,0 +1,49 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "9"); + } +} + +var proto = { + 1: 1, + 2: 2 +}; + +Object.defineProperty(proto, "0", { + get: function() { + return 0; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Object.defineProperty(child, "0", { + get: function() { + return "9"; + }, + configurable: true +}); + +Array.prototype.reduce.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-14.js new file mode 100644 index 0000000000..11c3c24f5c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-14.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "9"); + } +} + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 0; + }, + configurable: true +}); + +var arr = [, 1, 2]; +Object.defineProperty(arr, "0", { + get: function() { + return "9"; + }, + configurable: true +}); + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-15.js new file mode 100644 index 0000000000..3a4d3abc0c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-15.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} + +var proto = { + 1: 1, + 2: 2 +}; + +Object.defineProperty(proto, "0", { + get: function() { + return 0; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Array.prototype.reduce.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-16.js new file mode 100644 index 0000000000..8d5a927e5c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-16.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 0; + }, + configurable: true +}); + +var arr = [, 1, 2]; + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-17.js new file mode 100644 index 0000000000..7317cde753 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-17.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === undefined); + } +} + +var obj = { + 1: 1, + 2: 2, + length: 3 +}; + +Object.defineProperty(obj, "0", { + set: function() {}, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-18.js new file mode 100644 index 0000000000..ed6be4721b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-18.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === undefined); + } +} + +var arr = [, 1, 2]; + +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-19.js new file mode 100644 index 0000000000..d9182b778d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-19.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === undefined); + } +} + +Object.prototype[0] = 0; + +var obj = { + 1: 1, + 2: 2, + length: 3 +}; + +Object.defineProperty(obj, "0", { + set: function() {}, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-2.js new file mode 100644 index 0000000000..f2ccbd2b59 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-2.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} + +var arr = [0, 1, 2]; +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-20.js new file mode 100644 index 0000000000..03786c37da --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-20.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === undefined); + } +} + +Array.prototype[0] = 0; +var arr = [, 1, 2]; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-21.js new file mode 100644 index 0000000000..a28aa9ded6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-21.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === undefined); + } +} + +var proto = { + 1: 1, + 2: 2 +}; + +Object.defineProperty(proto, "0", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Array.prototype.reduce.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-22.js new file mode 100644 index 0000000000..9ab02ad487 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-22.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === undefined); + } +} + +Object.defineProperty(Array.prototype, "0", { + set: function() {}, + configurable: true +}); + +var arr = [, 1, 2]; + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-25.js new file mode 100644 index 0000000000..fc0c264a5c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-25.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - This object is the Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} + +var func = function(a, b, c) { + Array.prototype.reduce.call(arguments, callbackfn); +}; + +func(0, 1); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-26.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-26.js new file mode 100644 index 0000000000..13645e0c23 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-26.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - This object is the Arguments object which + implements its own property get method (number of arguments equals + number of parameters) +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2) { + testResult = (prevVal === 1); + } +} + +var func = function(a, b, c) { + delete arguments[0]; + Array.prototype.reduce.call(arguments, callbackfn); +}; + +func(0, 1, 2); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-27.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-27.js new file mode 100644 index 0000000000..2a674e5e2a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-27.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - This object is the Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 3) { + testResult = (prevVal === 2); + } +} + +var func = function(a, b, c) { + delete arguments[0]; + delete arguments[1]; + Array.prototype.reduce.call(arguments, callbackfn); +}; + +func(0, 1, 2, 3); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-28.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-28.js new file mode 100644 index 0000000000..3cdea44286 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-28.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - applied to String object, which + implements its own property get method +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "0"); + } +} + +var str = new String("012"); +Array.prototype.reduce.call(str, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-29.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-29.js new file mode 100644 index 0000000000..6b4b9ccf9c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-29.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - applied to Function object which + implements its own property get method +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} + +var obj = function(a, b, c) { + return a + b + c; +}; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; + +Array.prototype.reduce.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-3.js new file mode 100644 index 0000000000..4250f525c7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-3.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "9"); + } +} + +var proto = { + 0: 0, + 1: 1, + 2: 2, + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = "9"; +child[1] = "1"; +child.length = 3; + +Array.prototype.reduce.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-30.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-30.js new file mode 100644 index 0000000000..901d503f04 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-30.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element changed by getter on current + iterations is observed in subsequent iterations on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var arr = [, , 2]; +var preIterVisible = false; + +Object.defineProperty(arr, "0", { + get: function() { + preIterVisible = true; + return 0; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return 100; + } + }, + configurable: true +}); + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-31.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-31.js new file mode 100644 index 0000000000..acf21c758a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-31.js @@ -0,0 +1,48 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element changed by getter on current + iterations is observed in subsequent iterations on an Array-like + object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var obj = { + length: 2 +}; +var preIterVisible = false; + +Object.defineProperty(obj, "0", { + get: function() { + preIterVisible = true; + return 0; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return 100; + } + }, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-32.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-32.js new file mode 100644 index 0000000000..683b42c417 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-32.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - exception in getter terminates iteration + on an Array-like object +---*/ + +var accessed = false; +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx >= 1) { + accessed = true; + testResult = (prevVal === 0); + } +} + +var obj = { + 2: 2, + 1: 1, + length: 3 +}; +Object.defineProperty(obj, "0", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + Array.prototype.reduce.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(testResult, false, 'testResult'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-33.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-33.js new file mode 100644 index 0000000000..bdb2286cd6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-33.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - exception in getter terminates iteration + on an Array +---*/ + +var accessed = false; +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx >= 1) { + accessed = true; + testResult = (prevVal === 0); + } +} + +var arr = [, 1, 2]; + +Object.defineProperty(arr, "0", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.reduce(callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(testResult, false, 'testResult'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-4.js new file mode 100644 index 0000000000..43dc373a3d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-4.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} + +Array.prototype[0] = "9"; +[0, 1, 2].reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-5.js new file mode 100644 index 0000000000..d14d46865c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-5.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "9"); + } +} + +var proto = {}; + +Object.defineProperty(proto, "0", { + get: function() { + return 0; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +Object.defineProperty(child, "0", { + value: "9", + configurable: true +}); +child[1] = "1"; + +Array.prototype.reduce.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-6.js new file mode 100644 index 0000000000..7ee7621226 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-6.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return "5"; + }, + configurable: true +}); + +[0, 1, 2].reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-7.js new file mode 100644 index 0000000000..2ec2ee0b38 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-7.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited data + property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} + +var proto = { + 0: 0, + 1: 1, + 2: 2, + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Array.prototype.reduce.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-8.js new file mode 100644 index 0000000000..af606108f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-8.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited data + property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} + +Array.prototype[0] = 0; +Array.prototype[1] = 1; +Array.prototype[2] = 2; +[, , , ].reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-9.js new file mode 100644 index 0000000000..1fd31f3566 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-9.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} + +var obj = { + 1: 1, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "0", { + get: function() { + return 0; + }, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-1.js new file mode 100644 index 0000000000..0fced6464d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-1.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError when Array is empty and + initialValue is not present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.reduce(callbackfn); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-2.js new file mode 100644 index 0000000000..f16665bf36 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-2.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError when elements assigned + values are deleted by reducing array length and initialValue is + not present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} + +var arr = new Array(10); +arr[9] = 1; +arr.length = 5; +assert.throws(TypeError, function() { + arr.reduce(callbackfn); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-3.js new file mode 100644 index 0000000000..e112cf748e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError when elements assigned + values are deleted and initialValue is not present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} + +var arr = [1, 2, 3, 4, 5]; +delete arr[0]; +delete arr[1]; +delete arr[2]; +delete arr[3]; +delete arr[4]; +assert.throws(TypeError, function() { + arr.reduce(callbackfn); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-4.js new file mode 100644 index 0000000000..432919dc10 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-4.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce doesn't throw error when array has no own + properties but prototype contains a single property +---*/ + +var arr = [, , , ]; + +try { + Array.prototype[1] = "prototype"; + arr.reduce(function() {}); +} finally { + delete Array.prototype[1]; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-5.js new file mode 100644 index 0000000000..a45a73094b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-5.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - if exception occurs, it occurs after any + side-effects that might be produced by step 2 +---*/ + +var obj = {}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.reduce.call(obj, function() {}); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-6.js new file mode 100644 index 0000000000..446552144b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-6.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - if exception occurs, it occurs after any + side-effects that might be produced by step 3 +---*/ + +var obj = {}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.reduce.call(obj, function() {}); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-7.js new file mode 100644 index 0000000000..4716787468 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-7.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the exception is not thrown if exception + was thrown by step 2 +---*/ + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.reduce.call(obj, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-8.js new file mode 100644 index 0000000000..15d23e11b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-8.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the exception is not thrown if exception + was thrown by step 3 +---*/ + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.reduce.call(obj, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-1.js new file mode 100644 index 0000000000..3e8387e96a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-1.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce doesn't consider new elements added to + array after it is called +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + arr[5] = 6; + arr[2] = 3; + return prevVal + curVal; +} + +var arr = [1, 2, , 4, '5']; + +assert.sameValue(arr.reduce(callbackfn), "105", 'arr.reduce(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-10.js new file mode 100644 index 0000000000..d9b5928953 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-10.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce called with an initial value doesn't + consider new elements added to array after it is called +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + arr[5] = 6; + arr[2] = 3; + return prevVal + curVal; +} + +var arr = [1, 2, , 4, '5']; + +assert.sameValue(arr.reduce(callbackfn, ""), "12345", 'arr.reduce(callbackfn, "")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-2.js new file mode 100644 index 0000000000..ae74f029a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-2.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce considers new value of elements in array + after it is called +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + arr[3] = -2; + arr[4] = -1; + return prevVal + curVal; +} + +var arr = [1, 2, 3, 4, 5]; + +assert.sameValue(arr.reduce(callbackfn), 3, 'arr.reduce(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-3.js new file mode 100644 index 0000000000..d83ac8f89d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-3.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce doesn't visit deleted elements in array + after the call +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + delete arr[3]; + delete arr[4]; + return prevVal + curVal; +} + +var arr = ['1', 2, 3, 4, 5]; + +// two elements deleted +assert.sameValue(arr.reduce(callbackfn), "123", 'arr.reduce(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-4.js new file mode 100644 index 0000000000..3a3e10d2df --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-4.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce doesn't visit deleted elements when + Array.length is decreased +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + arr.length = 2; + return prevVal + curVal; +} + +var arr = [1, 2, 3, 4, 5]; + +assert.sameValue(arr.reduce(callbackfn), 3, 'arr.reduce(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-5.js new file mode 100644 index 0000000000..20255d50cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-5.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn not called for array with one + element +---*/ + +var callCnt = 0; + +function callbackfn(prevVal, curVal, idx, obj) +{ + callCnt++; + return 2; +} + +var arr = [1]; + +assert.sameValue(arr.reduce(callbackfn), 1, 'arr.reduce(callbackfn)'); +assert.sameValue(callCnt, 0, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-6.js new file mode 100644 index 0000000000..635d08b6e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-6.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce visits deleted element in array after the + call when same index is also present in prototype +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + delete arr[3]; + delete arr[4]; + return prevVal + curVal; +} + +Array.prototype[4] = 5; +var arr = ['1', 2, 3, 4, 5]; +var res = arr.reduce(callbackfn); +delete Array.prototype[4]; + +//one element acually deleted +assert.sameValue(res, "1235", 'res'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-7.js new file mode 100644 index 0000000000..658bc8a8bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-7.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce stops calling callbackfn once the array is + deleted during the call +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + delete o.arr; + return prevVal + curVal; +} + +var o = new Object(); +o.arr = ['1', 2, 3, 4, 5]; + +assert.sameValue(o.arr.reduce(callbackfn), "12345", 'o.arr.reduce(callbackfn)'); +assert.sameValue(o.hasOwnProperty("arr"), false, 'o.hasOwnProperty("arr")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-8.js new file mode 100644 index 0000000000..bfee2b4417 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-8.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - no observable effects occur if 'len' is 0 +---*/ + +var accessed = false; +var callbackAccessed = false; + +function callbackfn() { + callbackAccessed = true; +} + +var obj = { + length: 0 +}; + +Object.defineProperty(obj, "0", { + get: function() { + accessed = true; + return 10; + }, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn, "initialValue"); + +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(callbackAccessed, false, 'callbackAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-9.js new file mode 100644 index 0000000000..9d6ce4d023 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-9.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - modifications to length don't change + number of iterations in step 9 +---*/ + +var called = 0; + +function callbackfn(accum, val, idx, obj) { + called++; + return accum + val; +} + +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 2; + return 0; + }, + configurable: true +}); + +var newAccum = arr.reduce(callbackfn, "initialValue"); + +assert.sameValue(newAccum, "initialValue01", 'newAccum'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-1.js new file mode 100644 index 0000000000..44157ae461 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-1.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialvalue when Array is empty + and initialValue is present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} + +var arr = new Array(10); + +assert.sameValue(arr.reduce(callbackfn, 5), 5, 'arr.reduce(callbackfn,5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-10.js new file mode 100644 index 0000000000..60a6f7769a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-10.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting property of prototype in step 8 + causes deleted index property not to be visited on an Array-like + Object +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 3) { + testResult = false; + } +} + +var obj = { + 2: 2, + length: 20 +}; + +Object.defineProperty(obj, "0", { + get: function() { + delete Object.prototype[3]; + return 0; + }, + configurable: true +}); + +Object.prototype[3] = 1; +Array.prototype.reduce.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-11.js new file mode 100644 index 0000000000..b156e88812 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-11.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting property of prototype in step 8 + causes deleted index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var arr = [, , , 3]; +Object.defineProperty(arr, "0", { + get: function() { + delete Array.prototype[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-12.js new file mode 100644 index 0000000000..e3e9450048 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-12.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property with prototype + property in step 8 causes prototype index property to be visited + on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} + +var obj = { + 0: 0, + 1: 111, + 4: 10, + length: 10 +}; + +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; +Array.prototype.reduce.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-13.js new file mode 100644 index 0000000000..a5d1456e2f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-13.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property with prototype + property in step 8 causes prototype index property to be visited + on an Array +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} +var arr = [0, 111]; + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-14.js new file mode 100644 index 0000000000..edbd8ad8b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-14.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - decreasing length of array in step 8 + causes deleted index property not to be visited +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 2) { + testResult = false; + } +} + +var arr = [0, 1, 2, 3]; + +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 2; + return 0; + }, + configurable: true +}); + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-15.js new file mode 100644 index 0000000000..c34e872187 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-15.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - decreasing length of array with prototype + property in step 8 causes prototype index property to be visited +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 2 && val === "prototype") { + testResult = true; + } +} +var arr = [0, 1, 2, 3]; + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-16.js new file mode 100644 index 0000000000..ec284d7ce6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-16.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - decreasing length of array in step 8 does + not delete non-configurable properties +flags: [noStrict] +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 2 && val === "unconfigurable") { + testResult = true; + } +} + +var arr = [0, 1, 2, 3]; + +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); + +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-17.js new file mode 100644 index 0000000000..a498629a11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-17.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties added into own object are + visited on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 3 && val === 3) { + testResult = true; + } +} + +var obj = { + length: 5 +}; + +Object.defineProperty(obj, "1", { + get: function() { + Object.defineProperty(obj, "3", { + get: function() { + return 3; + }, + configurable: true + }); + return 1; + }, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-18.js new file mode 100644 index 0000000000..3071d8509d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-18.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties added into own object are + visited on an Array +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +arr.reduce(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-19.js new file mode 100644 index 0000000000..3fc99ff400 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-19.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties added to prototype are visited + on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 6.99) { + testResult = true; + } +} + +var obj = { + length: 6 +}; + +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-2.js new file mode 100644 index 0000000000..2d19d3bb2f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-2.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - added properties in step 2 are visible + here +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 2 && val === "2") { + testResult = true; + } +} + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + obj[2] = "2"; + return 3; + }, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-20.js new file mode 100644 index 0000000000..11593423e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-20.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties can be added to prototype are + visited on an Array +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 6.99) { + testResult = true; + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(Array.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +arr.reduce(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-21.js new file mode 100644 index 0000000000..42099d8cad --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-21.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property causes deleted + index property not to be visited on an Array-like object +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var obj = { + 5: 10, + length: 10 +}; + +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); + +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-22.js new file mode 100644 index 0000000000..7967244ed9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-22.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property causes deleted + index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var arr = [1, 2, 4]; + +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +arr.reduce(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-23.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-23.js new file mode 100644 index 0000000000..2bff04ecb3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-23.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting property of prototype causes + deleted index property not to be visited on an Array-like Object +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 3) { + testResult = false; + } +} + +var obj = { + 2: 2, + length: 20 +}; + +Object.defineProperty(obj, "0", { + get: function() { + delete Object.prototype[3]; + return 0; + }, + configurable: true +}); + +Object.prototype[3] = 1; +Array.prototype.reduce.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-24.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-24.js new file mode 100644 index 0000000000..8c6f24ae3c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-24.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting property of prototype causes + deleted index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var arr = [0, , , 3]; +Object.defineProperty(arr, "0", { + get: function() { + delete Array.prototype[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; +arr.reduce(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-25.js new file mode 100644 index 0000000000..7d5a359b7b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-25.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} + +var obj = { + 0: 0, + 1: 111, + 4: 10, + length: 10 +}; + +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; +Array.prototype.reduce.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-26.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-26.js new file mode 100644 index 0000000000..a0939b0528 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-26.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} +var arr = [0, 111]; + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; +arr.reduce(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-27.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-27.js new file mode 100644 index 0000000000..81d71e0551 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-27.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - decreasing length of array causes deleted + index property not to be visited +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 2) { + testResult = false; + } +} + +var arr = [0, 1, 2, 3]; + +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 2; + return 0; + }, + configurable: true +}); + +arr.reduce(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-28.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-28.js new file mode 100644 index 0000000000..c382d3c049 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-28.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - decreasing length of array with prototype + property causes prototype index property to be visited +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 2 && val === "prototype") { + testResult = true; + } +} +var arr = [0, 1, 2, 3]; + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +arr.reduce(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-29.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-29.js new file mode 100644 index 0000000000..bb036b1942 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-29.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - decreasing length of array does not + delete non-configurable properties +flags: [noStrict] +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 2 && val === "unconfigurable") { + testResult = true; + } +} + +var arr = [0, 1, 2, 3]; + +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); + +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +arr.reduce(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-3.js new file mode 100644 index 0000000000..d2b61c380b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-3.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleted properties in step 2 are visible + here +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 2) { + testResult = false; + } +} + +var obj = { + 2: "2", + 3: 10 +}; + +Object.defineProperty(obj, "length", { + get: function() { + delete obj[2]; + return 5; + }, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn, "initialValue"); + +assert(accessed, 'accessed !== true'); +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-4.js new file mode 100644 index 0000000000..11e541c5ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-4.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties added into own object in step + 8 are visited on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 3 && val === 3) { + testResult = true; + } +} + +var obj = { + length: 5 +}; + +Object.defineProperty(obj, "1", { + get: function() { + Object.defineProperty(obj, "3", { + get: function() { + return 3; + }, + configurable: true + }); + return 1; + }, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-5.js new file mode 100644 index 0000000000..c909df54cf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-5.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties added into own object in step + 8 are visited on an Array +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-6.js new file mode 100644 index 0000000000..80a02f023d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-6.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties added to prototype in step 8 + are visited on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 6.99) { + testResult = true; + } +} + +var obj = { + length: 6 +}; + +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-7.js new file mode 100644 index 0000000000..5f31131b59 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-7.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties added to prototype in step 8 + are visited on an Array +---*/ + +var testResult = false; + +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 6.99) { + testResult = true; + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(Array.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-8.js new file mode 100644 index 0000000000..91ca865f39 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-8.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property in step 8 causes + deleted index property not to be visited on an Array-like object +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var obj = { + 5: 10, + length: 10 +}; + +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); + +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-9.js new file mode 100644 index 0000000000..9ccd019873 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-9.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property in step 8 causes + deleted index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var arr = [1, 2, 4]; + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +arr.reduce(callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-1.js new file mode 100644 index 0000000000..749f146c19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-1.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn not called for indexes never + been assigned values +---*/ + +var callCnt = 0; + +function callbackfn(prevVal, curVal, idx, obj) +{ + callCnt++; + return curVal; +} + +var arr = new Array(10); +arr[0] = arr[1] = undefined; //explicitly assigning a value + +assert.sameValue(arr.reduce(callbackfn), undefined, 'arr.reduce(callbackfn)'); +assert.sameValue(callCnt, 1, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-1.js new file mode 100644 index 0000000000..e7639b790b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-1.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var obj = { + 0: 0, + 1: 1, + 2: 2, + length: 2 +}; +Array.prototype.reduce.call(obj, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-10.js new file mode 100644 index 0000000000..4c7c666a42 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-10.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property on an Array +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +arr.reduce(callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-11.js new file mode 100644 index 0000000000..d188f7d158 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-11.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "11"); + } +} + +var proto = { + 0: 0, + 1: 1, + 2: 2 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Object.defineProperty(child, "1", { + get: function() { + return "11"; + }, + configurable: true +}); + +Array.prototype.reduce.call(child, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-12.js new file mode 100644 index 0000000000..325721cdb3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-12.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "11"); + } +} + +Array.prototype[1] = 1; +var arr = [0, , 2]; + +Object.defineProperty(arr, "1", { + get: function() { + return "11"; + }, + configurable: true +}); + +arr.reduce(callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-13.js new file mode 100644 index 0000000000..3eed9913f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-13.js @@ -0,0 +1,50 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "11"); + } +} + +var proto = { + 0: 0, + 2: 2 +}; + +Object.defineProperty(proto, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Object.defineProperty(child, "1", { + get: function() { + return "11"; + }, + configurable: true +}); + +Array.prototype.reduce.call(child, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-14.js new file mode 100644 index 0000000000..ccf3277480 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-14.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "11"); + } +} + +Object.defineProperty(Array.prototype, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +var arr = [0, , 2]; + +Object.defineProperty(arr, "1", { + get: function() { + return "11"; + }, + configurable: true +}); +arr.reduce(callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-15.js new file mode 100644 index 0000000000..9d3c2e3eea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-15.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var proto = { + 0: 0, + 2: 2 +}; + +Object.defineProperty(proto, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Array.prototype.reduce.call(child, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-16.js new file mode 100644 index 0000000000..611db7802a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-16.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property on an Array +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +Object.defineProperty(Array.prototype, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +var arr = [0, , 2, ]; + +arr.reduce(callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-17.js new file mode 100644 index 0000000000..720b3fa366 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-17.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === undefined); + } +} + +var obj = { + 0: 0, + 2: 2, + length: 3 +}; + +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-18.js new file mode 100644 index 0000000000..2c2018cafc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-18.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === undefined); + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "1", { + set: function() {}, + configurable: true +}); + +arr.reduce(callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-19.js new file mode 100644 index 0000000000..aa81d7149c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-19.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === undefined); + } +} + +Object.defineProperty(Object.prototype, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +var obj = { + 0: 0, + 2: 2, + length: 3 +}; + +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-2.js new file mode 100644 index 0000000000..2ae2989b74 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-2.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property on an Array +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var arr = [0, 1]; +arr.reduce(callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-20.js new file mode 100644 index 0000000000..5268899bc3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-20.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === undefined); + } +} + +Object.defineProperty(Array.prototype, "1", { + get: function() { + return 11; + }, + configurable: true +}); + +var arr = [0, , 2]; +Object.defineProperty(arr, "1", { + set: function() {}, + configurable: true +}); + +arr.reduce(callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-21.js new file mode 100644 index 0000000000..e8bdb0bc83 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-21.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === undefined); + } +} + +var proto = { + 0: 0, + 2: 2 +}; + +Object.defineProperty(proto, "1", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Array.prototype.reduce.call(child, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-22.js new file mode 100644 index 0000000000..d6c37f0def --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-22.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === undefined); + } +} + +Object.defineProperty(Array.prototype, "1", { + set: function() {}, + configurable: true +}); + +var arr = [0, , 2]; + +arr.reduce(callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-25.js new file mode 100644 index 0000000000..cf14798787 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-25.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - This object is the Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var func = function(a, b, c) { + Array.prototype.reduce.call(arguments, callbackfn, initialValue); +}; + +func(0, 1); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-26.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-26.js new file mode 100644 index 0000000000..790beb9588 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-26.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - This object is the Arguments object which + implements its own property get method (number of arguments equals + number of parameters) +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2) { + testResult = (curVal === 2); + } +} + +var func = function(a, b, c) { + Array.prototype.reduce.call(arguments, callbackfn, initialValue); +}; + +func(0, 1, 2); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-27.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-27.js new file mode 100644 index 0000000000..59cd5addbc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-27.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - This object is the Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 3) { + testResult = (curVal === 3); + } +} + +var func = function(a, b, c) { + Array.prototype.reduce.call(arguments, callbackfn, initialValue); +}; + +func(0, 1, 2, 3); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-28.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-28.js new file mode 100644 index 0000000000..8be9460f76 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-28.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - applied to String object, which + implements its own property get method +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "1"); + } +} + +var str = new String("012"); + +Array.prototype.reduce.call(str, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-29.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-29.js new file mode 100644 index 0000000000..8f9873722d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-29.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - applied to Function object which + implements its own property get method +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var obj = function(a, b, c) { + return a + b + c; +}; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; + +Array.prototype.reduce.call(obj, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-3.js new file mode 100644 index 0000000000..569a310e2d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-3.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "11"); + } +} + +var proto = { + 0: 0, + 1: 1, + 2: 2, + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[1] = "11"; +child[2] = "22"; +child.length = 3; + +Array.prototype.reduce.call(child, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-30.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-30.js new file mode 100644 index 0000000000..1380973eb6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-30.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element changed by getter on previous + iterations is observed on an Array +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var arr = [, , 2]; +var preIterVisible = false; + +Object.defineProperty(arr, "0", { + get: function() { + preIterVisible = true; + return 0; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return 100; + } + }, + configurable: true +}); + +arr.reduce(callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-31.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-31.js new file mode 100644 index 0000000000..7853d46bb7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-31.js @@ -0,0 +1,49 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element changed by getter on previous + iterations is observed on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var obj = { + 2: 2, + length: 3 +}; +var preIterVisible = false; + +Object.defineProperty(obj, "0", { + get: function() { + preIterVisible = true; + return 0; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return "11"; + } + }, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-32.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-32.js new file mode 100644 index 0000000000..7d676d5d01 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-32.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - unnhandled exceptions happened in getter + terminate iteration on an Array-like object +---*/ + +var accessed = false; +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx >= 1) { + accessed = true; + testResult = (curVal >= 1); + } +} + +var obj = { + 0: 0, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + Array.prototype.reduce.call(obj, callbackfn, initialValue); +}); +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(testResult, false, 'testResult'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-33.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-33.js new file mode 100644 index 0000000000..0e7cc93359 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-33.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - unnhandled exceptions happened in getter + terminate iteration on an Array +---*/ + +var accessed = false; +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx >= 1) { + accessed = true; + testResult = (curVal >= 1); + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.reduce(callbackfn, initialValue); +}); +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(testResult, false, 'testResult'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-4.js new file mode 100644 index 0000000000..a50f6085f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-4.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +Array.prototype[1] = "3"; +[0, 1, 2].reduce(callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-5.js new file mode 100644 index 0000000000..c6fbbd7b9a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-5.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0) { + testResult = (curVal === "9"); + } +} + +var proto = {}; + +Object.defineProperty(proto, "0", { + get: function() { + return 0; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; + +Object.defineProperty(child, "0", { + value: "9", + configurable: true +}); + +child[1] = "1"; + +Array.prototype.reduce.call(child, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-6.js new file mode 100644 index 0000000000..804f3abf62 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-6.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +Object.defineProperty(Array.prototype, "1", { + get: function() { + return "9"; + }, + configurable: true +}); +[0, 1, 2].reduce(callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-7.js new file mode 100644 index 0000000000..fcab20dd03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-7.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited data + property on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var proto = { + 0: 0, + 1: 1, + 2: 2, + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Array.prototype.reduce.call(child, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-8.js new file mode 100644 index 0000000000..643caa660c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-8.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited data + property on an Array +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +Array.prototype[0] = 0; +Array.prototype[1] = 1; +Array.prototype[2] = 2; +[, , , ].reduce(callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-9.js new file mode 100644 index 0000000000..015237b068 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-9.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var obj = { + 0: 0, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +Array.prototype.reduce.call(obj, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-1.js new file mode 100644 index 0000000000..01a67c6ee7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-1.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn called with correct parameters + (initialvalue not passed) +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + if (idx > 0 && obj[idx] === curVal && obj[idx - 1] === prevVal) + return curVal; + else + return false; +} + +var arr = [0, 1, true, null, new Object(), "five"]; + +assert.sameValue(arr.reduce(callbackfn), "five", 'arr.reduce(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-10.js new file mode 100644 index 0000000000..7ed02502e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-10.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn is called with 1 formal + parameter +---*/ + +var result = false; + +function callbackfn(prevVal) { + result = (prevVal === 1); +} + +[11].reduce(callbackfn, 1); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-11.js new file mode 100644 index 0000000000..531891ff92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-11.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn is called with 2 formal + parameter +---*/ + +var result = false; + +function callbackfn(prevVal, curVal) { + result = (curVal > 10 && 1 === prevVal); +} + +[11].reduce(callbackfn, 1); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-12.js new file mode 100644 index 0000000000..61cdd93308 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-12.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn is called with 3 formal + parameter +---*/ + +var result = false; + +function callbackfn(prevVal, curVal, idx) { + result = (prevVal === 1 && arguments[3][idx] === curVal); +} + +[11].reduce(callbackfn, 1); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-13.js new file mode 100644 index 0000000000..3a2029f943 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-13.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn is called with 4 formal + parameter +---*/ + +var result = false; + +function callbackfn(prevVal, curVal, idx, obj) { + result = (prevVal === 1 && obj[idx] === curVal); +} + +[11].reduce(callbackfn, 1); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-14.js new file mode 100644 index 0000000000..5b6b548b7d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-14.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - callbackfn that uses arguments +---*/ + +var result = false; + +function callbackfn() { + result = (arguments[0] === 1 && arguments[3][arguments[2]] === arguments[1]); +} + +[11].reduce(callbackfn, 1); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-16.js new file mode 100644 index 0000000000..bd1c1e68f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-16.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - non-indexed properties are not called +---*/ + +var accessed = false; +var result1 = true; +var result2 = true; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (curVal === 8) { + result1 = false; + } + + if (prevVal === 8) { + result2 = false; + } +} + +var obj = { + 0: 11, + 10: 12, + non_index_property: 8, + length: 20 +}; + +Array.prototype.reduce.call(obj, callbackfn, 1); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-17.js new file mode 100644 index 0000000000..6389a25655 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-17.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'accumulator' used for current iteration + is the result of previous iteration on an Array +---*/ + +var result = true; +var accessed = false; +var preIteration = 1; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (preIteration !== prevVal) { + result = false; + } + preIteration = curVal; + return curVal; +} + +[11, 12, 13].reduce(callbackfn, 1); + +assert(result, 'result !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-18.js new file mode 100644 index 0000000000..0bcaab5cb3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-18.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'accumulator' used for first + iteration is the value of 'initialValue' when it is present on an + Array-like object +---*/ + +var result = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0) { + result = (arguments[0] === 1); + } +} + +var obj = { + 0: 11, + 1: 9, + length: 2 +}; + +Array.prototype.reduce.call(obj, callbackfn, 1); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-19.js new file mode 100644 index 0000000000..e4332b2cef --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-19.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'accumulator' used for first + iteration is the value of least index property which is not + undefined when 'initialValue' is not present on an Array +---*/ + +var called = 0; +var result = false; + +function callbackfn(prevVal, curVal, idx, obj) { + called++; + if (idx === 1) { + result = (prevVal === 11) && curVal === 9; + } +} + +[11, 9].reduce(callbackfn); + +assert(result, 'result !== true'); +assert.sameValue(called, 1, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-2.js new file mode 100644 index 0000000000..9221d07ff2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-2.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn called with correct parameters + (initialvalue passed) +---*/ + +var bParCorrect = false; + +function callbackfn(prevVal, curVal, idx, obj) +{ + if (idx === 0 && obj[idx] === curVal && prevVal === initialValue) + return curVal; + else if (idx > 0 && obj[idx] === curVal && obj[idx - 1] === prevVal) + return curVal; + else + return false; +} + +var arr = [0, 1, true, null, new Object(), "five"]; +var initialValue = 5.5; + +assert.sameValue(arr.reduce(callbackfn, initialValue), "five", 'arr.reduce(callbackfn,initialValue)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-20.js new file mode 100644 index 0000000000..51594de3c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-20.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - undefined can be used as accumulator +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return typeof prevVal === "undefined"; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, undefined), true, 'Array.prototype.reduce.call(obj, callbackfn, undefined)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-21.js new file mode 100644 index 0000000000..48f16b2c1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-21.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - null can be used as accumulator +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === null; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, null), true, 'Array.prototype.reduce.call(obj, callbackfn, null)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-22.js new file mode 100644 index 0000000000..a418171cec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-22.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - boolean primitive can be used as + accumulator +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === false; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, false), true, 'Array.prototype.reduce.call(obj, callbackfn, false)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-23.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-23.js new file mode 100644 index 0000000000..93676ebf11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-23.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - number primitive can be used as + accumulator +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === 12; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 12), true, 'Array.prototype.reduce.call(obj, callbackfn, 12)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-24.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-24.js new file mode 100644 index 0000000000..937acec0b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-24.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - string primitive can be used as + accumulator +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === "hello_"; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, "hello_"), true, 'Array.prototype.reduce.call(obj, callbackfn, "hello_")'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-25.js new file mode 100644 index 0000000000..58bcbd7f40 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-25.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - Function object can be used as accumulator +---*/ + +var objFunction = function() {}; + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objFunction; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objFunction), true, 'Array.prototype.reduce.call(obj, callbackfn, objFunction)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-26.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-26.js new file mode 100644 index 0000000000..e610d26a66 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-26.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - Array object can be used as accumulator +---*/ + +var objArray = new Array(10); + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objArray; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objArray), true, 'Array.prototype.reduce.call(obj, callbackfn, objArray)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-27.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-27.js new file mode 100644 index 0000000000..52c7a8d870 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-27.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - String object can be used as accumulator +---*/ + +var objString = new String(); + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objString; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objString), true, 'Array.prototype.reduce.call(obj, callbackfn, objString)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-28.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-28.js new file mode 100644 index 0000000000..b36d411d9d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-28.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - Boolean object can be used as accumulator +---*/ + +var objBoolean = new Boolean(); + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objBoolean; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objBoolean), true, 'Array.prototype.reduce.call(obj, callbackfn, objBoolean)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-29.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-29.js new file mode 100644 index 0000000000..ef666f11a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-29.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - Number object can be used as accumulator +---*/ + +var objNumber = new Number(); + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objNumber; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objNumber), true, 'Array.prototype.reduce.call(obj, callbackfn, objNumber)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-3.js new file mode 100644 index 0000000000..484f4def97 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - callbackfn takes 4 arguments +---*/ + +var bCalled = false; + +function callbackfn(prevVal, curVal, idx, obj) +{ + bCalled = true; + if (prevVal === true && arguments.length === 4) + return true; + else + return false; +} +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + +assert.sameValue(arr.reduce(callbackfn, true), true, 'arr.reduce(callbackfn,true)'); +assert.sameValue(bCalled, true, 'bCalled'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-30.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-30.js new file mode 100644 index 0000000000..3fbc3f2276 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-30.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - the Math object can be used as accumulator +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === Math; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, Math), true, 'Array.prototype.reduce.call(obj, callbackfn, Math)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-31.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-31.js new file mode 100644 index 0000000000..009e44f687 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-31.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - Date object can be used as accumulator +---*/ + +var objDate = new Date(); + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objDate; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objDate), true, 'Array.prototype.reduce.call(obj, callbackfn, objDate)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-32.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-32.js new file mode 100644 index 0000000000..1e226ccbc4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-32.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - RegExp object can be used as accumulator +---*/ + +var objRegExp = new RegExp(); + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objRegExp; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objRegExp), true, 'Array.prototype.reduce.call(obj, callbackfn, objRegExp)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-33.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-33.js new file mode 100644 index 0000000000..f73446cdfc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-33.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - the JSON can be used as accumulator +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === JSON; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, JSON), true, 'Array.prototype.reduce.call(obj, callbackfn, JSON)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-34.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-34.js new file mode 100644 index 0000000000..84a311f748 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-34.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - Error object can be used as accumulator +---*/ + +var objError = new RangeError(); + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objError; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objError), true, 'Array.prototype.reduce.call(obj, callbackfn, objError)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-35.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-35.js new file mode 100644 index 0000000000..62801208a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-35.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the Arguments object can be used as + accumulator +---*/ + +var accessed = false; +var arg; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === arg; +} + +var obj = { + 0: 11, + length: 1 +}; + +(function fun() { + arg = arguments; +}(10, 11, 12, 13)); + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, arg), true, 'Array.prototype.reduce.call(obj, callbackfn, arg)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-37.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-37.js new file mode 100644 index 0000000000..8c736bc96b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-37.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the global object can be used as + accumulator +---*/ + +var global = this; +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === global; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, this), true, 'Array.prototype.reduce.call(obj, callbackfn, this)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4-s.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4-s.js new file mode 100644 index 0000000000..deff6b06a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4-s.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - undefined passed as thisValue to strict + callbackfn +flags: [noStrict] +---*/ + +var innerThisCorrect = false; + +function callbackfn(prevVal, curVal, idx, obj) +{ + "use strict"; + innerThisCorrect = this === undefined; + return true; +} +[0].reduce(callbackfn, true); + +assert(innerThisCorrect, 'innerThisCorrect !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4.js new file mode 100644 index 0000000000..31dbdaea73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - k values are passed in acending numeric + order on an Array +---*/ + +var arr = [0, 1, 2]; +var lastIdx = 0; +var result = true; +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (lastIdx !== idx) { + result = false; + } else { + lastIdx++; + } +} + +arr.reduce(callbackfn, 11); + +assert(result, 'result !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-5.js new file mode 100644 index 0000000000..efb6db149f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-5.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - k values are accessed during each + iteration and not prior to starting the loop on an Array +---*/ + +var result = true; +var kIndex = []; +var called = 0; + +//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(prevVal, curVal, idx, obj) { + //Each position should be visited one time, which means k is accessed one time during iterations. + called++; + if (typeof kIndex[idx] === "undefined") { + //when current position is visited, its previous index should has been visited. + if (idx !== 0 && typeof kIndex[idx - 1] === "undefined") { + result = false; + } + kIndex[idx] = 1; + } else { + result = false; + } +} + +[11, 12, 13, 14].reduce(callbackfn, 1); + +assert(result, 'result !== true'); +assert.sameValue(called, 4, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-7.js new file mode 100644 index 0000000000..03ebf20fba --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-7.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - unhandled exceptions happened in + callbackfn terminate iteration +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 0) { + accessed = true; + } + if (idx === 0) { + throw new Error("Exception occurred in callbackfn"); + } +} + +var obj = { + 0: 11, + 4: 10, + 10: 8, + length: 20 +}; +assert.throws(Error, function() { + Array.prototype.reduce.call(obj, callbackfn, 1); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-8.js new file mode 100644 index 0000000000..135566d8a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-8.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element changed by callbackfn on previous + iterations is observed +---*/ + +var result = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0) { + obj[idx + 1] = 8; + } + + if (idx === 1) { + result = (curVal === 8); + } +} + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +Array.prototype.reduce.call(obj, callbackfn, 1); + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-9.js new file mode 100644 index 0000000000..1d317d4d44 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-9.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn is called with 0 formal + parameter +---*/ + +var called = 0; + +function callbackfn() { + called++; +} + +[11, 12].reduce(callbackfn, 1); + +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/browser.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/call-with-boolean.js new file mode 100644 index 0000000000..f7063cd6c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/call-with-boolean.js @@ -0,0 +1,20 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to boolean primitive +---*/ + +assert.sameValue( + Array.prototype.reduce.call(true, () => {}, -1), + -1, + 'Array.prototype.reduce.call(true, () => {}, -1) must return -1' +); +assert.sameValue( + Array.prototype.reduce.call(false, () => {}, -1), + -1, + 'Array.prototype.reduce.call(false, () => {}, -1) must return -1' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js new file mode 100644 index 0000000000..7196680bec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js @@ -0,0 +1,76 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.reduce +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 3}); + var sample = new TA(buffer); + var expectedPrevs, expectedNexts, expectedIndices, expectedArrays; + var prevs, nexts, indices, arrays, result; + + prevs = []; + nexts = []; + indices = []; + arrays = []; + result = Array.prototype.reduce.call(sample, function(prev, next, index, array) { + if (prevs.length === 0) { + try { + buffer.resize(2 * BPE); + expectedPrevs = [262, 0]; + expectedNexts = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + expectedPrevs = [262, 0, 1]; + expectedNexts = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + prevs.push(prev); + nexts.push(next); + indices.push(index); + arrays.push(array); + return index; + }, 262); + + assert.compareArray(prevs, expectedPrevs, 'prevs (shrink)'); + assert.compareArray(nexts, expectedNexts, 'nexts (shrink)'); + assert.compareArray(indices, expectedIndices, 'indices (shrink)'); + assert.compareArray(arrays, expectedArrays, 'arrays (shrink)'); + assert.sameValue(result, expectedIndices[expectedIndices.length - 1], 'result (shrink)'); + + prevs = []; + nexts = []; + indices = []; + arrays = []; + result = Array.prototype.reduce.call(sample, function(prev, next, index, array) { + if (prevs.length === 0) { + try { + buffer.resize(3 * BPE); + } catch (_) {} + } + + prevs.push(prev); + nexts.push(next); + indices.push(index); + arrays.push(array); + return index; + }, 262); + + assert.compareArray(prevs, expectedPrevs, 'prevs (grow)'); + assert.compareArray(nexts, expectedNexts, 'nexts (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, expectedIndices[expectedIndices.length - 1], 'result (grow)'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/length.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/length.js new file mode 100644 index 0000000000..46705546bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + The "length" property of Array.prototype.reduce +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.reduce.length, 1); + +verifyNotEnumerable(Array.prototype.reduce, 'length'); +verifyNotWritable(Array.prototype.reduce, 'length'); +verifyConfigurable(Array.prototype.reduce, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/name.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/name.js new file mode 100644 index 0000000000..0b368568bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce.name is "reduce". +info: | + Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.reduce.name, "reduce"); + +verifyNotEnumerable(Array.prototype.reduce, "name"); +verifyNotWritable(Array.prototype.reduce, "name"); +verifyConfigurable(Array.prototype.reduce, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/not-a-constructor.js new file mode 100644 index 0000000000..66a7e1f277 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/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: > + Array.prototype.reduce 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.reduce), + false, + 'isConstructor(Array.prototype.reduce) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.reduce(() => {}, []); +}, '`new Array.prototype.reduce(() => {}, [])` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/prop-desc.js new file mode 100644 index 0000000000..c2bdef04e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + "reduce" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.reduce, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "reduce"); +verifyWritable(Array.prototype, "reduce"); +verifyConfigurable(Array.prototype, "reduce"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/shell.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/shell.js new file mode 100644 index 0000000000..05fecd6ef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/shell.js @@ -0,0 +1,161 @@ +// GENERATED, DO NOT EDIT +// file: testTypedArray.js +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - floatArrayConstructors + - nonClampedIntArrayConstructors + - intArrayConstructors + - typedArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - nonAtomicsFriendlyTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +var floatArrayConstructors = [ + Float64Array, + Float32Array +]; + +var nonClampedIntArrayConstructors = [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array +]; + +var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]); + +// Float16Array is a newer feature +// adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it +if (typeof Float16Array !== 'undefined') { + floatArrayConstructors.push(Float16Array); +} + +/** + * Array containing every non-bigint typed array constructor. + */ + +var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]); +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} + +/** + * Checks if the given argument is one of the float-based TypedArray constructors. + * + * @param {constructor} ctor - the value to check + * @returns {boolean} + */ +function isFloatTypedArrayConstructor(arg) { + return floatArrayConstructors.indexOf(arg) !== -1; +} + +/** + * Determines the precision of the given float-based TypedArray constructor. + * + * @param {constructor} ctor - the value to check + * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively. + */ +function floatTypedArrayConstructorPrecision(FA) { + if (typeof Float16Array !== "undefined" && FA === Float16Array) { + return "half"; + } else if (FA === Float32Array) { + return "single"; + } else if (FA === Float64Array) { + return "double"; + } else { + throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray"); + } +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-1.js new file mode 100644 index 0000000000..9c269a4238 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to undefined throws a TypeError +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.reduceRight.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-10.js new file mode 100644 index 0000000000..7905eb1c06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-10.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to the Math object +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return '[object Math]' === Object.prototype.toString.call(obj); +} + +Math.length = 1; +Math[0] = 1; + +assert(Array.prototype.reduceRight.call(Math, callbackfn, 1), 'Array.prototype.reduceRight.call(Math, callbackfn, 1) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-11.js new file mode 100644 index 0000000000..0b948bb5ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-11.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to Date object +---*/ + +var obj = new Date(); +obj.length = 1; +obj[0] = 1; +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj instanceof Date; +} + +assert(Array.prototype.reduceRight.call(obj, callbackfn, 1), 'Array.prototype.reduceRight.call(obj, callbackfn, 1) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-12.js new file mode 100644 index 0000000000..6be9132c57 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-12.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to RegExp object +---*/ + +var obj = new RegExp(); +obj.length = 1; +obj[0] = 1; +var accessed = false; + +function callbackfn(prevVal, curVal, idx, o) { + accessed = true; + return o instanceof RegExp; +} + +assert(Array.prototype.reduceRight.call(obj, callbackfn, 1), 'Array.prototype.reduceRight.call(obj, callbackfn, 1) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-13.js new file mode 100644 index 0000000000..f3f39b22e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-13.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to the JSON object +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return ('[object JSON]' === Object.prototype.toString.call(obj)); +} + +JSON.length = 1; +JSON[0] = 1; + +assert(Array.prototype.reduceRight.call(JSON, callbackfn, 1), 'Array.prototype.reduceRight.call(JSON, callbackfn, 1) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-14.js new file mode 100644 index 0000000000..fa4bd8446b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-14.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to Error object +---*/ + +var obj = new Error(); +obj.length = 1; +obj[0] = 1; +var accessed = false; + +function callbackfn(prevVal, curVal, idx, o) { + accessed = true; + return o instanceof Error; +} + +assert(Array.prototype.reduceRight.call(obj, callbackfn, 1), 'Array.prototype.reduceRight.call(obj, callbackfn, 1) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-15.js new file mode 100644 index 0000000000..459cc6b04c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-15.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to the Arguments object +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return '[object Arguments]' === Object.prototype.toString.call(obj); +} + +var obj = (function() { + return arguments; +}("a", "b")); + +assert(Array.prototype.reduceRight.call(obj, callbackfn, "a"), 'Array.prototype.reduceRight.call(obj, callbackfn, "a") !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-2.js new file mode 100644 index 0000000000..dee59c432a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to null throws a TypeError +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.reduceRight.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-3.js new file mode 100644 index 0000000000..e48a267504 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-3.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to boolean primitive +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj instanceof Boolean; +} + +Boolean.prototype[0] = 1; +Boolean.prototype.length = 1; + +assert(Array.prototype.reduceRight.call(false, callbackfn, 1), 'Array.prototype.reduceRight.call(false, callbackfn, 1) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-4.js new file mode 100644 index 0000000000..dce9cd7792 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-4.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to Boolean object +---*/ + +var obj = new Boolean(true); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj instanceof Boolean; +} + +assert(Array.prototype.reduceRight.call(obj, callbackfn, 11), 'Array.prototype.reduceRight.call(obj, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-5.js new file mode 100644 index 0000000000..232a748330 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-5.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to number primitive +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj instanceof Number; +} + +Number.prototype[0] = 1; +Number.prototype.length = 1; + +assert(Array.prototype.reduceRight.call(2.5, callbackfn, 1), 'Array.prototype.reduceRight.call(2.5, callbackfn, 1) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-6.js new file mode 100644 index 0000000000..baa0557021 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-6.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to Number object +---*/ + +var obj = new Number(-128); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; +var accessed = false; + +function callbackfn(prevVal, curVal, idx, o) { + accessed = true; + return o instanceof Number; +} + +assert(Array.prototype.reduceRight.call(obj, callbackfn, 11), 'Array.prototype.reduceRight.call(obj, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-7.js new file mode 100644 index 0000000000..e9330ba845 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-7.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to string primitive +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj instanceof String; +} + +assert(Array.prototype.reduceRight.call("hello\nworld\\!", callbackfn, "h"), 'Array.prototype.reduceRight.call("hello\nworld\\!", callbackfn, "h") !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-8.js new file mode 100644 index 0000000000..f8f2b6a480 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-8.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to String object +---*/ + +var obj = new String("hello\nworld\\!"); +var accessed = false; + +function callbackfn(prevVal, curVal, idx, o) { + accessed = true; + return o instanceof String; +} + +assert(Array.prototype.reduceRight.call(obj, callbackfn, "h"), 'Array.prototype.reduceRight.call(obj, callbackfn, "h") !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-9.js new file mode 100644 index 0000000000..94b7826729 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-1-9.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to Function object +---*/ + +var obj = function(a, b) { + return a + b; +}; +obj[0] = 11; +obj[1] = 9; +var accessed = false; + +function callbackfn(prevVal, curVal, idx, o) { + accessed = true; + return o instanceof Function; +} + +assert(Array.prototype.reduceRight.call(obj, callbackfn, 11), 'Array.prototype.reduceRight.call(obj, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-1.js new file mode 100644 index 0000000000..dee63bd94c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-1.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight doesn't mutate the Array on which it + is called on +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + return 1; +} +var srcArr = [1, 2, 3, 4, 5]; +srcArr.reduceRight(callbackfn); + +assert.sameValue(srcArr[0], 1, 'srcArr[0]'); +assert.sameValue(srcArr[1], 2, 'srcArr[1]'); +assert.sameValue(srcArr[2], 3, 'srcArr[2]'); +assert.sameValue(srcArr[3], 4, 'srcArr[3]'); +assert.sameValue(srcArr[4], 5, 'srcArr[4]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-2.js new file mode 100644 index 0000000000..b38e20a381 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-2.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight reduces array in descending order of + indices +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + return prevVal + curVal; +} +var srcArr = ['1', '2', '3', '4', '5']; + +assert.sameValue(srcArr.reduceRight(callbackfn), '54321', 'srcArr.reduceRight(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-3.js new file mode 100644 index 0000000000..f421482435 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - subclassed array with length 1 +---*/ + +foo.prototype = [1]; + +function foo() {} +var f = new foo(); + +function cb() {} + +assert.sameValue(f.reduceRight(cb), 1, 'f.reduceRight(cb)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-4.js new file mode 100644 index 0000000000..ce6f0ef918 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-4.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - subclassed array with length more + than 1 +---*/ + +foo.prototype = new Array(0, 1, 2, 3); + +function foo() {} +var f = new foo(); + +function cb(prevVal, curVal, idx, obj) { + return prevVal + curVal; +} + +assert.sameValue(f.reduceRight(cb), 6, 'f.reduceRight(cb)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-5.js new file mode 100644 index 0000000000..4251a3228e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-5.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight reduces array in descending order of + indices(initialvalue present) +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + return prevVal + curVal; +} +var srcArr = ['1', '2', '3', '4', '5']; + +assert.sameValue(srcArr.reduceRight(callbackfn, '6'), '654321', 'srcArr.reduceRight(callbackfn,"6")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-6.js new file mode 100644 index 0000000000..f087b40433 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-6.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - subclassed array when initialvalue + provided +---*/ + +foo.prototype = new Array(0, 1, 2, 3); + +function foo() {} +var f = new foo(); + +function cb(prevVal, curVal, idx, obj) { + return prevVal + curVal; +} + +assert.sameValue(f.reduceRight(cb, "4"), "43210", 'f.reduceRight(cb,"4")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-7.js new file mode 100644 index 0000000000..7cd5fac5c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-7.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - subclassed array when length to 1 + and initialvalue provided +---*/ + +foo.prototype = [1]; + +function foo() {} +var f = new foo(); + +function cb(prevVal, curVal, idx, obj) { + return prevVal + curVal; +} + +assert.sameValue(f.reduceRight(cb, "4"), "41", 'f.reduceRight(cb,"4")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-8.js new file mode 100644 index 0000000000..ab9a4f3ba5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-10-8.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight doesn't visit expandos +---*/ + +var callCnt = 0; + +function callbackfn(prevVal, curVal, idx, obj) +{ + callCnt++; +} +var srcArr = ['1', '2', '3', '4', '5']; +srcArr["i"] = 10; +srcArr[true] = 11; + +srcArr.reduceRight(callbackfn); + +assert.sameValue(callCnt, 4, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-1.js new file mode 100644 index 0000000000..21c379ab71 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-1.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an own data property +---*/ + +var accessed = false; +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2 +}; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} + +assert(Array.prototype.reduceRight.call(obj, callbackfn, 11), 'Array.prototype.reduceRight.call(obj, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-10.js new file mode 100644 index 0000000000..619a08353d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-10.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an inherited accessor property +---*/ + +var accessed = false; +var Con = function() {}; + + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +Con.prototype = proto; + +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; + + +assert(Array.prototype.reduceRight.call(child, callbackfn, 11), 'Array.prototype.reduceRight.call(child, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-11.js new file mode 100644 index 0000000000..007fb8ab76 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-11.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an own accessor property without a get function +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return typeof obj.length === "undefined"; +} + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, 111), 111, 'Array.prototype.reduceRight.call(obj, callbackfn, 111)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-12.js new file mode 100644 index 0000000000..e9c86d15e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-12.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - 'length' is own accessor property + without a get function that overrides an inherited accessor + property +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return typeof obj.length === "undefined"; +} + +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var obj = { + 0: 12, + 1: 13 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, 11), 11, 'Array.prototype.reduceRight.call(obj, callbackfn, 11)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-13.js new file mode 100644 index 0000000000..c8541a1ee4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-13.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to the Array-like object that + 'length' is inherited accessor property without a get function +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return curVal > 10; +} + +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 11; +child[1] = 12; + +assert.sameValue(Array.prototype.reduceRight.call(child, callbackfn, 111), 111, 'Array.prototype.reduceRight.call(child, callbackfn, 111)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-14.js new file mode 100644 index 0000000000..1cada10464 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-14.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to the Array-like object that + 'length' property doesn't exist +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return curVal > 10; +} + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, 111), 111, 'Array.prototype.reduceRight.call(obj, callbackfn, 111)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-17.js new file mode 100644 index 0000000000..d92f6f751f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-17.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to the Arguments object, which + implements its own property get method +---*/ + +var arg; +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} + +var func = function(a, b) { + arg = arguments; + return Array.prototype.reduceRight.call(arguments, callbackfn, 11); +}; + +assert(func(12, 11), 'func(12, 11) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-18.js new file mode 100644 index 0000000000..854ebd4655 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-18.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to String object, which + implements its own property get method +---*/ + +var accessed = false; +var str = new String("432"); + +function callbackfn(preVal, curVal, idx, obj) { + accessed = true; + return obj.length === 3; +} + +String.prototype[3] = "1"; + +assert(Array.prototype.reduceRight.call(str, callbackfn, 111), 'Array.prototype.reduceRight.call(str, callbackfn, 111) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-19.js new file mode 100644 index 0000000000..22c3bf88b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-19.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Function object, which + implements its own property get method +---*/ + +var accessed = false; +var fun = function(a, b) { + return a + b; +}; +fun[0] = 12; +fun[1] = 11; +fun[2] = 9; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} + +assert(Array.prototype.reduceRight.call(fun, callbackfn, 11), 'Array.prototype.reduceRight.call(fun, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-2.js new file mode 100644 index 0000000000..9776353d22 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-2.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - 'length' is own data property on an + Array +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} + +assert([12, 11].reduceRight(callbackfn, 11), '[12, 11].reduceRight(callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-3.js new file mode 100644 index 0000000000..2c0b4a53d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-3.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an own data property that overrides an inherited data property +---*/ + +var accessed = true; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} + +var proto = { + length: 3 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert(Array.prototype.reduceRight.call(child, callbackfn), 'Array.prototype.reduceRight.call(child, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-4.js new file mode 100644 index 0000000000..5fb88cd893 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-4.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - 'length' is own data property that + overrides an inherited data property on an Array +---*/ + +var accessed = false; +var arrProtoLen; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} + +arrProtoLen = Array.prototype.length; +Array.prototype.length = 0; + +assert([12, 11].reduceRight(callbackfn, 11), '[12, 11].reduceRight(callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-5.js new file mode 100644 index 0000000000..a3198d3cf1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-5.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an own data property that overrides an inherited accessor + property +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert(Array.prototype.reduceRight.call(child, callbackfn), 'Array.prototype.reduceRight.call(child, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-6.js new file mode 100644 index 0000000000..b50278b5f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-6.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an inherited data property +---*/ + +var accessed = false; +var proto = { + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +function callbackfn1(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} + +assert(Array.prototype.reduceRight.call(child, callbackfn1, 11), 'Array.prototype.reduceRight.call(child, callbackfn1, 11) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-7.js new file mode 100644 index 0000000000..3adc1d14e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-7.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an own accessor property +---*/ + +var accessed = true; +var obj = {}; +obj[0] = 12; +obj[1] = 11; +obj[2] = 9; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} + +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +assert(Array.prototype.reduceRight.call(obj, callbackfn, 11), 'Array.prototype.reduceRight.call(obj, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-8.js new file mode 100644 index 0000000000..2e4e8c077b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-8.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an own accessor property that overrides an inherited data + property +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} + +var proto = { + length: 3 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert(Array.prototype.reduceRight.call(child, callbackfn, 11), 'Array.prototype.reduceRight.call(child, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-9.js new file mode 100644 index 0000000000..33243422e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-2-9.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an own accessor property that overrides an inherited accessor + property +---*/ + +var accessed = false; + +function callbackfn1(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; + +assert(Array.prototype.reduceRight.call(child, callbackfn1, 111), 'Array.prototype.reduceRight.call(child, callbackfn1, 111) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-1.js new file mode 100644 index 0000000000..2299e595e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-1.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - value of 'length' is undefined +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} + +var obj = { + 0: 9, + length: undefined +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, 1), 1, 'Array.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-10.js new file mode 100644 index 0000000000..cb8ad72632 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-10.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a number (value + is NaN) +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} + +var obj = { + 0: 9, + length: NaN +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, 1), 1, 'Array.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-11.js new file mode 100644 index 0000000000..68e2a98fd4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-11.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string + containing a positive number +---*/ + +var testResult1 = true; +var testResult2 = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + + if (idx === 1) { + testResult2 = true; + } + return false; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "2" +}; + +Array.prototype.reduceRight.call(obj, callbackfn, 1); + +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-12.js new file mode 100644 index 0000000000..e6162bf757 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-12.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string + containing a negative number +---*/ + +var testResult1 = true; +var testResult2 = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + + if (idx === 1) { + testResult2 = true; + } + return false; +} + +var obj = { + 0: 11, + 1: 12, + 2: 9, + length: "-4294967294" +}; + +Array.prototype.reduceRight.call(obj, callbackfn, 1); + +assert(testResult1, 'testResult1 !== true'); +assert.sameValue(testResult2, false, 'testResult2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-13.js new file mode 100644 index 0000000000..7138726ceb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-13.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string + containing a decimal number +---*/ + +var testResult1 = true; +var testResult2 = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + + if (idx === 1) { + testResult2 = true; + } + return false; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "2.5" +}; + +Array.prototype.reduceRight.call(obj, callbackfn, 1); + +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-14.js new file mode 100644 index 0000000000..8653b74ac3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-14.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string + containing -Infinity +---*/ + +var accessed2 = false; + +function callbackfn2(prevVal, curVal, idx, obj) { + accessed2 = true; +} + +var obj2 = { + 0: 9, + length: "-Infinity" +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj2, callbackfn2, 2), 2, 'Array.prototype.reduceRight.call(obj2, callbackfn2, 2)'); +assert.sameValue(accessed2, false, 'accessed2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-15.js new file mode 100644 index 0000000000..02d1fc781f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-15.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string + containing an exponential number +---*/ + +var testResult1 = true; +var testResult2 = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + + if (idx === 1) { + testResult2 = true; + } + return false; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "2E0" +}; + +Array.prototype.reduceRight.call(obj, callbackfn, 1); + +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-16.js new file mode 100644 index 0000000000..0cf82b8dc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-16.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string + containing a hex number +---*/ + +var testResult1 = true; +var testResult2 = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + + if (idx === 1) { + testResult2 = true; + } + return false; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "0x0002" +}; + +Array.prototype.reduceRight.call(obj, callbackfn, 1); + +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-17.js new file mode 100644 index 0000000000..047e97796d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-17.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string + containing a number with leading zeros +---*/ + +var testResult1 = true; +var testResult2 = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + + if (idx === 1) { + testResult2 = true; + } + return false; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "0002.00" +}; + +Array.prototype.reduceRight.call(obj, callbackfn, 1); + +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-18.js new file mode 100644 index 0000000000..86e87cc3c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-18.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string that + can't convert to a number +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} + +var obj = { + 0: 9, + 1: 8, + length: "two" +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, 11), 11, 'Array.prototype.reduceRight.call(obj, callbackfn, 11)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-19.js new file mode 100644 index 0000000000..0ec7c0601e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-19.js @@ -0,0 +1,50 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is an object which + has an own toString method +---*/ + +var testResult1 = true; +var testResult2 = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + + if (idx === 1) { + testResult2 = true; + } + return false; +} + +var toStringAccessed = false; +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: { + toString: function() { + toStringAccessed = true; + return '2'; + } + } +}; + +// objects inherit the default valueOf() method from Object +// that simply returns itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. + +Array.prototype.reduceRight.call(obj, callbackfn, 1); + +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); +assert(toStringAccessed, 'toStringAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-2.js new file mode 100644 index 0000000000..a453b582b0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-2.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to an Array-like object, + 'length' is 0 (length overridden to false(type conversion)) +---*/ + +var accessed = false; + +function callbackfn(preVal, curVal, idx, obj) { + accessed = true; +} + +var obj = { + 0: 9, + length: false +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, 1), 1, 'Array.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-20.js new file mode 100644 index 0000000000..3d695cee0c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-20.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is an Object which + has an own valueOf method +---*/ + +var testResult1 = true; +var testResult2 = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + + if (idx === 1) { + testResult2 = true; + } + return false; +} + +var valueOfAccessed = false; + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: { + valueOf: function() { + valueOfAccessed = true; + return 2; + } + } +}; + +Array.prototype.reduceRight.call(obj, callbackfn, 1); + +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-21.js new file mode 100644 index 0000000000..87c240ee83 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-21.js @@ -0,0 +1,52 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - 'length' is an object that has an + own valueOf method that returns an object and toString method that + returns a string +---*/ + +var testResult1 = true; +var testResult2 = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + + if (idx === 1) { + testResult2 = true; + } + return false; +} + +var toStringAccessed = false; +var valueOfAccessed = false; + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: { + valueOf: function() { + valueOfAccessed = true; + return {}; + }, + toString: function() { + toStringAccessed = true; + return '2'; + } + } +}; + +Array.prototype.reduceRight.call(obj, callbackfn, 1); + +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert(toStringAccessed, 'toStringAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-22.js new file mode 100644 index 0000000000..aa05079f85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-22.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError exception when + 'length' is an object with toString and valueOf methods that don�t + return primitive values +---*/ + +var accessed = false; +var toStringAccessed = false; +var valueOfAccessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} + +var obj = { + 0: 11, + 1: 12, + + length: { + valueOf: function() { + valueOfAccessed = true; + return {}; + }, + toString: function() { + toStringAccessed = true; + return {}; + } + } +}; +assert.throws(TypeError, function() { + Array.prototype.reduceRight.call(obj, callbackfn, 1); +}); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-23.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-23.js new file mode 100644 index 0000000000..204dea1c09 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-23.js @@ -0,0 +1,57 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight uses inherited valueOf method when + 'length' is an object with an own toString and inherited valueOf + methods +---*/ + +var testResult1 = true; +var testResult2 = false; +var valueOfAccessed = false; +var toStringAccessed = false; + +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + + if (idx === 1) { + testResult2 = true; + } + return false; +} + +child.toString = function() { + toStringAccessed = true; + return '1'; +}; + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: child +}; + +Array.prototype.reduceRight.call(obj, callbackfn, 1); + +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-24.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-24.js new file mode 100644 index 0000000000..37b8be87ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-24.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +var testResult1 = true; +var testResult2 = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + + if (idx === 1) { + testResult2 = true; + } + return false; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2.685 +}; + +Array.prototype.reduceRight.call(obj, callbackfn, 1); + +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-25.js new file mode 100644 index 0000000000..75436008af --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-25.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a negative + non-integer +---*/ + +var testResult1 = true; +var testResult2 = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + + if (idx === 1) { + testResult2 = true; + } + return false; +} + +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: -4294967294.5 +}; + +Array.prototype.reduceRight.call(obj, callbackfn, 1); + +assert(testResult1, 'testResult1 !== true'); +assert.sameValue(testResult2, false, 'testResult2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-3.js new file mode 100644 index 0000000000..d7c809db8a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-3.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a number (value + is 0) +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} + +var obj = { + 0: 9, + length: 0 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, 1), 1, 'Array.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-4.js new file mode 100644 index 0000000000..bab110a9f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-4.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a number (value + is +0) +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} + +var obj = { + 0: 9, + length: +0 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, 1), 1, 'Array.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-5.js new file mode 100644 index 0000000000..432697a489 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-5.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a number (value + is -0) +---*/ + +var accessed = false; + +function callbackfn(preVal, curVal, idx, obj) { + accessed = true; +} + +var obj = { + 0: 9, + length: -0 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, 1), 1, 'Array.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-6.js new file mode 100644 index 0000000000..a2af8a433c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-6.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a number (value + is positive) +---*/ + +var testResult1 = true; +var testResult2 = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + + if (idx === 1) { + testResult2 = true; + } + return false; +} + +var obj = { + 1: 11, + 2: 9, + length: 2 +}; + +Array.prototype.reduceRight.call(obj, callbackfn, 1); + +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-7.js new file mode 100644 index 0000000000..4b970f249d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-7.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a number (value + is negative) +---*/ + +var testResult1 = true; +var testResult2 = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + + if (idx === 1) { + testResult2 = true; + } + return false; +} + +var obj = { + 1: 11, + 2: 9, + length: -4294967294 +}; + +Array.prototype.reduceRight.call(obj, callbackfn, 1); + +assert(testResult1, 'testResult1 !== true'); +assert.sameValue(testResult2, false, 'testResult2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-9.js new file mode 100644 index 0000000000..6ffe23eb95 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-3-9.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a number (value + is -Infinity) +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} + +var obj = { + 0: 9, + length: -Infinity +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, 1), 1, 'Array.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-1.js new file mode 100644 index 0000000000..b7d5adfa00 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-1.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if callbackfn is + undefined +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.reduceRight(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-10.js new file mode 100644 index 0000000000..61327dcc6f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-10.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the exception is not thrown if + exception was thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.reduceRight.call(obj, undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-11.js new file mode 100644 index 0000000000..e7b0271061 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-11.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the exception is not thrown if + exception was thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.reduceRight.call(obj, undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-12.js new file mode 100644 index 0000000000..341f626254 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-12.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - 'callbackfn' is a function +---*/ + +var initialValue = 0; + +function callbackfn(accum, val, idx, obj) { + accum += val; + return accum; +} + +assert.sameValue([11, 9].reduceRight(callbackfn, initialValue), 20, '[11, 9].reduceRight(callbackfn, initialValue)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-15.js new file mode 100644 index 0000000000..d5a7ace182 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-15.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - calling with no callbackfn is the + same as passing undefined for callbackfn +---*/ + +var obj = { + 10: 10 +}; +var lengthAccessed = false; +var loopAccessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + lengthAccessed = true; + return 20; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + loopAccessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.reduceRight.call(obj, undefined); +}); +assert(lengthAccessed, 'lengthAccessed !== true'); +assert.sameValue(loopAccessed, false, 'loopAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-2.js new file mode 100644 index 0000000000..7b54f582a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-2.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws ReferenceError if callbackfn is + unreferenced +---*/ + +var arr = new Array(10); +assert.throws(ReferenceError, function() { + arr.reduceRight(foo); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-3.js new file mode 100644 index 0000000000..d8a0c1c694 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-3.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight throws TypeError if callbackfn is null +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.reduceRight(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-4.js new file mode 100644 index 0000000000..10db83a146 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-4.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if callbackfn is + boolean +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.reduceRight(true); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-5.js new file mode 100644 index 0000000000..37e336c570 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-5.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if callbackfn is + number +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.reduceRight(5); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-6.js new file mode 100644 index 0000000000..f778d63df1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-6.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if callbackfn is + string +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.reduceRight("abc"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-7.js new file mode 100644 index 0000000000..2bc4dab198 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-7.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if callbackfn is + Object without [[Call]] internal method +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.reduceRight(new Object()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-8.js new file mode 100644 index 0000000000..25f395572d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-8.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.reduceRight.call(obj, null); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-9.js new file mode 100644 index 0000000000..d04effce90 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-4-9.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.reduceRight.call(obj, null); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-1.js new file mode 100644 index 0000000000..a0ae5e668a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-1.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (empty array), no initVal +---*/ + +function cb() {} +assert.throws(TypeError, function() { + [].reduceRight(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-10.js new file mode 100644 index 0000000000..ccd326be93 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-10.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - side-effects produced by step 2 when + an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 0; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.reduceRight.call(obj, function() {}); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-11.js new file mode 100644 index 0000000000..bf27af3453 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-11.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - side-effects produced by step 3 when + an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "0"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.reduceRight.call(obj, function() {}); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-12.js new file mode 100644 index 0000000000..d839266b6f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-12.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the exception is not thrown if + exception was thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.reduceRight.call(obj, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-13.js new file mode 100644 index 0000000000..5b87a6363e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-13.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the exception is not thrown if + exception was thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.reduceRight.call(obj, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-2.js new file mode 100644 index 0000000000..8aae3aef48 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-2.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (subclassed Array, length overridden to null (type conversion)), + no initVal +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = null; + +function cb() {} +assert.throws(TypeError, function() { + f.reduceRight(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-3.js new file mode 100644 index 0000000000..ace1c67616 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-3.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (subclassed Array, length overridden to false (type conversion)), + no initVal +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = false; + +function cb() {} +assert.throws(TypeError, function() { + f.reduceRight(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-4.js new file mode 100644 index 0000000000..b63b28ac44 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-4.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (subclassed Array, length overridden to 0 (type conversion)), no + initVal +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 0; + +function cb() {} +assert.throws(TypeError, function() { + f.reduceRight(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-5.js new file mode 100644 index 0000000000..dad1c9abf1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-5.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (subclassed Array, length overridden to '0' (type conversion)), no + initVal +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = '0'; + +function cb() {} +assert.throws(TypeError, function() { + f.reduceRight(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-6.js new file mode 100644 index 0000000000..becfb0d732 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-6.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (subclassed Array, length overridden with obj with valueOf), no + initVal +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; + +function cb() {} +assert.throws(TypeError, function() { + f.reduceRight(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-7.js new file mode 100644 index 0000000000..80b9595899 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-7.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (subclassed Array, length overridden with obj w/o valueOf + (toString)), no initVal +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. + +function cb() {} +assert.throws(TypeError, function() { + f.reduceRight(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-8.js new file mode 100644 index 0000000000..91a471070e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-8.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (subclassed Array, length overridden with []), no initVal +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +f.length = []; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. + +function cb() {} +assert.throws(TypeError, function() { + f.reduceRight(cb); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-9.js new file mode 100644 index 0000000000..4cb8f44197 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-5-9.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - 'initialValue' is returned if 'len' + is 0 and 'initialValue' is present +---*/ + +var initialValue = 10; + +assert.sameValue([].reduceRight(function() {}, initialValue), initialValue, '[].reduceRight(function () { }, initialValue)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-1.js new file mode 100644 index 0000000000..7d55035484 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (empty array) +---*/ + +function cb() {} +assert.sameValue([].reduceRight(cb, 1), 1, '[].reduceRight(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-10.js new file mode 100644 index 0000000000..10cd502700 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-10.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - 'initialValue' is present +---*/ + +var str = "initialValue is present"; + +assert.sameValue([].reduceRight(function() {}, str), str, '[].reduceRight(function () { }, str)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-11.js new file mode 100644 index 0000000000..d80d9ae212 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-11.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - 'initialValue' is not present +---*/ + +var str = "initialValue is not present"; + +assert.sameValue([str].reduceRight(function() {}), str, '[str].reduceRight(function () { })'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-2.js new file mode 100644 index 0000000000..f1e13bba46 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-2.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + to null (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = null; + +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-3.js new file mode 100644 index 0000000000..8f6ee65bd9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-3.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + to false (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = false; + +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-4.js new file mode 100644 index 0000000000..152016a8ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-4.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + to 0 (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 0; + +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-5.js new file mode 100644 index 0000000000..72ccb1ceec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-5.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + to '0' (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = '0'; + +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-6.js new file mode 100644 index 0000000000..98a4dcdf32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-6.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + with obj with valueOf) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; + +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-7.js new file mode 100644 index 0000000000..07c449a76f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-7.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + with obj w/o valueOf (toString)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. + +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-8.js new file mode 100644 index 0000000000..6ec5e26cb7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-8.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + with []) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +f.length = []; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. + +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-9.js new file mode 100644 index 0000000000..78ff13ba5b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-7-9.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + with [0]) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +f.length = [0]; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. + +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-1.js new file mode 100644 index 0000000000..c75994b87b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-1.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - no observable effects occur if 'len' + is 0 +---*/ + +var accessed = false; + +var obj = { + length: 0 +}; + +Object.defineProperty(obj, "0", { + get: function() { + accessed = true; + return 10; + }, + configurable: true +}); + +assert.throws(TypeError, function() { + Array.prototype.reduceRight.call(obj, function() {}); +}); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-2.js new file mode 100644 index 0000000000..4c86d36955 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-2.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - modifications to length don't change + number of iterations in step 9 +---*/ + +var called = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + called++; + return prevVal + curVal; +} + +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "4", { + get: function() { + arr.length = 2; + return 10; + }, + configurable: true +}); + +var preVal = arr.reduceRight(callbackfn); + +assert.sameValue(preVal, 11, 'preVal'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-3.js new file mode 100644 index 0000000000..02938e970d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-3.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - while loop is breaken once + 'kPresent' is true +---*/ + +var called = 0; +var testResult = false; +var firstCalled = 0; +var secondCalled = 0; + +function callbackfn(prevVal, val, idx, obj) { + if (called === 0) { + testResult = (idx === 1); + } + called++; +} + +var arr = [, , , ]; + +Object.defineProperty(arr, "1", { + get: function() { + firstCalled++; + return 9; + }, + configurable: true +}); + +Object.defineProperty(arr, "2", { + get: function() { + secondCalled++; + return 11; + }, + configurable: true +}); + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); +assert.sameValue(firstCalled, 1, 'firstCalled'); +assert.sameValue(secondCalled, 1, 'secondCalled'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-1.js new file mode 100644 index 0000000000..1b8dbe9ea0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-1.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - added properties in step 2 are + visible here +---*/ + +var obj = {}; + +function callbackfn(prevVal, curVal, idx, obj) {} + +Object.defineProperty(obj, "length", { + get: function() { + obj[2] = "accumulator"; + return 3; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn), "accumulator", 'Array.prototype.reduceRight.call(obj, callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-2.js new file mode 100644 index 0000000000..acdaba679b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-2.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleted properties in step 2 are + visible here +---*/ + +var obj = { + 2: "accumulator", + 3: "another" +}; + +Object.defineProperty(obj, "length", { + get: function() { + delete obj[2]; + return 5; + }, + configurable: true +}); + +assert.notSameValue(Array.prototype.reduceRight.call(obj, function() {}), "accumulator", 'Array.prototype.reduceRight.call(obj, function () { })'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-1.js new file mode 100644 index 0000000000..3a0f4403f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0) { + testResult = (prevVal === 1); + } +} + +var obj = { + 0: 0, + 1: 1, + length: 2 +}; + +Array.prototype.reduceRight.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-10.js new file mode 100644 index 0000000000..a2c8b2305b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-10.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2) { + testResult = (curVal === 2); + } +} + +var arr = [0, 1, , 3]; + +Object.defineProperty(arr, "2", { + get: function() { + return 2; + }, + configurable: true +}); + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-11.js new file mode 100644 index 0000000000..a95f83a521 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-11.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "20"); + } +} + +var proto = { + 0: 0, + 1: 1, + 2: 2 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Object.defineProperty(child, "2", { + get: function() { + return "20"; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-12.js new file mode 100644 index 0000000000..4abd152d2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-12.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited data property on an + Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "20"); + } +} + +Array.prototype[2] = 2; +var arr = [0, 1]; + +Object.defineProperty(arr, "2", { + get: function() { + return "20"; + }, + configurable: true +}); + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-13.js new file mode 100644 index 0000000000..c3fc91080f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-13.js @@ -0,0 +1,49 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited accessor property on + an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "20"); + } +} + +var proto = { + 0: 0, + 1: 1 +}; + +Object.defineProperty(proto, "2", { + get: function() { + return 2; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Object.defineProperty(child, "2", { + get: function() { + return "20"; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-14.js new file mode 100644 index 0000000000..bef4e99259 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-14.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited accessor property on + an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "20"); + } +} + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return 2; + }, + configurable: true +}); + +var arr = [0, 1, , ]; + +Object.defineProperty(arr, "2", { + get: function() { + return "20"; + }, + configurable: true +}); + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-15.js new file mode 100644 index 0000000000..9c075857d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-15.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} + +var proto = { + 0: 0, + 1: 1 +}; + +Object.defineProperty(proto, "2", { + get: function() { + return 2; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Array.prototype.reduceRight.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-16.js new file mode 100644 index 0000000000..f4832f6dc8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-16.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return 2; + }, + configurable: true +}); + +var arr = [0, 1, , ]; + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-17.js new file mode 100644 index 0000000000..3237cbc95b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-17.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof prevVal === "undefined"); + } +} + +var obj = { + 0: 0, + 1: 1, + length: 3 +}; + +Object.defineProperty(obj, "2", { + set: function() {}, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-18.js new file mode 100644 index 0000000000..759835c769 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-18.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof prevVal === "undefined"); + } +} + +var arr = [0, 1]; + +Object.defineProperty(arr, "2", { + set: function() {}, + configurable: true +}); + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-19.js new file mode 100644 index 0000000000..65884de5d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-19.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function that overrides an + inherited accessor property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof prevVal === "undefined"); + } +} + +Object.prototype[2] = 2; + +var obj = { + 0: 0, + 1: 1, + length: 3 +}; +Object.defineProperty(obj, "2", { + set: function() {}, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-2.js new file mode 100644 index 0000000000..9579161a0a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-2.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} + +var arr = [0, 1, 2]; + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-20.js new file mode 100644 index 0000000000..cb22e630d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-20.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function that overrides an + inherited accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof prevVal === "undefined"); + } +} + +Array.prototype[2] = 2; +var arr = [0, 1]; +Object.defineProperty(arr, "2", { + set: function() {}, + configurable: true +}); + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-21.js new file mode 100644 index 0000000000..b210b8150b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-21.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof prevVal === "undefined"); + } +} + +var proto = { + 0: 0, + 1: 1 +}; + +Object.defineProperty(proto, "2", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Array.prototype.reduceRight.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-22.js new file mode 100644 index 0000000000..5083b26b3d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-22.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof prevVal === "undefined"); + } +} + +Object.defineProperty(Array.prototype, "2", { + set: function() {}, + configurable: true +}); + +var arr = [0, 1, , ]; + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-25.js new file mode 100644 index 0000000000..287c583b63 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-25.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - This object is the Arguments object + which implements its own property get method (number of arguments + is less than number of parameters) +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0) { + testResult = (prevVal === 1); + } +} + +var func = function(a, b, c) { + Array.prototype.reduceRight.call(arguments, callbackfn); +}; + +func(0, 1); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-26.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-26.js new file mode 100644 index 0000000000..49bbbd0904 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-26.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - This object is the Arguments object + which implements its own property get method (number of arguments + equals number of parameters) +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} + +var func = function(a, b, c) { + Array.prototype.reduceRight.call(arguments, callbackfn); +}; + +func(0, 1, 2); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-27.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-27.js new file mode 100644 index 0000000000..fe4f76a02a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-27.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - This object is the Arguments object + which implements its own property get method (number of arguments + is greater than number of parameters) +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2) { + testResult = (prevVal === 3); + } +} + +var func = function(a, b, c) { + Array.prototype.reduceRight.call(arguments, callbackfn); +}; + +func(0, 1, 2, 3); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-28.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-28.js new file mode 100644 index 0000000000..2b7cf16f5e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-28.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to String object, which + implements its own property get method +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "2"); + } +} + +var str = new String("012"); + +Array.prototype.reduceRight.call(str, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-29.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-29.js new file mode 100644 index 0000000000..fabc9b3af4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-29.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Function object which + implements its own property get method +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} + +var obj = function(a, b, c) { + return a + b + c; +}; + +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; + +Array.prototype.reduceRight.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-3.js new file mode 100644 index 0000000000..145ded49ac --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-3.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "20"); + } +} + +var proto = { + 0: 0, + 1: 1, + 2: 2, + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[1] = "10"; +child[2] = "20"; +child.length = 3; + +Array.prototype.reduceRight.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-30.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-30.js new file mode 100644 index 0000000000..c8303131c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-30.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element changed by getter on current + iteration is observed in subsequent iterations on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1 && prevVal === 2); + } +} + +var arr = [0]; +var preIterVisible = false; + +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return "20"; + } + }, + configurable: true +}); + +Object.defineProperty(arr, "2", { + get: function() { + preIterVisible = true; + return 2; + }, + configurable: true +}); + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-31.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-31.js new file mode 100644 index 0000000000..252e156541 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-31.js @@ -0,0 +1,48 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element changed by getter on current + iteration is observed subsequetly on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2 && curVal === 1); + } +} + +var obj = { + 0: 0, + length: 3 +}; +var preIterVisible = false; + +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return "20"; + } + }, + configurable: true +}); + +Object.defineProperty(obj, "2", { + get: function() { + preIterVisible = true; + return 2; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-32.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-32.js new file mode 100644 index 0000000000..447a5efe57 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-32.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Exception in getter terminate + iteration on an Array-like object +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx <= 1) { + accessed = true; + } +} + +var obj = { + 0: 0, + 1: 1, + length: 3 +}; +Object.defineProperty(obj, "2", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + Array.prototype.reduceRight.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-33.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-33.js new file mode 100644 index 0000000000..4c1b16e59f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-33.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Exception in getter terminate + iteration on an Array +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx <= 1) { + accessed = true; + } +} + +var arr = [0, 1]; + +Object.defineProperty(arr, "2", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.reduceRight(callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-4.js new file mode 100644 index 0000000000..ad0869c841 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-4.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} + +Array.prototype[2] = "11"; +[0, 1, 2].reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-5.js new file mode 100644 index 0000000000..76abd845ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-5.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "20"); + } +} + +var proto = {}; + +Object.defineProperty(proto, "2", { + get: function() { + return 11; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; +child[0] = "0"; +child[1] = "1"; +Object.defineProperty(proto, "2", { + value: "20", + configurable: true +}); + +Array.prototype.reduceRight.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-6.js new file mode 100644 index 0000000000..05f13e7c6b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-6.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return "2"; + }, + configurable: true +}); +[0, 1, 2].reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-7.js new file mode 100644 index 0000000000..e54b80fd1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-7.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + data property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} + +var proto = { + 0: 0, + 1: 1, + 2: 2, + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Array.prototype.reduceRight.call(child, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-8.js new file mode 100644 index 0000000000..e4931296db --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-8.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + data property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} + +Array.prototype[0] = 0; +Array.prototype[1] = 1; +Array.prototype[2] = 2; +[, , , ].reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-9.js new file mode 100644 index 0000000000..a4cae86ed3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-9.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} + +var obj = { + 0: 0, + 1: 1, + length: 3 +}; +Object.defineProperty(obj, "2", { + get: function() { + return 2; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-1.js new file mode 100644 index 0000000000..9a53144651 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-1.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError when Array is empty + and initialValue is not present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.reduceRight(callbackfn); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-2.js new file mode 100644 index 0000000000..108fbe48c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-2.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError when elements + assigned values are deleted by reducign array length and + initialValue is not present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} + +var arr = new Array(10); +arr[9] = 1; +arr.length = 5; +assert.throws(TypeError, function() { + arr.reduceRight(callbackfn); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-3.js new file mode 100644 index 0000000000..00cecb0f17 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError when elements + assigned values are deleted and initialValue is not present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} + +var arr = [1, 2, 3, 4, 5]; +delete arr[0]; +delete arr[1]; +delete arr[2]; +delete arr[3]; +delete arr[4]; +assert.throws(TypeError, function() { + arr.reduceRight(callbackfn); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-4.js new file mode 100644 index 0000000000..60e70d312a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-4.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight doesn't throw error when array has no + own properties but prototype contains a single property +---*/ + +var arr = [, , , ]; + +try { + Array.prototype[1] = "prototype"; + arr.reduceRight(function() {}); +} finally { + delete Array.prototype[1]; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-5.js new file mode 100644 index 0000000000..c7d70f4779 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-5.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var obj = {}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.reduceRight.call(obj, function() {}); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-6.js new file mode 100644 index 0000000000..0458cfa96a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-6.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var obj = {}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.reduceRight.call(obj, function() {}); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-7.js new file mode 100644 index 0000000000..125317592b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-7.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the exception is not thrown if + exception was thrown by step 2 +---*/ + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.reduceRight.call(obj, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-8.js new file mode 100644 index 0000000000..c3900adf69 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-8.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the exception is not thrown if + exception was thrown by step 3 +---*/ + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.reduceRight.call(obj, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-1.js new file mode 100644 index 0000000000..87cd27ba3b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-1.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight doesn't consider new elements which + index is larger than array original length added to array after it + is called, consider new elements which index is smaller than array + length +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + arr[5] = 6; + arr[2] = 3; + return prevVal + curVal; +} + +var arr = ['1', 2, , 4, '5']; + +assert.sameValue(arr.reduceRight(callbackfn), "54321", 'arr.reduceRight(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-2.js new file mode 100644 index 0000000000..b7c0d68c0f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-2.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight considers new value of elements in + array after it is called +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + arr[3] = -2; + arr[0] = -1; + return prevVal + curVal; +} + +var arr = [1, 2, 3, 4, 5]; + +assert.sameValue(arr.reduceRight(callbackfn), 13, 'arr.reduceRight(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-3.js new file mode 100644 index 0000000000..65d3b1cdc9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-3.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight doesn't consider unvisited deleted + elements in array after the call +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + delete arr[1]; + delete arr[4]; + return prevVal + curVal; +} + +var arr = ['1', 2, 3, 4, 5]; + +// two elements deleted +assert.sameValue(arr.reduceRight(callbackfn), "121", 'arr.reduceRight(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-4.js new file mode 100644 index 0000000000..6d3a05647c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-4.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight doesn't consider unvisited deleted + elements when Array.length is decreased +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + arr.length = 2; + return prevVal + curVal; +} + +var arr = [1, 2, 3, 4, 5]; + +assert.sameValue(arr.reduceRight(callbackfn), 12, 'arr.reduceRight(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-5.js new file mode 100644 index 0000000000..f1dc9f700f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-5.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn not called for array with + one element +---*/ + +var callCnt = 0; + +function callbackfn(prevVal, curVal, idx, obj) +{ + callCnt++; + return 2; +} + +var arr = [1]; + +assert.sameValue(arr.reduceRight(callbackfn), 1, 'arr.reduceRight(callbackfn)'); +assert.sameValue(callCnt, 0, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-6.js new file mode 100644 index 0000000000..2e9479fca9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-6.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight visits deleted element in array after + the call when same index is also present in prototype +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + delete arr[1]; + delete arr[2]; + return prevVal + curVal; +} +Array.prototype[2] = 6; +var arr = ['1', 2, 3, 4, 5]; +var res = arr.reduceRight(callbackfn); +delete Array.prototype[2]; + +//one element deleted +assert.sameValue(res, "151", 'res'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-7.js new file mode 100644 index 0000000000..c91ad96b3b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-7.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight not affect call when the array is + deleted during the call +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + delete o.arr; + return prevVal + curVal; +} + +var o = new Object(); +o.arr = ['1', 2, 3, 4, 5]; + +assert.sameValue(o.arr.reduceRight(callbackfn), "141", 'o.arr.reduceRight(callbackfn)'); +assert.sameValue(o.hasOwnProperty("arr"), false, 'o.hasOwnProperty("arr")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-8.js new file mode 100644 index 0000000000..6ff99c27d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-8.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - no observable effects occur if 'len' + is 0 +---*/ + +var accessed = false; +var callbackAccessed = false; + +function callbackfn() { + callbackAccessed = true; +} + +var obj = { + length: 0 +}; + +Object.defineProperty(obj, "5", { + get: function() { + accessed = true; + return 10; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); + +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(callbackAccessed, false, 'callbackAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-9.js new file mode 100644 index 0000000000..48c4cb806f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-9.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - modifications to length will change + number of iterations +---*/ + +var called = 0; + +function callbackfn(preVal, val, idx, obj) { + called++; +} + +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "4", { + get: function() { + arr.length = 2; + }, + configurable: true +}); + +arr.reduceRight(callbackfn, "initialValue"); + +assert.sameValue(called, 3, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-1.js new file mode 100644 index 0000000000..bb70adf44d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-1.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialvalue when Array is + empty and initialValue is not present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} + +var arr = new Array(10); + + +assert.sameValue(arr.reduceRight(callbackfn, 5), 5, 'arr.reduceRight(callbackfn,5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-10.js new file mode 100644 index 0000000000..f31a22a337 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-10.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting property of prototype in + step 8 causes deleted index property not to be visited on an + Array-like Object +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(preVal, val, idx, obj) { + accessed = true; + if (idx === 3) { + testResult = false; + } +} + +var obj = { + 2: 2, + length: 20 +}; + +Object.defineProperty(obj, "5", { + get: function() { + delete Object.prototype[3]; + return 0; + }, + configurable: true +}); + +Object.prototype[3] = 1; +Array.prototype.reduceRight.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-11.js new file mode 100644 index 0000000000..aaa374d024 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-11.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting property of prototype in + step 8 causes deleted index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var arr = [0, , , ]; +Object.defineProperty(arr, "3", { + get: function() { + delete Array.prototype[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-12.js new file mode 100644 index 0000000000..3e0cc96e44 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-12.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property with prototype + property in step 8 causes prototype index property to be visited + on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1 && curVal === 1) { + testResult = true; + } +} + +var obj = { + 0: 0, + 1: 111, + length: 10 +}; + +Object.defineProperty(obj, "4", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; +Array.prototype.reduceRight.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-13.js new file mode 100644 index 0000000000..372cc99ec1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-13.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property with prototype + property in step 8 causes prototype index property to be visited + on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1 && curVal === 1) { + testResult = true; + } +} +var arr = [0, 111]; + +Object.defineProperty(arr, "2", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-14.js new file mode 100644 index 0000000000..1c7c8834e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-14.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - decreasing length of array in step 8 + causes deleted index property not to be visited +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 2) { + testResult = false; + } +} + +var arr = [0, 1, 2, 3]; + +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 0; + }, + configurable: true +}); + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-15.js new file mode 100644 index 0000000000..fd482cbc21 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-15.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - decreasing length of array with + prototype property in step 8 causes prototype index property to be + visited +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2 && curVal === "prototype") { + testResult = true; + } +} +var arr = [0, 1, 2, 3]; + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); + +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-16.js new file mode 100644 index 0000000000..e00cdef991 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-16.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - decreasing length of array in step 8 + does not delete non-configurable properties +flags: [noStrict] +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2 && curVal === "unconfigurable") { + testResult = true; + } +} + +var arr = [0, 1, 2, 3]; + +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); + +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-17.js new file mode 100644 index 0000000000..4dc8fd611b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-17.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added into own object are + visited on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0 && curVal === 0) { + testResult = true; + } +} + +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "1", { + get: function() { + Object.defineProperty(obj, "0", { + get: function() { + return 0; + }, + configurable: true + }); + return 1; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-18.js new file mode 100644 index 0000000000..a9ccb43bfd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-18.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added into own object are + visited on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1 && curVal === 1) { + testResult = true; + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "2", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-19.js new file mode 100644 index 0000000000..f21ff313b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-19.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added to prototype are + visited on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1 && curVal === 6.99) { + testResult = true; + } +} + +var obj = { + length: 6 +}; + +Object.defineProperty(obj, "2", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-2.js new file mode 100644 index 0000000000..f68ffddfa9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-2.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - added properties in step 2 are + visible here +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2 && curVal === "2") { + testResult = true; + } +} + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + obj[2] = "2"; + return 3; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-20.js new file mode 100644 index 0000000000..6a512f0663 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-20.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added to prototype can be + visited on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1 && curVal === 6.99) { + testResult = true; + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "2", { + get: function() { + Object.defineProperty(Array.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-21.js new file mode 100644 index 0000000000..f99e17432d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-21.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property causes deleted + index property not to be visited on an Array-like object +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var obj = { + 0: 10, + length: 10 +}; + +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); + +Object.defineProperty(obj, "5", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-22.js new file mode 100644 index 0000000000..f329d8731d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-22.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property causes deleted + index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var arr = [1, 2, 4]; + +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); + +Object.defineProperty(arr, "2", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-23.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-23.js new file mode 100644 index 0000000000..b68b324509 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-23.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting property of prototype + causes deleted index property not to be visited on an Array-like + Object +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 3) { + testResult = false; + } +} + +var obj = { + 2: 2, + length: 20 +}; + +Object.defineProperty(obj, "5", { + get: function() { + delete Object.prototype[3]; + return 0; + }, + configurable: true +}); + +Object.prototype[3] = 1; +Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-24.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-24.js new file mode 100644 index 0000000000..c3a23e9f08 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-24.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting property of prototype + causes deleted index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var arr = [0, , , ]; +Object.defineProperty(arr, "3", { + get: function() { + delete Array.prototype[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-25.js new file mode 100644 index 0000000000..cf1e1bf9c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-25.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1 && curVal === 1) { + testResult = true; + } +} + +var obj = { + 0: 0, + 1: 111, + 4: 10, + length: 10 +}; + +Object.defineProperty(obj, "4", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; +Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-26.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-26.js new file mode 100644 index 0000000000..7e1626c7aa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-26.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1 && curVal === 1) { + testResult = true; + } +} +var arr = [0, 111]; + +Object.defineProperty(arr, "2", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-27.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-27.js new file mode 100644 index 0000000000..e6434ff55f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-27.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - decreasing length of array causes + deleted index property not to be visited +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 2) { + testResult = false; + } +} + +var arr = [0, 1, 2, 3]; + +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 0; + }, + configurable: true +}); + +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-28.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-28.js new file mode 100644 index 0000000000..d79bed6b88 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-28.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - decreasing length of array with + prototype property causes prototype index property to be visited +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2 && curVal === "prototype") { + testResult = true; + } +} +var arr = [0, 1, 2, 3]; + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); + +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-29.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-29.js new file mode 100644 index 0000000000..d90a6cfde6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-29.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - decreasing length of array does not + delete non-configurable properties +flags: [noStrict] +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2 && curVal === "unconfigurable") { + testResult = true; + } +} + +var arr = [0, 1, 2, 3]; + +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); + +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-3.js new file mode 100644 index 0000000000..b67f066a9d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-3.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleted properties in step 2 are + visible here +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(preVal, curVal, idx, obj) { + accessed = true; + if (idx === 2) { + testResult = false; + } +} + +var obj = { + 2: "2", + 3: 10 +}; + +Object.defineProperty(obj, "length", { + get: function() { + delete obj[2]; + return 5; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); + +assert(accessed, 'accessed !== true'); +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-4.js new file mode 100644 index 0000000000..78a6b4c2ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-4.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added into own object in + step 8 can be visited on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(preVal, curVal, idx, obj) { + if (idx === 0 && curVal === 0) { + testResult = true; + } +} + +var obj = { + length: 2 +}; + +Object.defineProperty(obj, "1", { + get: function() { + Object.defineProperty(obj, "0", { + get: function() { + return 0; + }, + configurable: true + }); + return 1; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-5.js new file mode 100644 index 0000000000..d86d7f4821 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-5.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added into own object in + step 8 can be visited on an Array +---*/ + +var testResult = false; + +function callbackfn(preVal, curVal, idx, obj) { + if (idx === 1 && curVal === 1) { + testResult = true; + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "2", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-6.js new file mode 100644 index 0000000000..bf88884835 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-6.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added to prototype in + step 8 visited on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(preVal, curVal, idx, obj) { + if (idx === 1 && curVal === 6.99) { + testResult = true; + } +} + +var obj = { + length: 6 +}; + +Object.defineProperty(obj, "2", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-7.js new file mode 100644 index 0000000000..a660fc411e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-7.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added to prototype in + step 8 visited on an Array +---*/ + +var testResult = false; + +function callbackfn(preVal, curVal, idx, obj) { + if (idx === 1 && curVal === 6.99) { + testResult = true; + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "2", { + get: function() { + Object.defineProperty(Array.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-8.js new file mode 100644 index 0000000000..7b14c28e20 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-8.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property in step 8 + causes deleted index property not to be visited on an Array-like + object +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(preVal, val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var obj = { + 0: 10, + length: 10 +}; + +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); + +Object.defineProperty(obj, "5", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-9.js new file mode 100644 index 0000000000..ee7a758b92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-9.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property in step 8 + causes deleted index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; + +function callbackfn(preVal, curVal, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} + +var arr = [0]; + +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); + +Object.defineProperty(arr, "2", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-1.js new file mode 100644 index 0000000000..dedae5359e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-1.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn not called for indexes + never been assigned values +---*/ + +var callCnt = 0; + +function callbackfn(prevVal, curVal, idx, obj) +{ + callCnt++; + return curVal; +} + +var arr = new Array(10); +arr[0] = arr[1] = undefined; //explicitly assigning a value + +assert.sameValue(arr.reduceRight(callbackfn), undefined, 'arr.reduceRight(callbackfn)'); +assert.sameValue(callCnt, 1, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-1.js new file mode 100644 index 0000000000..6a6f41de5c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0) { + testResult = (curVal === 0); + } +} + +var obj = { + 0: 0, + 1: 1, + 2: 2, + length: 2 +}; +Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-10.js new file mode 100644 index 0000000000..366358b9fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-10.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-11.js new file mode 100644 index 0000000000..e47c9fe125 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-11.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "1"); + } +} + +var proto = { + 0: 0, + 1: 11, + 2: 2 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Object.defineProperty(child, "1", { + get: function() { + return "1"; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(child, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-12.js new file mode 100644 index 0000000000..116ee8e9b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-12.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited data property on an + Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "1"); + } +} + +Array.prototype[1] = 11; +var arr = [0, , 2]; + +Object.defineProperty(arr, "1", { + get: function() { + return "1"; + }, + configurable: true +}); + +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-13.js new file mode 100644 index 0000000000..2627936945 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-13.js @@ -0,0 +1,49 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited accessor property on + an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "1"); + } +} + +var proto = { + 0: 0, + 2: 2 +}; + +Object.defineProperty(proto, "1", { + get: function() { + return 11; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Object.defineProperty(child, "1", { + get: function() { + return "1"; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(child, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-14.js new file mode 100644 index 0000000000..5399501a79 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-14.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited accessor property on + an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "1"); + } +} + +Object.defineProperty(Array.prototype, "1", { + get: function() { + return 11; + }, + configurable: true +}); + +var arr = [0, , 2]; + +Object.defineProperty(arr, "1", { + get: function() { + return "1"; + }, + configurable: true +}); +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-15.js new file mode 100644 index 0000000000..2a3000a8f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-15.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var proto = { + 0: 0, + 2: 2 +}; + +Object.defineProperty(proto, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Array.prototype.reduceRight.call(child, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-16.js new file mode 100644 index 0000000000..f26e6e7394 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-16.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +Object.defineProperty(Array.prototype, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +var arr = [0, , 2]; + +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-17.js new file mode 100644 index 0000000000..c444fe34b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-17.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof curVal === "undefined"); + } +} + +var obj = { + 0: 0, + 2: 2, + length: 3 +}; + +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-18.js new file mode 100644 index 0000000000..ce4fc77c5e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-18.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof curVal === "undefined"); + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "1", { + set: function() {}, + configurable: true +}); + +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-19.js new file mode 100644 index 0000000000..416c2c5954 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-19.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function that overrides an + inherited accessor property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof curVal === "undefined"); + } +} + +Object.prototype[1] = 1; + +var obj = { + 0: 0, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-2.js new file mode 100644 index 0000000000..111a399ce1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-2.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var arr = [0, 1, 2]; +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-20.js new file mode 100644 index 0000000000..31a31547ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-20.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function that overrides an + inherited accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof curVal === "undefined"); + } +} + +Array.prototype[1] = 1; +var arr = [0, , 2]; +Object.defineProperty(arr, "1", { + set: function() {}, + configurable: true +}); + +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-21.js new file mode 100644 index 0000000000..9b7bb4156e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-21.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof curVal === "undefined"); + } +} + +var proto = { + 0: 0, + 2: 2 +}; + +Object.defineProperty(proto, "1", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Array.prototype.reduceRight.call(child, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-22.js new file mode 100644 index 0000000000..56e6e555ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-22.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof curVal === "undefined"); + } +} + +Object.defineProperty(Array.prototype, "1", { + set: function() {}, + configurable: true +}); + +var arr = [0, , 2]; + +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-25.js new file mode 100644 index 0000000000..ee8229e01a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-25.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - This object is the Arguments object + which implements its own property get method (number of arguments + is less than number of parameters) +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var func = function(a, b, c) { + Array.prototype.reduceRight.call(arguments, callbackfn, "initialValue"); +}; + +func(0, 1); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-26.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-26.js new file mode 100644 index 0000000000..3c09c62954 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-26.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - This object is the Arguments object + which implements its own property get method (number of arguments + equals number of parameters) +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2) { + testResult = (curVal === 2); + } +} + +var func = function(a, b, c) { + Array.prototype.reduceRight.call(arguments, callbackfn, "initialValue"); +}; + +func(0, 1, 2); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-27.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-27.js new file mode 100644 index 0000000000..e40ea92104 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-27.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - This object is the Arguments object + which implements its own property get method (number of arguments + is greater than number of parameters) +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 3) { + testResult = (curVal === 3); + } +} + +var func = function(a, b, c) { + Array.prototype.reduceRight.call(arguments, callbackfn, "initialValue"); +}; + +func(0, 1, 2, 3); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-28.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-28.js new file mode 100644 index 0000000000..731d345e51 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-28.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to String object, which + implements its own property get method +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "1"); + } +} + +var str = new String("012"); +Array.prototype.reduceRight.call(str, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-29.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-29.js new file mode 100644 index 0000000000..efbfb7b503 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-29.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Function object which + implements its own property get method +---*/ + +var testResult = false; +var initialValue = 0; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var obj = function(a, b, c) { + return a + b + c; +}; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; + +Array.prototype.reduceRight.call(obj, callbackfn, initialValue); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-3.js new file mode 100644 index 0000000000..7328d4f716 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-3.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "1"); + } +} + +var proto = { + 0: 10, + 1: 11, + 2: 12, + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[1] = "1"; +child[2] = "2"; +child.length = 3; + +Array.prototype.reduceRight.call(child, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-30.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-30.js new file mode 100644 index 0000000000..2a6cc75418 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-30.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element changed by getter on + previous iterations is observed on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var arr = [, , ]; +var preIterVisible = false; + +Object.defineProperty(arr, "2", { + get: function() { + preIterVisible = true; + return 0; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return "11"; + } + }, + configurable: true +}); + +arr.reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-31.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-31.js new file mode 100644 index 0000000000..fd4ec5d6f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-31.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element changed by getter on + previous iterations is observed on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var obj = { + length: 3 +}; +var preIterVisible = false; + +Object.defineProperty(obj, "2", { + get: function() { + preIterVisible = true; + return 0; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return "11"; + } + }, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-32.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-32.js new file mode 100644 index 0000000000..0e29e03b4a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-32.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - unnhandled exceptions happened in + getter terminate iteration on an Array-like object +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx <= 1) { + accessed = true; + } +} + + +var obj = { + 0: 0, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-33.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-33.js new file mode 100644 index 0000000000..5d7b1271ba --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-33.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - unnhandled exceptions happened in + getter terminate iteration on an Array +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx <= 1) { + accessed = true; + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "1", { + get: function() { + throw new Test262Error("unhandle exception happened in getter"); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + arr.reduceRight(callbackfn, "initialValue"); +}); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-4.js new file mode 100644 index 0000000000..dfc17f3099 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-4.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +Array.prototype[1] = "11"; +[0, 1, 2].reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-5.js new file mode 100644 index 0000000000..d45b839723 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-5.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0) { + testResult = (curVal === "0"); + } +} + +var proto = {}; + +Object.defineProperty(proto, "0", { + get: function() { + return 10; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +Object.defineProperty(child, "0", { + value: "0", + configurable: true +}); +child[1] = "1"; + +Array.prototype.reduceRight.call(child, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-6.js new file mode 100644 index 0000000000..3fab4c5323 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-6.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +Object.defineProperty(Array.prototype, "1", { + get: function() { + return "11"; + }, + configurable: true +}); +[0, 1, 2].reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-7.js new file mode 100644 index 0000000000..9ad5541f0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-7.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + data property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var proto = { + 0: 0, + 1: 1, + 2: 2 +}; +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 3; + +Array.prototype.reduceRight.call(child, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-8.js new file mode 100644 index 0000000000..8a5b29bd4d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-8.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + data property on an Array +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +Array.prototype[0] = 0; +Array.prototype[1] = 1; +Array.prototype[2] = 2; +[, , , ].reduceRight(callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-9.js new file mode 100644 index 0000000000..6fcb07c435 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-9.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} + +var obj = { + 0: 0, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-1.js new file mode 100644 index 0000000000..c08153cc3c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-1.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn called with correct + parameters (initialvalue not passed) +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + if (idx + 1 < obj.length && obj[idx] === curVal && obj[idx + 1] === prevVal) + return curVal; + else + return false; +} + +var arr = [0, 1, true, null, new Object(), "five"]; + +assert.sameValue(arr.reduceRight(callbackfn), 0, 'arr.reduceRight(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-10.js new file mode 100644 index 0000000000..bbd6a4e48f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-10.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn is called with 1 formal + parameter +---*/ + +var called = 0; + +function callbackfn(prevVal) { + called++; + return prevVal; +} + +assert.sameValue([11, 12].reduceRight(callbackfn, 100), 100, '[11, 12].reduceRight(callbackfn, 100)'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-11.js new file mode 100644 index 0000000000..7ae7d55ee5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-11.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn is called with 2 formal + parameter +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal) { + if (prevVal === 100) { + testResult = true; + } + return curVal > 10; +} + +assert.sameValue([11].reduceRight(callbackfn, 100), true, '[11].reduceRight(callbackfn, 100)'); +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-12.js new file mode 100644 index 0000000000..fc2251aac1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-12.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn is called with 3 formal + parameter +---*/ + +var testResult = false; +var arr = [11, 12, 13]; +var initVal = 6.99; + +function callbackfn(prevVal, curVal, idx) { + if (idx === 2) { + testResult = (prevVal === initVal); + } + return curVal > 10 && arguments[3][idx] === curVal; +} + +assert.sameValue(arr.reduceRight(callbackfn, initVal), true, 'arr.reduceRight(callbackfn, initVal)'); +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-13.js new file mode 100644 index 0000000000..dadad8321b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-13.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn is called with 4 formal + parameter +---*/ + +var arr = [11, 12, 13]; +var initVal = 6.99; +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2) { + testResult = (prevVal === initVal); + } + return curVal > 10 && obj[idx] === curVal; +} + +assert.sameValue(arr.reduceRight(callbackfn, initVal), true, 'arr.reduceRight(callbackfn, initVal)'); +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-14.js new file mode 100644 index 0000000000..0548a3bb8a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-14.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - callbackfn uses arguments +---*/ + +function callbackfn() { + return arguments[0] === 100 && arguments[3][arguments[2]] === arguments[1]; +} + +assert.sameValue([11].reduceRight(callbackfn, 100), true, '[11].reduceRight(callbackfn, 100)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-16.js new file mode 100644 index 0000000000..e0ce705a19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-16.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - non-indexed properties are not + called on an Array-like object +---*/ + +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (prevVal === 8 || curVal === 8) { + testResult = true; + } +} + +var obj = { + 0: 11, + 10: 12, + non_index_property: 8, + length: 20 +}; +Array.prototype.reduceRight.call(obj, callbackfn, "initialValue"); + +assert.sameValue(testResult, false, 'testResult'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-17.js new file mode 100644 index 0000000000..7ed779a120 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-17.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - 'accumulator' used for current + iteration is the result of previous iteration on an Array +---*/ + +var arr = [11, 12, 13]; +var testResult = true; +var initVal = 6.99; +var preResult = initVal; + +function callbackfn(prevVal, curVal, idx, obj) { + if (prevVal !== preResult) { + testResult = false; + } + preResult = curVal; + return curVal; +} + +arr.reduceRight(callbackfn, initVal); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-18.js new file mode 100644 index 0000000000..d6970a8ba3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-18.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - 'accumulator' used for first + iteration is the value of 'initialValue' when it is present on an + Array +---*/ + +var arr = [11, 12]; +var testResult = false; +var initVal = 6.99; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === initVal); + } + return curVal; +} + +arr.reduceRight(callbackfn, initVal); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-19.js new file mode 100644 index 0000000000..fdccf85eed --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-19.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'accumulator' used for + first iteration is the value of max index property which is not + undefined when 'initialValue' is not present on an Array +---*/ + +var arr = [11, 12, 13]; +var testResult = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 13); + } + return curVal; +} +arr.reduceRight(callbackfn); + +assert(testResult, 'testResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-2.js new file mode 100644 index 0000000000..4056b365a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-2.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn called with correct + parameters (initialvalue passed) +---*/ + +var bParCorrect = false; +var arr = [0, 1, true, null, new Object(), "five"]; +var initialValue = 5.5; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === obj.length - 1 && obj[idx] === curVal && prevVal === initialValue) + return curVal; + else if (idx + 1 < obj.length && obj[idx] === curVal && obj[idx + 1] === prevVal) + return curVal; + else + return false; +} + +assert.sameValue(arr.reduceRight(callbackfn, initialValue), 0, 'arr.reduceRight(callbackfn, initialValue)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-20.js new file mode 100644 index 0000000000..6881fc9712 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-20.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - undefined can be used as accumulator +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return typeof prevVal === "undefined"; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, undefined), true, 'Array.prototype.reduceRight.call(obj, callbackfn, undefined)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-21.js new file mode 100644 index 0000000000..75598d0c82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-21.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - null can be used as accumulator +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === null; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, null), true, 'Array.prototype.reduceRight.call(obj, callbackfn, null)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-22.js new file mode 100644 index 0000000000..3128f0ca63 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-22.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - boolean primitive can be used as + accumulator +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === false; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, false), true, 'Array.prototype.reduceRight.call(obj, callbackfn, false)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-23.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-23.js new file mode 100644 index 0000000000..cd427b7df5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-23.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - number primitive can be used as + accumulator +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === 12; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, 12), true, 'Array.prototype.reduceRight.call(obj, callbackfn, 12)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-24.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-24.js new file mode 100644 index 0000000000..92fb8532dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-24.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - string primitive can be used as + accumulator +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === "hello_"; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, "hello_"), true, 'Array.prototype.reduceRight.call(obj, callbackfn, "hello_")'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-25.js new file mode 100644 index 0000000000..4880b72314 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-25.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Function Object can be used as + accumulator +---*/ + +var accessed = false; +var objFunction = function() {}; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objFunction; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, objFunction), true, 'Array.prototype.reduceRight.call(obj, callbackfn, objFunction)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-26.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-26.js new file mode 100644 index 0000000000..694ac40bda --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-26.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Array Object can be used as + accumulator +---*/ + +var accessed = false; +var objArray = []; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objArray; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, objArray), true, 'Array.prototype.reduceRight.call(obj, callbackfn, objArray)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-27.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-27.js new file mode 100644 index 0000000000..68c67bd92f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-27.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - String Object can be used as + accumulator +---*/ + +var accessed = false; +var objString = new String(); + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objString; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, objString), true, 'Array.prototype.reduceRight.call(obj, callbackfn, objString)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-28.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-28.js new file mode 100644 index 0000000000..47fb54af5c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-28.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Boolean Object can be used as + accumulator +---*/ + +var accessed = false; +var objBoolean = new Boolean(); + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objBoolean; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, objBoolean), true, 'Array.prototype.reduceRight.call(obj, callbackfn, objBoolean)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-29.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-29.js new file mode 100644 index 0000000000..4540656a7d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-29.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Number Object can be used as + accumulator +---*/ + +var accessed = false; +var objNumber = new Number(); + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objNumber; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, objNumber), true, 'Array.prototype.reduceRight.call(obj, callbackfn, objNumber)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-3.js new file mode 100644 index 0000000000..c31fa3cd0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - callbackfn takes 4 arguments +---*/ + +var bCalled = false; + +function callbackfn(prevVal, curVal, idx, obj) +{ + bCalled = true; + if (prevVal === true && arguments.length === 4) + return true; + else + return false; +} +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + +assert.sameValue(arr.reduceRight(callbackfn, true), true, 'arr.reduceRight(callbackfn,true)'); +assert.sameValue(bCalled, true, 'bCalled'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-30.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-30.js new file mode 100644 index 0000000000..35ea67bb90 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-30.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the Math Object can be used as + accumulator +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === Math; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, Math), true, 'Array.prototype.reduceRight.call(obj, callbackfn, Math)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-31.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-31.js new file mode 100644 index 0000000000..76acefe853 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-31.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Date Object can be used as + accumulator +---*/ + +var accessed = false; +var objDate = new Date(); + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objDate; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, objDate), true, 'Array.prototype.reduceRight.call(obj, callbackfn, objDate)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-32.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-32.js new file mode 100644 index 0000000000..f00a3547d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-32.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - RegExp Object can be used as + accumulator +---*/ + +var accessed = false; +var objRegExp = new RegExp(); + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objRegExp; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, objRegExp), true, 'Array.prototype.reduceRight.call(obj, callbackfn, objRegExp)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-33.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-33.js new file mode 100644 index 0000000000..ea4e069518 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-33.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - the JSON can be used as accumulator +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === JSON; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, JSON), true, 'Array.prototype.reduceRight.call(obj, callbackfn, JSON)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-34.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-34.js new file mode 100644 index 0000000000..bc815f1950 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-34.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Error Object can be used as + accumulator +---*/ + +var accessed = false; +var objError = new RangeError(); + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objError; +} + +var obj = { + 0: 11, + length: 1 +}; + + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, objError), true, 'Array.prototype.reduceRight.call(obj, callbackfn, objError)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-35.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-35.js new file mode 100644 index 0000000000..db8071bbeb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-35.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the Arguments object can be used as + accumulator +---*/ + +var accessed = false; +var arg; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === arg; +} + +var obj = { + 0: 11, + length: 1 +}; + +(function fun() { + arg = arguments; +}(10, 11, 12, 13)); + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, arg), true, 'Array.prototype.reduceRight.call(obj, callbackfn, arg)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-37.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-37.js new file mode 100644 index 0000000000..8d56e9e95e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-37.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the global object can be used as + accumulator +---*/ + +var global = this; +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === global; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, this), true, 'Array.prototype.reduceRight.call(obj, callbackfn, this)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-4-s.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-4-s.js new file mode 100644 index 0000000000..1f1d3b7667 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-4-s.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - undefined passed as thisValue to + strict callbackfn +flags: [noStrict] +---*/ + +var innerThisCorrect = false; + +function callbackfn(prevVal, curVal, idx, obj) +{ + "use strict"; + innerThisCorrect = this === undefined; + return true; +} +[0].reduceRight(callbackfn, true); + +assert(innerThisCorrect, 'innerThisCorrect !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-4.js new file mode 100644 index 0000000000..099513a31a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-4.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - k values are passed in acending + numeric order +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +var lastIdx = arr.length - 1; +var accessed = false; +var result = true; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (lastIdx !== idx) { + result = false; + } else { + lastIdx--; + } +} +arr.reduceRight(callbackfn, 1); + +assert(result, 'result !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-5.js new file mode 100644 index 0000000000..25c1e0733a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-5.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - k values are accessed during each + iteration and not prior to starting the loop on an Array +---*/ + +var arr = [11, 12, 13, 14]; +var kIndex = []; +var result = true; +var called = 0; + +//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(preVal, curVal, idx, o) { + //Each position should be visited one time, which means k is accessed one time during iterations. + called++; + if (typeof kIndex[idx] === "undefined") { + //when current position is visited, its next index should has been visited. + if (idx !== arr.length - 1 && typeof kIndex[idx + 1] === "undefined") { + result = false; + } + kIndex[idx] = 1; + } else { + result = false; + } +} + +arr.reduceRight(callbackfn, 1); + +assert(result, 'result !== true'); +assert.sameValue(called, 4, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-7.js new file mode 100644 index 0000000000..e6028af07f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-7.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - unhandled exceptions happened in + callbackfn terminate iteration +---*/ + +var accessed = false; + +function callbackfn(prevVal, curVal, idx, obj) { + if (idx < 10) { + accessed = true; + } + if (idx === 10) { + throw new Test262Error("Exception occurred in callbackfn"); + } +} + +var obj = { + 0: 11, + 4: 10, + 10: 8, + length: 20 +}; + +assert.throws(Test262Error, function() { + Array.prototype.reduceRight.call(obj, callbackfn, 1); +}); + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-8.js new file mode 100644 index 0000000000..16d476bb34 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-8.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element changed by callbackfn on + previous iterations is observed +---*/ + +var accessed = false; +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 1) { + obj[idx - 1] = 8; + } + return curVal > 10; +} + +assert.sameValue(Array.prototype.reduceRight.call(obj, callbackfn, 1), false, 'Array.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-9.js new file mode 100644 index 0000000000..5bfbc4aeeb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-9.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn is called with 0 formal + parameter +---*/ + +var called = 0; + +function callbackfn() { + called++; + return true; +} + +assert.sameValue([11, 12].reduceRight(callbackfn, 11), true, '[11, 12].reduceRight(callbackfn, 11)'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/browser.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/call-with-boolean.js new file mode 100644 index 0000000000..a419bcf4e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/call-with-boolean.js @@ -0,0 +1,20 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceRight +description: Array.prototype.reduceRight applied to boolean primitive +---*/ + +assert.sameValue( + Array.prototype.reduceRight.call(true, () => {}, -1), + -1, + 'Array.prototype.reduceRight.call(true, () => {}, -1) must return -1' +); +assert.sameValue( + Array.prototype.reduceRight.call(false, () => {}, -1), + -1, + 'Array.prototype.reduceRight.call(false, () => {}, -1) must return -1' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/callbackfn-resize-arraybuffer.js new file mode 100644 index 0000000000..8704bccee9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/callbackfn-resize-arraybuffer.js @@ -0,0 +1,81 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.reduceright +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 3}); + var sample = new TA(buffer); + var expectedPrevsShrink, expectedNextsShrink, expectedIndicesShrink, expectedArraysShrink; + var expectedPrevsGrow, expectedNextsGrow, expectedIndicesGrow, expectedArraysGrow; + var prevs, nexts, indices, arrays, result; + + prevs = []; + nexts = []; + indices = []; + arrays = []; + result = Array.prototype.reduceRight.call(sample, function(prev, next, index, array) { + if (prevs.length === 0) { + try { + buffer.resize(BPE); + expectedPrevsShrink = [262, 2]; + expectedNextsShrink = [0, 0]; + expectedIndicesShrink = [2, 0]; + expectedArraysShrink = [sample, sample]; + expectedPrevsGrow = [262]; + expectedNextsGrow = [0]; + expectedIndicesGrow = [0]; + expectedArraysGrow = [sample]; + } catch (_) { + expectedPrevsShrink = expectedPrevsGrow = [262, 2, 1]; + expectedNextsShrink = expectedNextsGrow = [0, 0, 0]; + expectedIndicesShrink = expectedIndicesGrow = [2, 1, 0]; + expectedArraysShrink = expectedArraysGrow = [sample, sample, sample]; + } + } + + prevs.push(prev); + nexts.push(next); + indices.push(index); + arrays.push(array); + return index; + }, 262); + + assert.compareArray(prevs, expectedPrevsShrink, 'prevs (shrink)'); + assert.compareArray(nexts, expectedNextsShrink, 'nexts (shrink)'); + assert.compareArray(indices, expectedIndicesShrink, 'indices (shrink)'); + assert.compareArray(arrays, expectedArraysShrink, 'arrays (shrink)'); + assert.sameValue(result, 0, 'result (shrink)'); + + prevs = []; + nexts = []; + indices = []; + arrays = []; + result = Array.prototype.reduceRight.call(sample, function(prev, next, index, array) { + if (prevs.length === 0) { + try { + buffer.resize(3 * BPE); + } catch (_) {} + } + + prevs.push(prev); + nexts.push(next); + indices.push(index); + arrays.push(array); + return index; + }, 262); + + assert.compareArray(prevs, expectedPrevsGrow, 'prevs (grow)'); + assert.compareArray(nexts, expectedNextsGrow, 'nexts (grow)'); + assert.compareArray(indices, expectedIndicesGrow, 'indices (grow)'); + assert.compareArray(arrays, expectedArraysGrow, 'arrays (grow)'); + assert.sameValue(result, expectedIndicesGrow[expectedIndicesGrow.length - 1], 'result (grow)'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/length-near-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/length-near-integer-limit.js new file mode 100644 index 0000000000..165ecebf1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/length-near-integer-limit.js @@ -0,0 +1,59 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Elements are processed in an array-like object + whose "length" property is near the integer limit. +info: | + Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + [...] + 9. Repeat, while k ≥ 0 + a. Let Pk be ! ToString(k). + b. Let kPresent be ? HasProperty(O, Pk). + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Set accumulator to ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). + [...] +includes: [compareArray.js] +---*/ + +var arrayLike = { + length: Number.MAX_SAFE_INTEGER, +}; + +arrayLike[Number.MAX_SAFE_INTEGER - 1] = 1; +arrayLike[Number.MAX_SAFE_INTEGER - 3] = 3; + +var accumulator = function(acc, el, index) { + acc.push([el, index]); + + if (el === 3) { + throw acc; + } + + return acc; +}; + +try { + Array.prototype.reduceRight.call(arrayLike, accumulator, []); + throw new Test262Error("should not be called"); +} catch (acc) { + assert.sameValue(acc.length, 2, 'The value of acc.length is expected to be 2'); + assert.compareArray( + acc[0], + [1, Number.MAX_SAFE_INTEGER - 1], + 'The value of acc[0] is expected to be [1, Number.MAX_SAFE_INTEGER - 1]' + ); + assert.compareArray( + acc[1], + [3, Number.MAX_SAFE_INTEGER - 3], + 'The value of acc[1] is expected to be [3, Number.MAX_SAFE_INTEGER - 3]' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/length.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/length.js new file mode 100644 index 0000000000..4f02036c8d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + The "length" property of Array.prototype.reduceRight +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.reduceRight.length, 1); + +verifyNotEnumerable(Array.prototype.reduceRight, 'length'); +verifyNotWritable(Array.prototype.reduceRight, 'length'); +verifyConfigurable(Array.prototype.reduceRight, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/name.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/name.js new file mode 100644 index 0000000000..c3e90f6957 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight.name is "reduceRight". +info: | + Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.reduceRight.name, "reduceRight"); + +verifyNotEnumerable(Array.prototype.reduceRight, "name"); +verifyNotWritable(Array.prototype.reduceRight, "name"); +verifyConfigurable(Array.prototype.reduceRight, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/not-a-constructor.js new file mode 100644 index 0000000000..77e7e825b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/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: > + Array.prototype.reduceRight 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.reduceRight), + false, + 'isConstructor(Array.prototype.reduceRight) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.reduceRight(() => {}, []); +}, '`new Array.prototype.reduceRight(() => {}, [])` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/prop-desc.js new file mode 100644 index 0000000000..98de001a8d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduceright +description: > + "reduceRight" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.reduceRight, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "reduceRight"); +verifyWritable(Array.prototype, "reduceRight"); +verifyConfigurable(Array.prototype, "reduceRight"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/shell.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/shell.js new file mode 100644 index 0000000000..05fecd6ef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/shell.js @@ -0,0 +1,161 @@ +// GENERATED, DO NOT EDIT +// file: testTypedArray.js +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - floatArrayConstructors + - nonClampedIntArrayConstructors + - intArrayConstructors + - typedArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - nonAtomicsFriendlyTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +var floatArrayConstructors = [ + Float64Array, + Float32Array +]; + +var nonClampedIntArrayConstructors = [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array +]; + +var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]); + +// Float16Array is a newer feature +// adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it +if (typeof Float16Array !== 'undefined') { + floatArrayConstructors.push(Float16Array); +} + +/** + * Array containing every non-bigint typed array constructor. + */ + +var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]); +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} + +/** + * Checks if the given argument is one of the float-based TypedArray constructors. + * + * @param {constructor} ctor - the value to check + * @returns {boolean} + */ +function isFloatTypedArrayConstructor(arg) { + return floatArrayConstructors.indexOf(arg) !== -1; +} + +/** + * Determines the precision of the given float-based TypedArray constructor. + * + * @param {constructor} ctor - the value to check + * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively. + */ +function floatTypedArrayConstructorPrecision(FA) { + if (typeof Float16Array !== "undefined" && FA === Float16Array) { + return "half"; + } else if (FA === Float32Array) { + return "single"; + } else if (FA === Float64Array) { + return "double"; + } else { + throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray"); + } +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A1_T1.js new file mode 100644 index 0000000000..c3c857081c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A1_T1.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The elements of the array are rearranged so as to reverse their order. + The object is returned as the result of the call +esid: sec-array.prototype.reverse +description: Checking case when reverse is given no arguments or one argument +---*/ + +var x = []; +var reverse = x.reverse(); +if (reverse !== x) { + throw new Test262Error('#1: x = []; x.reverse() === x. Actual: ' + (reverse)); +} + +x = []; +x[0] = 1; +var reverse = x.reverse(); +if (reverse !== x) { + throw new Test262Error('#2: x = []; x[0] = 1; x.reverse() === x. Actual: ' + (reverse)); +} + +x = new Array(1, 2); +var reverse = x.reverse(); +if (reverse !== x) { + throw new Test262Error('#3: x = new Array(1,2); x.reverse() === x. Actual: ' + (reverse)); +} + +if (x[0] !== 2) { + throw new Test262Error('#4: x = new Array(1,2); x.reverse(); x[0] === 2. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#5: x = new Array(1,2); x.reverse(); x[1] === 1. Actual: ' + (x[1])); +} + +if (x.length !== 2) { + throw new Test262Error('#6: x = new Array(1,2); x.reverse(); x.length === 2. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A1_T2.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A1_T2.js new file mode 100644 index 0000000000..17d693192f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A1_T2.js @@ -0,0 +1,108 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The elements of the array are rearranged so as to reverse their order. + The object is returned as the result of the call +esid: sec-array.prototype.reverse +description: Checking this algorithm, elements are objects and primitives +---*/ + +var x = []; +x[0] = true; +x[2] = Infinity; +x[4] = undefined; +x[5] = undefined; +x[8] = "NaN"; +x[9] = "-1"; + +var reverse = x.reverse(); +if (reverse !== x) { + throw new Test262Error('#1: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse() === x. Actual: ' + (reverse)); +} + +if (x[0] !== "-1") { + throw new Test262Error('#2: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[0] === "-1". Actual: ' + (x[0])); +} + +if (x[1] !== "NaN") { + throw new Test262Error('#3: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[1] === "NaN". Actual: ' + (x[1])); +} + +if (x[2] !== undefined) { + throw new Test262Error('#4: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[2] === undefined. Actual: ' + (x[2])); +} + +if (x[3] !== undefined) { + throw new Test262Error('#5: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[3] === undefined. Actual: ' + (x[3])); +} + +if (x[4] !== undefined) { + throw new Test262Error('#6: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[4] === undefined. Actual: ' + (x[4])); +} + +if (x[5] !== undefined) { + throw new Test262Error('#7: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[5] === undefined. Actual: ' + (x[5])); +} + +if (x[6] !== undefined) { + throw new Test262Error('#8: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[6] === undefined. Actual: ' + (x[6])); +} + +if (x[7] !== Infinity) { + throw new Test262Error('#9: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[7] === Infinity. Actual: ' + (x[7])); +} + +if (x[8] !== undefined) { + throw new Test262Error('#10: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[8] === undefined. Actual: ' + (x[8])); +} + +if (x[9] !== true) { + throw new Test262Error('#11: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[9] === true. Actual: ' + (x[9])); +} + +x.length = 9; + +var reverse = x.reverse(); +if (reverse !== x) { + throw new Test262Error('#1: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse() === x. Actual: ' + (reverse)); +} + +if (x[0] !== undefined) { + throw new Test262Error('#12: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[0] === undefined. Actual: ' + (x[0])); +} + +if (x[1] !== Infinity) { + throw new Test262Error('#13: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[1] === Infinity. Actual: ' + (x[1])); +} + +if (x[2] !== undefined) { + throw new Test262Error('#14: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[2] === undefined. Actual: ' + (x[2])); +} + +if (x[3] !== undefined) { + throw new Test262Error('#15: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[3] === undefined. Actual: ' + (x[3])); +} + +if (x[4] !== undefined) { + throw new Test262Error('#16: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[4] === undefined. Actual: ' + (x[4])); +} + +if (x[5] !== undefined) { + throw new Test262Error('#17: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[5] === undefined. Actual: ' + (x[5])); +} + +if (x[6] !== undefined) { + throw new Test262Error('#18: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[6] === undefined. Actual: ' + (x[6])); +} + +if (x[7] !== "NaN") { + throw new Test262Error('#19: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[7] === "NaN". Actual: ' + (x[7])); +} + +if (x[8] !== "-1") { + throw new Test262Error('#20: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[8] === "-1". Actual: ' + (x[8])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T1.js new file mode 100644 index 0000000000..be4e477e02 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T1.js @@ -0,0 +1,113 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The reverse function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.reverse +description: > + Checking this for Object object, elements are objects and + primitives, length is integer +---*/ + +var obj = {}; +obj.length = 10; +obj.reverse = Array.prototype.reverse; + +obj[0] = true; +obj[2] = Infinity; +obj[4] = undefined; +obj[5] = undefined; +obj[8] = "NaN"; +obj[9] = "-1"; + +var reverse = obj.reverse(); +if (reverse !== obj) { + throw new Test262Error('#1: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse() === obj. Actual: ' + (reverse)); +} + +if (obj[0] !== "-1") { + throw new Test262Error('#2: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[0] === "-1". Actual: ' + (obj[0])); +} + +if (obj[1] !== "NaN") { + throw new Test262Error('#3: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[1] === "NaN". Actual: ' + (obj[1])); +} + +if (obj[2] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[2] === undefined. Actual: ' + (obj[2])); +} + +if (obj[3] !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[3] === undefined. Actual: ' + (obj[3])); +} + +if (obj[4] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[4] === undefined. Actual: ' + (obj[4])); +} + +if (obj[5] !== undefined) { + throw new Test262Error('#7: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[5] === undefined. Actual: ' + (obj[5])); +} + +if (obj[6] !== undefined) { + throw new Test262Error('#8: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[6] === undefined. Actual: ' + (obj[6])); +} + +if (obj[7] !== Infinity) { + throw new Test262Error('#9: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[7] === Infinity. Actual: ' + (obj[7])); +} + +if (obj[8] !== undefined) { + throw new Test262Error('#10: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[8] === undefined. Actual: ' + (obj[8])); +} + +if (obj[9] !== true) { + throw new Test262Error('#11: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[9] === true. Actual: ' + (obj[9])); +} + +obj.length = 9; + +var reverse = obj.reverse(); +if (reverse !== obj) { + throw new Test262Error('#1: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse() === obj. Actual: ' + (reverse)); +} + +if (obj[0] !== undefined) { + throw new Test262Error('#12: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[0] === undefined. Actual: ' + (obj[0])); +} + +if (obj[1] !== Infinity) { + throw new Test262Error('#13: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[1] === Infinity. Actual: ' + (obj[1])); +} + +if (obj[2] !== undefined) { + throw new Test262Error('#14: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[2] === undefined. Actual: ' + (obj[2])); +} + +if (obj[3] !== undefined) { + throw new Test262Error('#15: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[3] === undefined. Actual: ' + (obj[3])); +} + +if (obj[4] !== undefined) { + throw new Test262Error('#16: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[4] === undefined. Actual: ' + (obj[4])); +} + +if (obj[5] !== undefined) { + throw new Test262Error('#17: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[5] === undefined. Actual: ' + (obj[5])); +} + +if (obj[6] !== undefined) { + throw new Test262Error('#18: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[6] === undefined. Actual: ' + (obj[6])); +} + +if (obj[7] !== "NaN") { + throw new Test262Error('#19: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[7] === "NaN". Actual: ' + (obj[7])); +} + +if (obj[8] !== "-1") { + throw new Test262Error('#20: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[8] === "-1". Actual: ' + (obj[8])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T2.js new file mode 100644 index 0000000000..0b61f0aeed --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T2.js @@ -0,0 +1,113 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The reverse function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.reverse +description: > + Checking this for Object object, elements are objects and + primitives, length is not integer +---*/ + +var obj = {}; +obj.length = 10.5; +obj.reverse = Array.prototype.reverse; + +obj[0] = true; +obj[2] = Infinity; +obj[4] = undefined; +obj[5] = undefined; +obj[8] = "NaN"; +obj[9] = "-1"; + +var reverse = obj.reverse(); +if (reverse !== obj) { + throw new Test262Error('#1: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse() === obj. Actual: ' + (reverse)); +} + +if (obj[0] !== "-1") { + throw new Test262Error('#2: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[0] === "-1". Actual: ' + (obj[0])); +} + +if (obj[1] !== "NaN") { + throw new Test262Error('#3: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[1] === "NaN". Actual: ' + (obj[1])); +} + +if (obj[2] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[2] === undefined. Actual: ' + (obj[2])); +} + +if (obj[3] !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[3] === undefined. Actual: ' + (obj[3])); +} + +if (obj[4] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[4] === undefined. Actual: ' + (obj[4])); +} + +if (obj[5] !== undefined) { + throw new Test262Error('#7: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[5] === undefined. Actual: ' + (obj[5])); +} + +if (obj[6] !== undefined) { + throw new Test262Error('#8: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[6] === undefined. Actual: ' + (obj[6])); +} + +if (obj[7] !== Infinity) { + throw new Test262Error('#9: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[7] === Infinity. Actual: ' + (obj[7])); +} + +if (obj[8] !== undefined) { + throw new Test262Error('#10: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[8] === undefined. Actual: ' + (obj[8])); +} + +if (obj[9] !== true) { + throw new Test262Error('#11: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[9] === true. Actual: ' + (obj[9])); +} + +obj.length = new Number(9.5); + +var reverse = obj.reverse(); +if (reverse !== obj) { + throw new Test262Error('#1: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse() === obj. Actual: ' + (reverse)); +} + +if (obj[0] !== undefined) { + throw new Test262Error('#12: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[0] === undefined. Actual: ' + (obj[0])); +} + +if (obj[1] !== Infinity) { + throw new Test262Error('#13: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[1] === Infinity. Actual: ' + (obj[1])); +} + +if (obj[2] !== undefined) { + throw new Test262Error('#14: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[2] === undefined. Actual: ' + (obj[2])); +} + +if (obj[3] !== undefined) { + throw new Test262Error('#15: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[3] === undefined. Actual: ' + (obj[3])); +} + +if (obj[4] !== undefined) { + throw new Test262Error('#16: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[4] === undefined. Actual: ' + (obj[4])); +} + +if (obj[5] !== undefined) { + throw new Test262Error('#17: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[5] === undefined. Actual: ' + (obj[5])); +} + +if (obj[6] !== undefined) { + throw new Test262Error('#18: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[6] === undefined. Actual: ' + (obj[6])); +} + +if (obj[7] !== "NaN") { + throw new Test262Error('#19: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[7] === "NaN". Actual: ' + (obj[7])); +} + +if (obj[8] !== "-1") { + throw new Test262Error('#20: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[8] === "-1". Actual: ' + (obj[8])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T3.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T3.js new file mode 100644 index 0000000000..0afd7860c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T3.js @@ -0,0 +1,113 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The reverse function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.reverse +description: > + Checking this for Object object, elements are objects and + primitives, length is string +---*/ + +var obj = {}; +obj.length = "10"; +obj.reverse = Array.prototype.reverse; + +obj[0] = true; +obj[2] = Infinity; +obj[4] = undefined; +obj[5] = undefined; +obj[8] = "NaN"; +obj[9] = "-1"; + +var reverse = obj.reverse(); +if (reverse !== obj) { + throw new Test262Error('#1: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse() === obj. Actual: ' + (reverse)); +} + +if (obj[0] !== "-1") { + throw new Test262Error('#2: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[0] === "-1". Actual: ' + (obj[0])); +} + +if (obj[1] !== "NaN") { + throw new Test262Error('#3: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[1] === "NaN". Actual: ' + (obj[1])); +} + +if (obj[2] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[2] === undefined. Actual: ' + (obj[2])); +} + +if (obj[3] !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[3] === undefined. Actual: ' + (obj[3])); +} + +if (obj[4] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[4] === undefined. Actual: ' + (obj[4])); +} + +if (obj[5] !== undefined) { + throw new Test262Error('#7: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[5] === undefined. Actual: ' + (obj[5])); +} + +if (obj[6] !== undefined) { + throw new Test262Error('#8: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[6] === undefined. Actual: ' + (obj[6])); +} + +if (obj[7] !== Infinity) { + throw new Test262Error('#9: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[7] === Infinity. Actual: ' + (obj[7])); +} + +if (obj[8] !== undefined) { + throw new Test262Error('#10: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[8] === undefined. Actual: ' + (obj[8])); +} + +if (obj[9] !== true) { + throw new Test262Error('#11: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[9] === true. Actual: ' + (obj[9])); +} + +obj.length = new String("9"); + +var reverse = obj.reverse(); +if (reverse !== obj) { + throw new Test262Error('#1: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse() === obj. Actual: ' + (reverse)); +} + +if (obj[0] !== undefined) { + throw new Test262Error('#12: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[0] === undefined. Actual: ' + (obj[0])); +} + +if (obj[1] !== Infinity) { + throw new Test262Error('#13: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[1] === Infinity. Actual: ' + (obj[1])); +} + +if (obj[2] !== undefined) { + throw new Test262Error('#14: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[2] === undefined. Actual: ' + (obj[2])); +} + +if (obj[3] !== undefined) { + throw new Test262Error('#15: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[3] === undefined. Actual: ' + (obj[3])); +} + +if (obj[4] !== undefined) { + throw new Test262Error('#16: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[4] === undefined. Actual: ' + (obj[4])); +} + +if (obj[5] !== undefined) { + throw new Test262Error('#17: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[5] === undefined. Actual: ' + (obj[5])); +} + +if (obj[6] !== undefined) { + throw new Test262Error('#18: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[6] === undefined. Actual: ' + (obj[6])); +} + +if (obj[7] !== "NaN") { + throw new Test262Error('#19: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[7] === "NaN". Actual: ' + (obj[7])); +} + +if (obj[8] !== "-1") { + throw new Test262Error('#20: var obj = {}; obj.reverse = Array.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[8] === "-1". Actual: ' + (obj[8])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A3_T3.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A3_T3.js new file mode 100644 index 0000000000..6f757b571b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A3_T3.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.reverse +description: length = -4294967294 +---*/ + +var obj = {}; +obj.reverse = Array.prototype.reverse; +obj[0] = "x"; +obj[1] = "y"; +obj[2] = "z"; +obj.length = -4294967294; + +var reverse = obj.reverse(); +if (reverse !== obj) { + throw new Test262Error('#1: var obj = {}; obj.reverse = Array.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse() === obj. Actual: ' + (reverse)); +} + +if (obj.length !== -4294967294) { + throw new Test262Error('#2: var obj = {}; obj.reverse = Array.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse(); obj.length === -4294967294. Actual: ' + (obj.length)); +} + +if (obj[0] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.reverse = Array.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse(); obj[0] === "x". Actual: ' + (obj[0])); +} + +if (obj[1] !== "y") { + throw new Test262Error('#4: var obj = {}; obj.reverse = Array.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse(); obj[1] === "y". Actual: ' + (obj[1])); +} + +if (obj[2] !== "z") { + throw new Test262Error('#5: var obj = {}; obj.reverse = Array.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse(); obj[2] === "z". Actual: ' + (obj[2])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A4_T1.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A4_T1.js new file mode 100644 index 0000000000..21f59fcf52 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A4_T1.js @@ -0,0 +1,62 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.reverse +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Array.prototype[1] = 1; +var x = [0]; +x.length = 2; +x.reverse(); + +if (x[0] !== 1) { + throw new Test262Error('#1: Array.prototype[1] = 1; x = [0]; x.length = 2; x.reverse(); x[0] === 1. Actual: ' + (x[0])); +} + +if (x[1] !== 0) { + throw new Test262Error('#2: Array.prototype[1] = 1; x = [0]; x.length = 2; x.reverse(); x[1] === 0. Actual: ' + (x[1])); +} + +x.length = 0; + +if (x[0] !== undefined) { + throw new Test262Error('#3: Array.prototype[1] = 1; x = [0]; x.length = 2; x.reverse(); x.length = 0; x[0] === undefined. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#4: Array.prototype[1] = 1; x = [0]; x.length = 2; x.reverse(); x.length = 0; x[1] === 1. Actual: ' + (x[1])); +} + +Object.prototype[1] = 1; +Object.prototype.length = 2; +Object.prototype.reverse = Array.prototype.reverse; +x = { + 0: 0 +}; +x.reverse(); + +if (x[0] !== 1) { + throw new Test262Error('#5: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.reverse = Array.prototype.reverse; x = {0:0}; x.reverse(); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 0) { + throw new Test262Error('#6: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.reverse = Array.prototype.reverse; x = {0:0}; x.reverse(); x[1] === 0. Actual: ' + (x[1])); +} + +delete x[0]; +delete x[1]; + +if (x[0] !== undefined) { + throw new Test262Error('#7: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.reverse = Array.prototype.reverse; x = {0:0}; x.reverse(); delete x[0]; delete x[1]; x[0] === undefined. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#8: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.reverse = Array.prototype.reverse; x = {0:0}; x.reverse(); delete x[0]; delete x[1]; x[1] === 1. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A4_T2.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A4_T2.js new file mode 100644 index 0000000000..f71c23a262 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A4_T2.js @@ -0,0 +1,63 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.reverse +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Array.prototype[1] = -1; +var x = [0, 1]; +x.length = 2; +x.reverse(); + +if (x[0] !== 1) { + throw new Test262Error('#1: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.reverse(); x[0] === 1. Actual: ' + (x[0])); +} + +if (x[1] !== 0) { + throw new Test262Error('#2: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.reverse(); x[1] === 0. Actual: ' + (x[1])); +} + +x.length = 0; + +if (x[0] !== undefined) { + throw new Test262Error('#3: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.reverse(); x.length = 0; x[0] === undefined. Actual: ' + (x[0])); +} + +if (x[1] !== -1) { + throw new Test262Error('#4: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.reverse(); x.length = 0; x[1] === -1. Actual: ' + (x[1])); +} + +Object.prototype[1] = -1; +Object.prototype.length = 2; +Object.prototype.reverse = Array.prototype.reverse; +x = { + 0: 0, + 1: 1 +}; +x.reverse(); + +if (x[0] !== 1) { + throw new Test262Error('#5: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.reverse = Array.prototype.reverse; x = {0:0,1:1}; x.reverse(); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 0) { + throw new Test262Error('#6: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.reverse = Array.prototype.reverse; x = {0:0,1:1}; x.reverse(); x[1] === 0. Actual: ' + (x[1])); +} + +delete x[0]; +delete x[1]; + +if (x[0] !== undefined) { + throw new Test262Error('#7: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.reverse = Array.prototype.reverse; x = {0:0,1:1}; x.reverse(); delete x[0]; delete x[1]; x[0] === undefined. Actual: ' + (x[0])); +} + +if (x[1] !== -1) { + throw new Test262Error('#8: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.reverse = Array.prototype.reverse; x = {0:0,1:1}; x.reverse(); delete x[0]; delete x[1]; x[1] === -1. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/array-has-one-entry.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/array-has-one-entry.js new file mode 100644 index 0000000000..630ae1eb3f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/array-has-one-entry.js @@ -0,0 +1,25 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reverse +description: Array.prototype.reverse should not iterate items if there is only one entry +info: | + Array.prototype.reverse ( ) + + Let O be ? ToObject(this value). + Let len be ? LengthOfArrayLike(O). + Let middle be floor(len / 2). + Let lower be 0. + Repeat, while lower ≠ middle, + ... + Return O. +---*/ + +let a = [1]; + +Object.freeze(a); + +a.reverse(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/browser.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/call-with-boolean.js new file mode 100644 index 0000000000..0993ce09f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/call-with-boolean.js @@ -0,0 +1,20 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reverse +description: Array.prototype.reverse applied to boolean primitive +---*/ + +assert.sameValue( + Array.prototype.reverse.call(true) instanceof Boolean, + true, + 'The result of `(Array.prototype.reverse.call(true) instanceof Boolean)` is true' +); +assert.sameValue( + Array.prototype.reverse.call(false) instanceof Boolean, + true, + 'The result of `(Array.prototype.reverse.call(false) instanceof Boolean)` is true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/get_if_present_with_delete.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/get_if_present_with_delete.js new file mode 100644 index 0000000000..cf80988cf2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/get_if_present_with_delete.js @@ -0,0 +1,39 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Array.prototype.reverse only gets present properties - delete property with getter +info: | + 22.1.3.20 Array.prototype.reverse ( ) + + ... + 7. + d. Let lowerExists be HasProperty(O, lowerP). + e. ReturnIfAbrupt(lowerExists). + f. If lowerExists is true, then + i. Let lowerValue be Get(O, lowerP). + ii. ReturnIfAbrupt(lowerValue). + g. Let upperExists be HasProperty(O, upperP). + h. ReturnIfAbrupt(upperExists). + i. If upperExists is true, then + i. Let upperValue be Get(O, upperP). + ii. ReturnIfAbrupt(upperValue). +esid: sec-array.prototype.reverse +---*/ + +var array = ["first", "second"]; + +Object.defineProperty(array, 0, { + get: function() { + array.length = 0; + return "first"; + } +}); + +array.reverse(); + +assert.sameValue((0 in array), false, "Indexed property '0' not present"); +assert.sameValue((1 in array), true, "Indexed property '1' present"); +assert.sameValue(array[1], "first", "Indexed property '1' value correct"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-object.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-object.js new file mode 100644 index 0000000000..056478532c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-object.js @@ -0,0 +1,35 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reverse +description: > + Ensure reverse() implementation correctly handles length exceeding 2^53-1 with plain objects. +info: | + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... +features: [exponentiation] +---*/ + +function StopReverse() {} + +// Object with large "length" property and no indexed properties in the uint32 range. +var arrayLike = { + get "9007199254740990" () { + throw new StopReverse(); + }, + get "9007199254740991" () { + throw new Test262Error("Get 9007199254740991"); + }, + get "9007199254740992" () { + throw new Test262Error("Get 9007199254740992"); + }, + length: 2 ** 53 + 2, +}; + +assert.throws(StopReverse, function() { + Array.prototype.reverse.call(arrayLike); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-proxy.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-proxy.js new file mode 100644 index 0000000000..57fba3cd11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-proxy.js @@ -0,0 +1,122 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reverse +description: > + Ensure correct MOP operations are called when length exceeds 2^53-1. +includes: [compareArray.js, proxyTrapsHelper.js] +features: [exponentiation] +---*/ + +function StopReverse() {} + +var arrayLike = { + 0: "zero", + /* 1: hole, */ + 2: "two", + /* 3: hole, */ + + get 4() { + throw new StopReverse(); + }, + + 9007199254740987: "2**53-5", + /* 9007199254740988: hole, */ + /* 9007199254740989: hole, */ + 9007199254740990: "2**53-2", + + length: 2 ** 53 + 2, +}; + +var traps = []; + +var proxy = new Proxy(arrayLike, allowProxyTraps({ + getOwnPropertyDescriptor(t, pk) { + traps.push(`GetOwnPropertyDescriptor:${String(pk)}`); + return Reflect.getOwnPropertyDescriptor(t, pk); + }, + defineProperty(t, pk, desc) { + traps.push(`DefineProperty:${String(pk)}`); + return Reflect.defineProperty(t, pk, desc); + }, + has(t, pk) { + traps.push(`Has:${String(pk)}`); + return Reflect.has(t, pk); + }, + get(t, pk, r) { + traps.push(`Get:${String(pk)}`); + return Reflect.get(t, pk, r); + }, + set(t, pk, v, r) { + traps.push(`Set:${String(pk)}`); + return Reflect.set(t, pk, v, r); + }, + deleteProperty(t, pk) { + traps.push(`Delete:${String(pk)}`); + return Reflect.deleteProperty(t, pk); + }, +})) + +// Uses a separate exception than Test262Error, so that errors from allowProxyTraps +// are properly propagated. +assert.throws(StopReverse, function() { + Array.prototype.reverse.call(proxy); +}, 'Array.prototype.reverse.call(proxy) throws a StopReverse exception'); + +assert.compareArray(traps, [ + // Initial get length operation. + "Get:length", + + // Lower and upper index are both present. + "Has:0", + "Get:0", + "Has:9007199254740990", + "Get:9007199254740990", + "Set:0", + "GetOwnPropertyDescriptor:0", + "DefineProperty:0", + "Set:9007199254740990", + "GetOwnPropertyDescriptor:9007199254740990", + "DefineProperty:9007199254740990", + + // Lower and upper index are both absent. + "Has:1", + "Has:9007199254740989", + + // Lower index is present, upper index is absent. + "Has:2", + "Get:2", + "Has:9007199254740988", + "Delete:2", + "Set:9007199254740988", + "GetOwnPropertyDescriptor:9007199254740988", + "DefineProperty:9007199254740988", + + // Lower index is absent, upper index is present. + "Has:3", + "Has:9007199254740987", + "Get:9007199254740987", + "Set:3", + "GetOwnPropertyDescriptor:3", + "DefineProperty:3", + "Delete:9007199254740987", + + // Stop exception. + "Has:4", + "Get:4", +], 'The value of traps is expected to be [\n // Initial get length operation.\n "Get:length",\n\n // Lower and upper index are both present.\n "Has:0",\n "Get:0",\n "Has:9007199254740990",\n "Get:9007199254740990",\n "Set:0",\n "GetOwnPropertyDescriptor:0",\n "DefineProperty:0",\n "Set:9007199254740990",\n "GetOwnPropertyDescriptor:9007199254740990",\n "DefineProperty:9007199254740990",\n\n // Lower and upper index are both absent.\n "Has:1",\n "Has:9007199254740989",\n\n // Lower index is present, upper index is absent.\n "Has:2",\n "Get:2",\n "Has:9007199254740988",\n "Delete:2",\n "Set:9007199254740988",\n "GetOwnPropertyDescriptor:9007199254740988",\n "DefineProperty:9007199254740988",\n\n // Lower index is absent, upper index is present.\n "Has:3",\n "Has:9007199254740987",\n "Get:9007199254740987",\n "Set:3",\n "GetOwnPropertyDescriptor:3",\n "DefineProperty:3",\n "Delete:9007199254740987",\n\n // Stop exception.\n "Has:4",\n "Get:4",\n]'); + +assert.sameValue(arrayLike.length, 2 ** 53 + 2, 'The value of arrayLike.length is expected to be 2 ** 53 + 2'); + +assert.sameValue(arrayLike[0], "2**53-2", 'The value of arrayLike[0] is expected to be "2**53-2"'); +assert.sameValue(1 in arrayLike, false, 'The result of evaluating (1 in arrayLike) is expected to be false'); +assert.sameValue(2 in arrayLike, false, 'The result of evaluating (2 in arrayLike) is expected to be false'); +assert.sameValue(arrayLike[3], "2**53-5", 'The value of arrayLike[3] is expected to be "2**53-5"'); + +assert.sameValue(9007199254740987 in arrayLike, false, 'The result of evaluating (9007199254740987 in arrayLike) is expected to be false'); +assert.sameValue(arrayLike[9007199254740988], "two", 'The value of arrayLike[9007199254740988] is expected to be "two"'); +assert.sameValue(9007199254740989 in arrayLike, false, 'The result of evaluating (9007199254740989 in arrayLike) is expected to be false'); +assert.sameValue(arrayLike[9007199254740990], "zero", 'The value of arrayLike[9007199254740990] is expected to be "zero"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/length.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/length.js new file mode 100644 index 0000000000..fb5562c43d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reverse +description: > + The "length" property of Array.prototype.reverse +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.reverse.length, 0); + +verifyNotEnumerable(Array.prototype.reverse, 'length'); +verifyNotWritable(Array.prototype.reverse, 'length'); +verifyConfigurable(Array.prototype.reverse, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/name.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/name.js new file mode 100644 index 0000000000..450398c5d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reverse +description: > + Array.prototype.reverse.name is "reverse". +info: | + Array.prototype.reverse ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.reverse.name, "reverse"); + +verifyNotEnumerable(Array.prototype.reverse, "name"); +verifyNotWritable(Array.prototype.reverse, "name"); +verifyConfigurable(Array.prototype.reverse, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/not-a-constructor.js new file mode 100644 index 0000000000..693a459165 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/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: > + Array.prototype.reverse 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.reverse), + false, + 'isConstructor(Array.prototype.reverse) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.reverse(); +}, '`new Array.prototype.reverse()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/prop-desc.js new file mode 100644 index 0000000000..6752c1d89e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reverse +description: > + "reverse" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.reverse, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "reverse"); +verifyWritable(Array.prototype, "reverse"); +verifyConfigurable(Array.prototype, "reverse"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/shell.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/shell.js new file mode 100644 index 0000000000..bc72493f03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/shell.js @@ -0,0 +1,33 @@ +// GENERATED, DO NOT EDIT +// file: proxyTrapsHelper.js +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Used to assert the correctness of object behavior in the presence + and context of Proxy objects. +defines: [allowProxyTraps] +---*/ + +function allowProxyTraps(overrides) { + function throwTest262Error(msg) { + return function () { throw new Test262Error(msg); }; + } + if (!overrides) { overrides = {}; } + return { + getPrototypeOf: overrides.getPrototypeOf || throwTest262Error('[[GetPrototypeOf]] trap called'), + setPrototypeOf: overrides.setPrototypeOf || throwTest262Error('[[SetPrototypeOf]] trap called'), + isExtensible: overrides.isExtensible || throwTest262Error('[[IsExtensible]] trap called'), + preventExtensions: overrides.preventExtensions || throwTest262Error('[[PreventExtensions]] trap called'), + getOwnPropertyDescriptor: overrides.getOwnPropertyDescriptor || throwTest262Error('[[GetOwnProperty]] trap called'), + has: overrides.has || throwTest262Error('[[HasProperty]] trap called'), + get: overrides.get || throwTest262Error('[[Get]] trap called'), + set: overrides.set || throwTest262Error('[[Set]] trap called'), + deleteProperty: overrides.deleteProperty || throwTest262Error('[[Delete]] trap called'), + defineProperty: overrides.defineProperty || throwTest262Error('[[DefineOwnProperty]] trap called'), + enumerate: throwTest262Error('[[Enumerate]] trap called: this trap has been removed'), + ownKeys: overrides.ownKeys || throwTest262Error('[[OwnPropertyKeys]] trap called'), + apply: overrides.apply || throwTest262Error('[[Call]] trap called'), + construct: overrides.construct || throwTest262Error('[[Construct]] trap called') + }; +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/shell.js b/js/src/tests/test262/built-ins/Array/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A1.1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A1.1_T1.js new file mode 100644 index 0000000000..1f70e9b735 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A1.1_T1.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If length equal zero, call the [[Put]] method of this object + with arguments "length" and 0 and return undefined +esid: sec-array.prototype.shift +description: Checking this algorithm +---*/ + +var x = new Array(); +var shift = x.shift(); +if (shift !== undefined) { + throw new Test262Error('#1: var x = new Array(); x.shift() === undefined. Actual: ' + (shift)); +} + +if (x.length !== 0) { + throw new Test262Error('#2: var x = new Array(); x.shift(); x.length === 0. Actual: ' + (x.length)); +} + +var x = Array(1, 2, 3); +x.length = 0; +var shift = x.shift(); +if (shift !== undefined) { + throw new Test262Error('#2: var x = Array(1,2,3); x.length = 0; x.shift() === undefined. Actual: ' + (shift)); +} + +if (x.length !== 0) { + throw new Test262Error('#4: var x = new Array(1,2,3); x.length = 0; x.shift(); x.length === 0. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A1.2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A1.2_T1.js new file mode 100644 index 0000000000..a0e9c13392 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A1.2_T1.js @@ -0,0 +1,60 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The first element of the array is removed from the array and + returned +esid: sec-array.prototype.shift +description: Checking this use new Array() and [] +---*/ + +var x = new Array(0, 1, 2, 3); +var shift = x.shift(); +if (shift !== 0) { + throw new Test262Error('#1: x = new Array(0,1,2,3); x.shift() === 0. Actual: ' + (shift)); +} + +if (x.length !== 3) { + throw new Test262Error('#2: x = new Array(0,1,2,3); x.shift(); x.length == 3'); +} + +if (x[0] !== 1) { + throw new Test262Error('#3: x = new Array(0,1,2,3); x.shift(); x[0] == 1'); +} + +if (x[1] !== 2) { + throw new Test262Error('#4: x = new Array(0,1,2,3); x.shift(); x[1] == 2'); +} + +x = []; +x[0] = 0; +x[3] = 3; +var shift = x.shift(); +if (shift !== 0) { + throw new Test262Error('#5: x = []; x[0] = 0; x[3] = 3; x.shift() === 0. Actual: ' + (shift)); +} + +if (x.length !== 3) { + throw new Test262Error('#6: x = []; x[0] = 0; x[3] = 3; x.shift(); x.length == 3'); +} + +if (x[0] !== undefined) { + throw new Test262Error('#7: x = []; x[0] = 0; x[3] = 3; x.shift(); x[0] == undefined'); +} + +if (x[12] !== undefined) { + throw new Test262Error('#8: x = []; x[0] = 0; x[3] = 3; x.shift(); x[1] == undefined'); +} + +x.length = 1; +var shift = x.shift(); +if (shift !== undefined) { + throw new Test262Error('#9: x = []; x[0] = 0; x[3] = 3; x.shift(); x.length = 1; x.shift() === undefined. Actual: ' + (shift)); +} + +if (x.length !== 0) { + throw new Test262Error('#10: x = []; x[0] = 0; x[3] = 3; x.shift(); x.length = 1; x.shift(); x.length === 0. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T1.js new file mode 100644 index 0000000000..29f2f4f311 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T1.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The shift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.shift +description: > + If ToUint32(length) equal zero, call the [[Put]] method of this + object with arguments "length" and 0 and return undefined +---*/ + +var obj = {}; +obj.shift = Array.prototype.shift; + +if (obj.length !== undefined) { + throw new Test262Error('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + var shift = obj.shift(); + if (shift !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); + } + if (obj.length !== 0) { + throw new Test262Error('#2: var obj = {}; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); + } +} + +obj.length = undefined; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#3: var obj = {}; obj.length = undefined; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +if (obj.length !== 0) { + throw new Test262Error('#4: var obj = {}; obj.length = undefined; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} + +obj.length = null +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.length = null; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +if (obj.length !== 0) { + throw new Test262Error('#6: var obj = {}; obj.length = null; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T2.js new file mode 100644 index 0000000000..cbe2c18644 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T2.js @@ -0,0 +1,71 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The shift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.shift +description: > + If ToUint32(length) equal zero, call the [[Put]] method of this + object with arguments "length" and 0 and return undefined +---*/ + +var obj = {}; +obj.shift = Array.prototype.shift; + +obj.length = NaN; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.length = NaN; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +if (obj.length !== 0) { + throw new Test262Error('#2: var obj = {}; obj.length = NaN; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} + +obj.length = Number.NEGATIVE_INFINITY; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +if (obj.length !== 0) { + throw new Test262Error('#6: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} + +obj.length = -0; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#7: var obj = {}; obj.length = -0; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +if (obj.length !== 0) { + throw new Test262Error('#8: var obj = {}; obj.length = -0; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} else { + if (1 / obj.length !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#8: var obj = {}; obj.length = -0; obj.shift = Array.prototype.shift; obj.shift(); obj.length === +0. Actual: ' + (obj.length)); + } +} + +obj.length = 0.5; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#9: var obj = {}; obj.length = 0.5; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +if (obj.length !== 0) { + throw new Test262Error('#10: var obj = {}; obj.length = 0.5; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} + +obj.length = new Number(0); +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#11: var obj = {}; obj.length = new Number(0); obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +if (obj.length !== 0) { + throw new Test262Error('#12: var obj = {}; obj.length = new Number(0); obj.shift = Array.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T3.js b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T3.js new file mode 100644 index 0000000000..13d371b6ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T3.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The shift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.shift +description: > + The first element of the array is removed from the array and + returned +---*/ + +var obj = {}; +obj.shift = Array.prototype.shift; + +obj.length = 2.5; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.length = 2.5; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +if (obj.length !== 1) { + throw new Test262Error('#2: var obj = {}; obj.length = 2.5; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 1. Actual: ' + (obj.length)); +} + +obj.length = new Number(2); +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#11: var obj = {}; obj.length = new Number(2); obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +if (obj.length !== 1) { + throw new Test262Error('#12: var obj = {}; obj.length = new Number(2); obj.shift = Array.prototype.shift; obj.shift(); obj.length === 1. Actual: ' + (obj.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T4.js b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T4.js new file mode 100644 index 0000000000..1f315396cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T4.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The shift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.shift +description: > + The first element of the array is removed from the array and + returned +---*/ + +var obj = {}; +obj["0"] = 0; +obj["3"] = 3; +obj.shift = Array.prototype.shift; + +obj.length = 4; +var shift = obj.shift(); +if (shift !== 0) { + throw new Test262Error('#1: var obj = {}; obj["0"] = 0; obj["3"] = 3; obj.length = 4; obj.shift = Array.prototype.shift; obj.shift() === 0. Actual: ' + (shift)); +} + +if (obj.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj["0"] = 0; obj["3"] = 3; obj.length = 4; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 3. Actual: ' + (obj.length)); +} + +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#3: var obj = {}; obj["0"] = 0; obj["3"] = 3; obj.length = 4; obj.shift = Array.prototype.shift; obj.shift(); obj.shift() === undefined. Actual: ' + (shift)); +} + +if (obj.length !== 2) { + throw new Test262Error('#4: var obj = {}; obj["0"] = 0; obj["3"] = 3; obj.length = 4; obj.shift = Array.prototype.shift; obj.shift(); obj.shift(); obj.length === 2. Actual: ' + (obj.length)); +} + +obj.length = 1; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#5: var obj = {}; obj["0"] = 0; obj["3"] = 3; obj.length = 4; obj.shift = Array.prototype.shift; obj.shift(); obj.shift(); obj.length = 1; obj.shift() === undefined. Actual: ' + (shift)); +} + +if (obj.length !== 0) { + throw new Test262Error('#6: var obj = {}; obj["0"] = 0; obj["3"] = 3; obj.length = 4; obj.shift = Array.prototype.shift; obj.shift(); obj.shift(); obj.length = 1; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T5.js b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T5.js new file mode 100644 index 0000000000..76b01bbe57 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T5.js @@ -0,0 +1,126 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The shift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.shift +description: > + Operator use ToNumber from length. If Type(value) is Object, + evaluate ToPrimitive(value, Number) +---*/ + +var obj = {}; +obj.shift = Array.prototype.shift; + +obj[0] = -1; +obj.length = { + valueOf() { + return 1 + } +}; +var shift = obj.shift(); +assert.sameValue(shift, -1, 'The value of shift is expected to be -1'); + +obj[0] = -1; +obj.length = { + valueOf() { + return 1 + }, + toString() { + return 0 + } +}; +var shift = obj.shift(); +assert.sameValue(shift, -1, 'The value of shift is expected to be -1'); + +obj[0] = -1; +obj.length = { + valueOf() { + return 1 + }, + toString() { + return {} + } +}; +var shift = obj.shift(); +assert.sameValue(shift, -1, 'The value of shift is expected to be -1'); + +try { + obj[0] = -1; + obj.length = { + valueOf() { + return 1 + }, + toString() { + throw "error" + } + }; + var shift = obj.shift(); + assert.sameValue(shift, -1, 'The value of shift is expected to be -1'); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} + +obj[0] = -1; +obj.length = { + toString() { + return 0 + } +}; +var shift = obj.shift(); +assert.sameValue(shift, undefined, 'The value of shift is expected to equal undefined'); + +obj[0] = -1; +obj.length = { + valueOf() { + return {} + }, + toString() { + return 0 + } +} +var shift = obj.shift(); +assert.sameValue(shift, undefined, 'The value of shift is expected to equal undefined'); + +try { + obj[0] = -1; + obj.length = { + valueOf() { + throw "error" + }, + toString() { + return 0 + } + }; + var shift = obj.shift(); + throw new Test262Error('#7.1: obj[0] = -1; obj.length = {valueOf() {throw "error"}, toString() {return 0}}; obj.shift() throw "error". Actual: ' + (shift)); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} + +try { + obj[0] = -1; + obj.length = { + valueOf() { + return {} + }, + toString() { + return {} + } + }; + var shift = obj.shift(); + throw new Test262Error('#8.1: obj[0] = -1; obj.length = {valueOf() {return {}}, toString() {return {}}} obj.shift() throw TypeError. Actual: ' + (shift)); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A3_T3.js b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A3_T3.js new file mode 100644 index 0000000000..70d9a86cd0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A3_T3.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.shift +description: length is arbitrarily +---*/ + +var obj = {}; +obj.shift = Array.prototype.shift; +obj[0] = "x"; +obj[1] = "y"; +obj.length = -4294967294; + +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.shift = Array.prototype.shift; obj[0] = "x"; obj[1] = "y"; obj.length = -4294967294; obj.shift() === undefined. Actual: ' + (shift)); +} + +if (obj.length !== 0) { + throw new Test262Error('#2: var obj = {}; obj.shift = Array.prototype.shift; obj[0] = "x"; obj[1] = "y"; obj.length = -4294967294; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} + +if (obj[0] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.shift = Array.prototype.shift; obj[0] = "x"; obj[1] = "y"; obj.length = -4294967294; obj.shift(); obj[0] === "x". Actual: ' + (obj[0])); +} + +if (obj[1] !== "y") { + throw new Test262Error('#4: var obj = {}; obj.shift = Array.prototype.shift; obj[0] = "x" obj[1] = "y"; obj.length = -4294967294; obj.shift(); obj[1] === "y". Actual: ' + (obj[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A4_T1.js b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A4_T1.js new file mode 100644 index 0000000000..8865e88e73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A4_T1.js @@ -0,0 +1,58 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.shift +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Array.prototype[1] = 1; +var x = [0]; +x.length = 2; + +var shift = x.shift(); +if (shift !== 0) { + throw new Test262Error('#1: Array.prototype[1] = 1; x = [0]; x.length = 2; x.shift() === 0. Actual: ' + (shift)); +} + +if (x[0] !== 1) { + throw new Test262Error('#2: Array.prototype[1] = 1; x = [0]; x.length = 2; x.shift(); x[0] === 1. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#3: Array.prototype[1] = 1; x = [0]; x.length = 2; x.shift(); x[1] === 1. Actual: ' + (x[1])); +} + +Object.prototype[1] = 1; +Object.prototype.length = 2; +Object.prototype.shift = Array.prototype.shift; +x = { + 0: 0 +}; + +var shift = x.shift(); +if (shift !== 0) { + throw new Test262Error('#4: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.shift = Array.prototype.shift; x = {0:0}; x.shift() === 0. Actual: ' + (shift)); +} + +if (x[0] !== 1) { + throw new Test262Error('#5: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.shift = Array.prototype.shift; x = {0:0}; x.shift(); x[0] === 1. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#6: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.shift = Array.prototype.shift; x = {0:0}; x.shift(); x[1] === 1. Actual: ' + (x[1])); +} + +if (x.length !== 1) { + throw new Test262Error('#7: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.shift = Array.prototype.shift; x = {0:0}; x.shift(); x.length === 1. Actual: ' + (x.length)); +} + +delete x.length; +if (x.length !== 2) { + throw new Test262Error('#8: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.shift = Array.prototype.shift; x = {0:0}; x.shift(); delete x; x.length === 2. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A4_T2.js b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A4_T2.js new file mode 100644 index 0000000000..def860e177 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A4_T2.js @@ -0,0 +1,59 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.shift +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Array.prototype[1] = -1; +var x = [0, 1]; +x.length = 2; + +var shift = x.shift(); +if (shift !== 0) { + throw new Test262Error('#1: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.shift() === 0. Actual: ' + (shift)); +} + +if (x[0] !== 1) { + throw new Test262Error('#2: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.shift(); x[0] === 1. Actual: ' + (x[0])); +} + +if (x[1] !== -1) { + throw new Test262Error('#3: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.shift(); x[1] === -1. Actual: ' + (x[1])); +} + +Object.prototype[1] = -1; +Object.prototype.length = 2; +Object.prototype.shift = Array.prototype.shift; +x = { + 0: 0, + 1: 1 +}; + +var shift = x.shift(); +if (shift !== 0) { + throw new Test262Error('#4: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.shift = Array.prototype.shift; x = {0:0,1:1}; x.shift() === 0. Actual: ' + (shift)); +} + +if (x[0] !== 1) { + throw new Test262Error('#5: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.shift = Array.prototype.shift; x = {0:0,1:1}; x.shift(); x[0] === 1. Actual: ' + (x[0])); +} + +if (x[1] !== -1) { + throw new Test262Error('#6: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.shift = Array.prototype.shift; x = {0:0,1:1}; x.shift(); x[1] === -1. Actual: ' + (x[1])); +} + +if (x.length !== 1) { + throw new Test262Error('#7: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.shift = Array.prototype.shift; x = {0:0,1:1}; x.shift(); x.length === 1. Actual: ' + (x.length)); +} + +delete x.length; +if (x.length !== 2) { + throw new Test262Error('#8: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.shift = Array.prototype.shift; x = {0:0,1:1}; x.shift(); delete x; x.length === 2. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/browser.js b/js/src/tests/test262/built-ins/Array/prototype/shift/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/shift/call-with-boolean.js new file mode 100644 index 0000000000..142fa3a6d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/call-with-boolean.js @@ -0,0 +1,20 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.shift +description: Array.prototype.shift applied to boolean primitive +---*/ + +assert.sameValue( + Array.prototype.shift.call(true), + undefined, + 'Array.prototype.shift.call(true) must return undefined' +); +assert.sameValue( + Array.prototype.shift.call(false), + undefined, + 'Array.prototype.shift.call(false) must return undefined' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/length.js b/js/src/tests/test262/built-ins/Array/prototype/shift/length.js new file mode 100644 index 0000000000..08932c056d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.shift +description: > + The "length" property of Array.prototype.shift +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.shift.length, 0); + +verifyNotEnumerable(Array.prototype.shift, 'length'); +verifyNotWritable(Array.prototype.shift, 'length'); +verifyConfigurable(Array.prototype.shift, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/name.js b/js/src/tests/test262/built-ins/Array/prototype/shift/name.js new file mode 100644 index 0000000000..a64cdab03f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.shift +description: > + Array.prototype.shift.name is "shift". +info: | + Array.prototype.shift ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.shift.name, "shift"); + +verifyNotEnumerable(Array.prototype.shift, "name"); +verifyNotWritable(Array.prototype.shift, "name"); +verifyConfigurable(Array.prototype.shift, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/shift/not-a-constructor.js new file mode 100644 index 0000000000..b58cbbb0fa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/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: > + Array.prototype.shift 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.shift), + false, + 'isConstructor(Array.prototype.shift) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.shift(); +}, '`new Array.prototype.shift()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/shift/prop-desc.js new file mode 100644 index 0000000000..851e87947e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.shift +description: > + "shift" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.shift, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "shift"); +verifyWritable(Array.prototype, "shift"); +verifyConfigurable(Array.prototype, "shift"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/set-length-array-is-frozen.js b/js/src/tests/test262/built-ins/Array/prototype/shift/set-length-array-is-frozen.js new file mode 100644 index 0000000000..30064e098d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/set-length-array-is-frozen.js @@ -0,0 +1,45 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.shift +description: > + A TypeError is thrown when "length" is [[Set]] on a frozen array. +info: | + Array.prototype.shift ( ) + + [...] + 4. Let first be ? Get(O, "0"). + [...] + 8. Perform ? Set(O, "length", 𝔽(len - 1), true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = new Array(1); +var arrayPrototypeGet0Calls = 0; + +Object.defineProperty(Array.prototype, "0", { + get() { + Object.freeze(array); + arrayPrototypeGet0Calls++; + }, +}); + +assert.throws(TypeError, function() { + array.shift(); +}); + +assert.sameValue(array.length, 1); +assert.sameValue(arrayPrototypeGet0Calls, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/set-length-array-length-is-non-writable.js b/js/src/tests/test262/built-ins/Array/prototype/shift/set-length-array-length-is-non-writable.js new file mode 100644 index 0000000000..2094475bd9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/set-length-array-length-is-non-writable.js @@ -0,0 +1,45 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.shift +description: > + A TypeError is thrown when "length" is [[Set]] on an array with non-writable "length". +info: | + Array.prototype.shift ( ) + + [...] + 4. Let first be ? Get(O, "0"). + [...] + 8. Perform ? Set(O, "length", 𝔽(len - 1), true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = new Array(1); +var arrayPrototypeGet0Calls = 0; + +Object.defineProperty(Array.prototype, "0", { + get() { + Object.defineProperty(array, "length", { writable: false }); + arrayPrototypeGet0Calls++; + }, +}); + +assert.throws(TypeError, function() { + array.shift(); +}); + +assert.sameValue(array.length, 1); +assert.sameValue(arrayPrototypeGet0Calls, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/set-length-zero-array-is-frozen.js b/js/src/tests/test262/built-ins/Array/prototype/shift/set-length-zero-array-is-frozen.js new file mode 100644 index 0000000000..6e5a16be2d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/set-length-zero-array-is-frozen.js @@ -0,0 +1,34 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.shift +description: > + A TypeError is thrown when "length" is [[Set]] on an empty frozen array. +info: | + Array.prototype.shift ( ) + + [...] + 3. If len = 0, then + a. Perform ? Set(O, "length", +0𝔽, true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = []; +Object.freeze(array); + +assert.throws(TypeError, function() { + array.shift(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/set-length-zero-array-length-is-non-writable.js b/js/src/tests/test262/built-ins/Array/prototype/shift/set-length-zero-array-length-is-non-writable.js new file mode 100644 index 0000000000..d7ee7f8f6e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/set-length-zero-array-length-is-non-writable.js @@ -0,0 +1,34 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.shift +description: > + A TypeError is thrown when "length" is [[Set]] on an empty array with non-writable "length". +info: | + Array.prototype.shift ( ) + + [...] + 3. If len = 0, then + a. Perform ? Set(O, "length", +0𝔽, true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = []; +Object.defineProperty(array, "length", { writable: false }); + +assert.throws(TypeError, function() { + array.shift(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/shell.js b/js/src/tests/test262/built-ins/Array/prototype/shift/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/throws-when-this-value-length-is-writable-false.js b/js/src/tests/test262/built-ins/Array/prototype/shift/throws-when-this-value-length-is-writable-false.js new file mode 100644 index 0000000000..1c03b29e68 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/throws-when-this-value-length-is-writable-false.js @@ -0,0 +1,37 @@ +// Copyright (C) 2020 Sony Interactive Entertainment Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.shift +description: > + Array#shift throws TypeError if this value's "length" property was defined with [[Writable]]: false. +info: | + Array.prototype.shift ( ) + ... + 3. If len is zero, then + a. Perform ? Set(O, "length", 0, true). + ... + 8. Perform ? Set(O, "length", len - 1, true). + + Set ( O, P, V, Throw ) + ... + 4. Let success be ? O.[[Set]](P, V, O). + 5. If success is false and Throw is true, throw a TypeError exception. +---*/ + +assert.throws(TypeError, () => { + Array.prototype.shift.call(''); +}, "Array.prototype.shift.call('')"); + +assert.throws(TypeError, () => { + Array.prototype.shift.call('abc'); +}, "Array.prototype.shift.call('abc')"); + +assert.throws(TypeError, () => { + Array.prototype.shift.call(function() {}); +}, "Array.prototype.shift.call(function() {})"); + +assert.throws(TypeError, () => { + Array.prototype.shift.call(Object.defineProperty({}, 'length', {writable: false})); +}, "Array.prototype.shift.call(Object.defineProperty({}, 'length', {writable: false}))"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/15.4.4.10-10-c-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/slice/15.4.4.10-10-c-ii-1.js new file mode 100644 index 0000000000..4289b144ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/15.4.4.10-10-c-ii-1.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.slice +description: > + Array.prototype.slice will slice a string from start to end when + index property (read-only) exists in Array.prototype (Step 10.c.ii) +---*/ + +var arrObj = [1, 2, 3]; + +Object.defineProperty(Array.prototype, "0", { + value: "test", + writable: false, + configurable: true +}); + +var newArr = arrObj.slice(0, 1); + +assert(newArr.hasOwnProperty("0"), 'newArr.hasOwnProperty("0") !== true'); +assert.sameValue(newArr[0], 1, 'newArr[0]'); +assert.sameValue(typeof newArr[1], "undefined", 'typeof newArr[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T1.js new file mode 100644 index 0000000000..08b9e8f6ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T1.js @@ -0,0 +1,40 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length > end > start = 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(0, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T2.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T2.js new file mode 100644 index 0000000000..e2ad4f1103 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T2.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length > end = start > 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(3, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(3,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(3,3); arr.length === 0. Actual: ' + (arr.length)); +} + +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(3,3); arr[0] === undefined. Actual: ' + (arr[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T3.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T3.js new file mode 100644 index 0000000000..098fe5df6a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T3.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length > start > end > 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(4, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(4,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(4,3); arr.length === 0. Actual: ' + (arr.length)); +} + +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(4,3); arr[0] === undefined. Actual: ' + (arr[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T4.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T4.js new file mode 100644 index 0000000000..2a60f0819c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T4.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length = end = start > 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(5, 5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(5,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(5,5); arr.length === 0. Actual: ' + (arr.length)); +} + +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(5,5); arr[0] === undefined. Actual: ' + (arr[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T5.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T5.js new file mode 100644 index 0000000000..52276cb431 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T5.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length = end > start > 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(3, 5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(3,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(3,5); arr.length === 2. Actual: ' + (arr.length)); +} + +if (arr[0] !== 3) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(3,5); arr[0] === 3. Actual: ' + (arr[0])); +} + +if (arr[1] !== 4) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(3,5); arr[1] === 4. Actual: ' + (arr[1])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(3,5); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T6.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T6.js new file mode 100644 index 0000000000..c33acf360c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T6.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length > end > start > 0; +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(2, 4); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(2,4); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(2,4); arr.length === 2. Actual: ' + (arr.length)); +} + +if (arr[0] !== 2) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(2,4); arr[0] === 2. Actual: ' + (arr[0])); +} + +if (arr[1] !== 3) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(2,4); arr[1] === 3. Actual: ' + (arr[1])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(2,4); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T7.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T7.js new file mode 100644 index 0000000000..608a2d1dfe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T7.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: end > length > start > 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(3, 6); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(3,6); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(3,6); arr.length === 2. Actual: ' + (arr.length)); +} + +if (arr[0] !== 3) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(3,6); arr[0] === 3. Actual: ' + (arr[0])); +} + +if (arr[1] !== 4) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(3,6); arr[1] === 4. Actual: ' + (arr[1])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(3,6); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T1.js new file mode 100644 index 0000000000..cf4b16b79d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T1.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length > end = abs(start), start < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-3, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-3,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 1) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-3,3); arr.length === 1. Actual: ' + (arr.length)); +} + +if (arr[0] !== 2) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-3,3); arr[0] === 2. Actual: ' + (arr[0])); +} + +if (arr[1] !== undefined) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-3,3); arr[1] === undefined. Actual: ' + (arr[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T2.js new file mode 100644 index 0000000000..2c37d6d9b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T2.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length = end > abs(start), start < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-1, 5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-1,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 1) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-1,5); arr.length === 1. Actual: ' + (arr.length)); +} + +if (arr[0] !== 4) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-1,5); arr[0] === 4. Actual: ' + (arr[0])); +} + +if (arr[1] !== undefined) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-1,5); arr[1] === undefined. Actual: ' + (arr[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T3.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T3.js new file mode 100644 index 0000000000..dc5a28a18f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T3.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: abs(start) = length > end > 0, start < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-5, 1); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-5,1); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 1) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-5,1); arr.length === 1. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-5,1); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== undefined) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-5,1); arr[1] === undefined. Actual: ' + (arr[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T4.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T4.js new file mode 100644 index 0000000000..3cabccfb46 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T4.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: abs(start) > length = end > 0, start < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-9, 5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 5) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr.length === 5. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[3] === 3. Actual: ' + (arr[3])); +} + +if (arr[4] !== 4) { + throw new Test262Error('#7: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[4] === 4. Actual: ' + (arr[4])); +} + +if (arr[5] !== undefined) { + throw new Test262Error('#8: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[5] === undefined. Actual: ' + (arr[5])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T1.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T1.js new file mode 100644 index 0000000000..8ba48c3fbf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T1.js @@ -0,0 +1,40 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: length > abs(end) > start = 0, end < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(0, -2); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T2.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T2.js new file mode 100644 index 0000000000..d9cd34fae4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T2.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: length > abs(end) > start > 0, end < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(1, -4); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(1,-4); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(1,-4); arr.length === 0. Actual: ' + (arr.length)); +} + +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(1,-4); arr[0] === undefined. Actual: ' + (arr[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T3.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T3.js new file mode 100644 index 0000000000..cee2aa722a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T3.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: length = abs(end) > start = 0, end < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(0, -5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,-5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,-5); arr.length === 0. Actual: ' + (arr.length)); +} + +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,-5); arr[0] === undefined. Actual: ' + (arr[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T4.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T4.js new file mode 100644 index 0000000000..b8e5c2de02 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T4.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: abs(end) > length > start > 0, end < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(4, -9); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(4,-9); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(4,-9); arr.length === 0. Actual: ' + (arr.length)); +} + +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(4,-9); arr[0] === undefined. Actual: ' + (arr[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T1.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T1.js new file mode 100644 index 0000000000..4d3497d8c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T1.js @@ -0,0 +1,40 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: -length = start < end < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-5, -2); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T2.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T2.js new file mode 100644 index 0000000000..dc5edeb65b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T2.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: -length < start < end < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-3, -1); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-3,-1); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-3,-1); arr.length === 2. Actual: ' + (arr.length)); +} + +if (arr[0] !== 2) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-3,-1); arr[0] === 2. Actual: ' + (arr[0])); +} + +if (arr[1] !== 3) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-3,-1); arr[1] === 3. Actual: ' + (arr[1])); +} + +if (arr[2] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(-3,-1); arr[2] === undefined. Actual: ' + (arr[2])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T3.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T3.js new file mode 100644 index 0000000000..2ad1794dc5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T3.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: start < -length < end < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-9, -1); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 4) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr.length === 4. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr[3] === 3. Actual: ' + (arr[3])); +} + +if (arr[4] !== undefined) { + throw new Test262Error('#7: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr[4] === undefined. Actual: ' + (arr[4])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T4.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T4.js new file mode 100644 index 0000000000..559654a7a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T4.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: start = end < -length +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-6, -6); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-6,-6); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-6,-6); arr.length === 0. Actual: ' + (arr.length)); +} + +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-6,-6); arr[0] === undefined. Actual: ' + (arr[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.5_T1.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.5_T1.js new file mode 100644 index 0000000000..8003dd6aa0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.5_T1.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If end is undefined use length +esid: sec-array.prototype.slice +description: end === undefined +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(3, undefined); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(3, undefined); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(3, undefined); arr.length === 2. Actual: ' + (arr.length)); +} + +if (arr[0] !== 3) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(3, undefined); arr[0] === 3. Actual: ' + (arr[0])); +} + +if (arr[1] !== 4) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(3, undefined); arr[1] === 4. Actual: ' + (arr[1])); +} + +if (arr[2] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(3, undefined); arr[2] === undefined. Actual: ' + (arr[2])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.5_T2.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.5_T2.js new file mode 100644 index 0000000000..38fdc5e779 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.5_T2.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If end is undefined use length +esid: sec-array.prototype.slice +description: end is absent +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-2); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-2); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-2); arr.length === 2. Actual: ' + (arr.length)); +} + +if (arr[0] !== 3) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-2); arr[0] === 3. Actual: ' + (arr[0])); +} + +if (arr[1] !== 4) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-2); arr[1] === 4. Actual: ' + (arr[1])); +} + +if (arr[2] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(-2); arr[2] === undefined. Actual: ' + (arr[2])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T1.js new file mode 100644 index 0000000000..58e07e8b49 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T1.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.slice +description: start is not integer +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(2.5, 4); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(2.5,4); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(2.5,4); arr.length === 2. Actual: ' + (arr.length)); +} + +if (arr[0] !== 2) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(2.5,4); arr[0] === 2. Actual: ' + (arr[0])); +} + +if (arr[1] !== 3) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(2.5,4); arr[1] === 3. Actual: ' + (arr[1])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(2.5,4); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T2.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T2.js new file mode 100644 index 0000000000..61501fa6a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T2.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.slice +description: start = NaN +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(NaN, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T3.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T3.js new file mode 100644 index 0000000000..184c6a3d50 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T3.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.slice +description: start = Infinity +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(Number.POSITIVE_INFINITY, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(Number.POSITIVE_INFINITY,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(Number.POSITIVE_INFINITY,3); arr.length === 0. Actual: ' + (arr.length)); +} + +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(Number.POSITIVE_INFINITY,3); arr[0] === undefined. Actual: ' + (arr[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T4.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T4.js new file mode 100644 index 0000000000..c68293a53f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T4.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.slice +description: start = -Infinity +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(Number.NEGATIVE_INFINITY, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T5.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T5.js new file mode 100644 index 0000000000..5516c0de6d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T5.js @@ -0,0 +1,45 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.slice +description: ToInteger use ToNumber +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice({ + valueOf: function() { + return 0 + }, + toString: function() { + return 3 + } +}, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T1.js new file mode 100644 index 0000000000..3ce7f0e68b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T1.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from end +esid: sec-array.prototype.slice +description: end is not integer +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(2, 4.5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(2,4.5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(2,4.5); arr.length === 2. Actual: ' + (arr.length)); +} + +if (arr[0] !== 2) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(2,4.5); arr[0] === 2. Actual: ' + (arr[0])); +} + +if (arr[1] !== 3) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(2,4.5); arr[1] === 3. Actual: ' + (arr[1])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(2,4.5); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T2.js new file mode 100644 index 0000000000..a875da047b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T2.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from end +esid: sec-array.prototype.slice +description: end = NaN +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(0, NaN); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,NaN); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,NaN); arr.length === 0. Actual: ' + (arr.length)); +} + +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,NaN); arr[0] === undefined. Actual: ' + (arr[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T3.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T3.js new file mode 100644 index 0000000000..3cad37ddbe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T3.js @@ -0,0 +1,46 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from end +esid: sec-array.prototype.slice +description: end = Infinity +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(0, Number.POSITIVE_INFINITY); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 5) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr.length === 5. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[3] === 3. Actual: ' + (arr[3])); +} + +if (arr[4] !== 4) { + throw new Test262Error('#7: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[4] === 4. Actual: ' + (arr[4])); +} + +if (arr[5] !== undefined) { + throw new Test262Error('#8: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[5] === undefined. Actual: ' + (arr[5])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T4.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T4.js new file mode 100644 index 0000000000..14a9bbe26b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T4.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from end +esid: sec-array.prototype.slice +description: end = -Infinity +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(0, Number.NEGATIVE_INFINITY); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.NEGATIVE_INFINITY); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.NEGATIVE_INFINITY); arr.length === 0. Actual: ' + (arr.length)); +} + +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.NEGATIVE_INFINITY); arr[0] === undefined. Actual: ' + (arr[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T5.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T5.js new file mode 100644 index 0000000000..a5d20c21c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T5.js @@ -0,0 +1,45 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from end +esid: sec-array.prototype.slice +description: ToInteger use ToNumber +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(0, { + valueOf: function() { + return 3 + }, + toString: function() { + return 0 + } +}); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T1.js new file mode 100644 index 0000000000..2eedb258f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T1.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The slice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.slice +description: > + If start is positive, use min(start, length). If end is positive, + use min(end, length) +---*/ + +var obj = {}; +obj.slice = Array.prototype.slice; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +obj[4] = 4; +obj.length = 5; +var arr = obj.slice(0, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,3); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,3); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T2.js new file mode 100644 index 0000000000..017c5e5bc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T2.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The slice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.slice +description: > + If start is negative, use max(start + length, 0). If end is + positive, use min(end, length) +---*/ + +var obj = {}; +obj.slice = Array.prototype.slice; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +obj[4] = 4; +obj.length = 5; +var arr = obj.slice(-5, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,3); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,3); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T3.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T3.js new file mode 100644 index 0000000000..739b23457c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T3.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The slice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.slice +description: > + If start is positive, use min(start, length). If end is negative, + use max(end + length, 0) +---*/ + +var obj = {}; +obj.slice = Array.prototype.slice; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +obj[4] = 4; +obj.length = 5; +var arr = obj.slice(0, -2); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,-2); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,-2); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,-2); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,-2); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,-2); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,-2); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T4.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T4.js new file mode 100644 index 0000000000..2b70862d78 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T4.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The slice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.slice +description: > + If start is negative, use max(start + length, 0). If end is + negative, use max(end + length, 0) +---*/ + +var obj = {}; +obj.slice = Array.prototype.slice; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +obj[4] = 4; +obj.length = 5; +var arr = obj.slice(-5, -2); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,-2); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,-2); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,-2); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,-2); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,-2); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,-2); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T5.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T5.js new file mode 100644 index 0000000000..5adbd4e740 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T5.js @@ -0,0 +1,47 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The slice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.slice +description: If end is undefined use length +---*/ + +var obj = {}; +obj.slice = Array.prototype.slice; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +obj[4] = 4; +obj.length = 5; +var arr = obj.slice(2); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 2) { + throw new Test262Error('#3: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2); arr[0] === 2. Actual: ' + (arr[0])); +} + +if (arr[1] !== 3) { + throw new Test262Error('#4: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2); arr[1] === 3. Actual: ' + (arr[1])); +} + +if (arr[2] !== 4) { + throw new Test262Error('#5: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2); arr[2] === 4. Actual: ' + (arr[2])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T6.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T6.js new file mode 100644 index 0000000000..1646ec6982 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T6.js @@ -0,0 +1,47 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The slice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.slice +description: If end is undefined use length +---*/ + +var obj = {}; +obj.slice = Array.prototype.slice; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +obj[4] = 4; +obj.length = 5; +var arr = obj.slice(2, undefined); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2, undefined); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2, undefined); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 2) { + throw new Test262Error('#3: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2, undefined); arr[0] === 2. Actual: ' + (arr[0])); +} + +if (arr[1] !== 3) { + throw new Test262Error('#4: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2, undefined); arr[1] === 3. Actual: ' + (arr[1])); +} + +if (arr[2] !== 4) { + throw new Test262Error('#5: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2, undefined); arr[2] === 4. Actual: ' + (arr[2])); +} + +if (arr[3] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2, undefined); arr[3] === undefined. Actual: ' + (arr[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A3_T1.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A3_T1.js new file mode 100644 index 0000000000..882be8b71b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.slice +description: length = 4294967296 +---*/ + +assert.throws(RangeError, () => { + var obj = {}; + obj.slice = Array.prototype.slice; + obj[0] = "x"; + obj[4294967295] = "y"; + obj.length = 4294967296; + obj.slice(0, 4294967296); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A3_T2.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A3_T2.js new file mode 100644 index 0000000000..45d225c6b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A3_T2.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.slice +description: length = 4294967297 +---*/ + +assert.throws(RangeError, () => { + var obj = {}; + obj.slice = Array.prototype.slice; + obj[0] = "x"; + obj[4294967296] = "y"; + obj.length = 4294967297; + obj.slice(0, 4294967297); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A3_T3.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A3_T3.js new file mode 100644 index 0000000000..876eb9c4f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A3_T3.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToUint32(length) for non Array objects +esid: sec-array.prototype.slice +description: length = -1 +---*/ + +var obj = {}; +obj.slice = Array.prototype.slice; +obj[4294967294] = "x"; +obj.length = -1; +var arr = obj.slice(4294967294, 4294967295); + +if (arr.length !== 0) { + throw new Test262Error('#1: var obj = {}; obj.slice = Array.prototype.slice; obj[4294967294] = "x"; obj.length = 4294967295; var arr = obj.slice(4294967294,4294967295); arr.length === 0. Actual: ' + (arr.length)); +} + +if (arr[0] !== undefined) { + throw new Test262Error('#3: var obj = {}; obj.slice = Array.prototype.slice; obj[4294967294] = "x"; obj.length = 4294967295; var arr = obj.slice(4294967294,4294967295); arr[0] === undefined. Actual: ' + (arr[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A4_T1.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A4_T1.js new file mode 100644 index 0000000000..210f014a96 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A4_T1.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]] from not an inherited property" +esid: sec-array.prototype.slice +description: "[[Prototype]] of Array instance is Array.prototype" +---*/ + +Array.prototype[1] = 1; +var x = [0]; +x.length = 2; +var arr = x.slice(); + +if (arr[0] !== 0) { + throw new Test262Error('#1: Array.prototype[1] = 1; x = [0]; x.length = 2; var arr = x.slice(); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#2: Array.prototype[1] = 1; x = [0]; x.length = 2; var arr = x.slice(); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr.hasOwnProperty('1') !== true) { + throw new Test262Error('#3: Array.prototype[1] = 1; x = [0]; x.length = 2; var arr = x.slice(); arr.hasOwnProperty(\'1\') === true. Actual: ' + (arr.hasOwnProperty('1'))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/browser.js b/js/src/tests/test262/built-ins/Array/prototype/slice/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/slice/call-with-boolean.js new file mode 100644 index 0000000000..7441affadc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/call-with-boolean.js @@ -0,0 +1,13 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.slice +description: Array.prototype.slice applied to boolean primitive +includes: [compareArray.js] +---*/ + +assert.compareArray(Array.prototype.slice.call(true), [], 'Array.prototype.slice.call(true) must return []'); +assert.compareArray(Array.prototype.slice.call(false), [], 'Array.prototype.slice.call(false) must return []'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-ctor-non-object.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-ctor-non-object.js new file mode 100644 index 0000000000..6dd21c084f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-ctor-non-object.js @@ -0,0 +1,45 @@ +// 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-array.prototype.slice +description: > + Behavior when `constructor` property is neither an Object nor undefined +info: | + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 9. If IsConstructor(C) is false, throw a TypeError exception. +---*/ + +var a = []; + +a.constructor = null; +assert.throws(TypeError, function() { + a.slice(); +}, 'null value'); + +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.slice(); +}, 'number value'); + +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.slice(); +}, 'string value'); + +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.slice(); +}, 'boolean value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-ctor-poisoned.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-ctor-poisoned.js new file mode 100644 index 0000000000..bc5755d3ab --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-ctor-poisoned.js @@ -0,0 +1,29 @@ +// 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-array.prototype.slice +description: Abrupt completion from `constructor` property access +info: | + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). +---*/ + +var a = []; + +Object.defineProperty(a, 'constructor', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + a.slice(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-non-array-invalid-len.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-non-array-invalid-len.js new file mode 100644 index 0000000000..2e357f8c76 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-non-array-invalid-len.js @@ -0,0 +1,44 @@ +// 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-array.prototype.slice +description: Abrupt completion from creating a new array +info: | + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). + + 9.4.2.2 ArrayCreate + + [...] + 3. If length>232-1, throw a RangeError exception. +---*/ + +var callCount = 0; +var maxLength = Math.pow(2, 32); +var obj = Object.defineProperty({}, 'length', { + get: function() { + return maxLength; + }, + set: function() { + callCount += 1; + } +}); + +assert.throws(RangeError, function() { + Array.prototype.slice.call(obj); +}); + +assert.sameValue( + callCount, + 0, + 'RangeError thrown during array creation, not property modification' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-non-array.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-non-array.js new file mode 100644 index 0000000000..27a2032e03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-non-array.js @@ -0,0 +1,35 @@ +// 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-array.prototype.slice +description: Constructor is ignored for non-Array values +info: | + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). +---*/ + +var obj = { + length: 0 +}; +var callCount = 0; +var result; +Object.defineProperty(obj, 'constructor', { + get: function() { + callCount += 1; + } +}); + +result = Array.prototype.slice.call(obj); + +assert.sameValue(callCount, 0, '`constructor` property not accessed'); +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert(Array.isArray(result), 'result is an Array exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-proto-from-ctor-realm-array.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-proto-from-ctor-realm-array.js new file mode 100644 index 0000000000..79e647f5a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-proto-from-ctor-realm-array.js @@ -0,0 +1,45 @@ +// 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-array.prototype.slice +description: Prefer Array constructor of current realm record +info: | + 1. Let O be ? ToObject(this value). + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C + be undefined. + [...] +features: [cross-realm, Symbol.species] +---*/ + +var array = []; +var callCount = 0; +var OArray = $262.createRealm().global.Array; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OArray; + +Object.defineProperty(Array, Symbol.species, speciesDesc); +Object.defineProperty(OArray, Symbol.species, speciesDesc); + +result = array.slice(); + +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert.sameValue(callCount, 0, 'Species constructor is not referenced'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-proto-from-ctor-realm-non-array.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-proto-from-ctor-realm-non-array.js new file mode 100644 index 0000000000..e586b619b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-proto-from-ctor-realm-non-array.js @@ -0,0 +1,46 @@ +// 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-array.prototype.slice +description: Accept non-Array constructors from other realms +info: | + 1. Let O be ? ToObject(this value). + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C + be undefined. + [...] +features: [cross-realm, Symbol.species] +---*/ + +var array = []; +var callCount = 0; +var CustomCtor = function() {}; +var OObject = $262.createRealm().global.Object; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OObject; +OObject[Symbol.species] = CustomCtor; + +Object.defineProperty(Array, Symbol.species, speciesDesc); + +result = array.slice(); + +assert.sameValue(Object.getPrototypeOf(result), CustomCtor.prototype); +assert.sameValue(callCount, 0, 'Array species constructor is not referenced'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-proxied-array-invalid-len.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-proxied-array-invalid-len.js new file mode 100644 index 0000000000..8560161f69 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-proxied-array-invalid-len.js @@ -0,0 +1,54 @@ +// 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-array.prototype.slice +description: > + Ensure a RangeError is thrown when a proxied array returns an invalid array length. +info: | + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 10. Return ? Construct(C, « length »). + + 9.4.2.2 ArrayCreate + + [...] + 3. If length>2^32-1, throw a RangeError exception. +features: [Proxy] +---*/ + +var array = []; +var maxLength = Math.pow(2, 32); +var callCount = 0; +var proxy = new Proxy(array, { + get: function(_, name) { + if (name === 'length') { + return maxLength; + } + return array[name]; + }, + set: function() { + callCount += 1; + return true; + } +}); + +assert.throws(RangeError, function() { + Array.prototype.slice.call(proxy); +}); + +assert.sameValue( + callCount, + 0, + 'RangeError thrown during array creation, not property modification' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-proxy.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-proxy.js new file mode 100644 index 0000000000..7ad8ec6ea7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-proxy.js @@ -0,0 +1,41 @@ +// 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-array.prototype.slice +description: Species constructor of a Proxy object whose target is an array +info: | + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + 12. Return A. + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + + 7.2.2 IsArray + + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is + null, throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy, Symbol.species] +---*/ + +var array = []; +var proxy = new Proxy(new Proxy(array, {}), {}); +var Ctor = function() {}; +var result; + +array.constructor = function() {}; +array.constructor[Symbol.species] = Ctor; + +result = Array.prototype.slice.call(proxy); + +assert.sameValue(Object.getPrototypeOf(result), Ctor.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-revoked-proxy.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-revoked-proxy.js new file mode 100644 index 0000000000..3c240a5f2d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-revoked-proxy.js @@ -0,0 +1,41 @@ +// 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-array.prototype.slice +description: Abrupt completion from constructor that is a revoked Proxy object +info: | + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + + 7.2.2 IsArray + + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is + null, throw a TypeError exception. +features: [Proxy] +---*/ + +var o = Proxy.revocable([], {}); +var callCount = 0; + +Object.defineProperty(o.proxy, 'constructor', { + get: function() { + callCount += 1; + } +}); +o.revoke(); + +assert.throws(TypeError, function() { + Array.prototype.slice.call(o.proxy); +}); + +assert.sameValue(callCount, 0, '`constructor` property not accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-abrupt.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-abrupt.js new file mode 100644 index 0000000000..68755f9954 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-abrupt.js @@ -0,0 +1,35 @@ +// 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-array.prototype.slice +description: Species constructor returns an abrupt completion +info: | + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var Ctor = function() { + throw new Test262Error(); +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; + +assert.throws(Test262Error, function() { + a.slice(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-neg-zero.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-neg-zero.js new file mode 100644 index 0000000000..7ad5e272da --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-neg-zero.js @@ -0,0 +1,47 @@ +// 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-array.prototype.slice +description: The value `-0` is converted to `0` +info: | + [...] + 3. Let relativeStart be ? ToInteger(start). + 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k + be min(relativeStart, len). + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let + final be min(relativeEnd, len). + 7. Let count be max(final - k, 0). + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 2. If length is -0, let length be +0. + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var args; +var Ctor = function() { + args = arguments; +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; + +a.slice(0, -0); + +assert.sameValue(args.length, 1); +assert.sameValue(args[0], 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-non-ctor.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-non-ctor.js new file mode 100644 index 0000000000..bb254dfbad --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-non-ctor.js @@ -0,0 +1,41 @@ +// 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-array.prototype.slice +description: > + Behavior when the @@species attribute is a non-constructor object +info: | + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 9. If IsConstructor(C) is false, throw a TypeError exception. +includes: [isConstructor.js] +features: [Symbol.species, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(parseInt), + false, + 'precondition: isConstructor(parseInt) must return false' +); + +var a = []; + +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; + +assert.throws(TypeError, function() { + a.slice(); +}, 'a.slice() throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-null.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-null.js new file mode 100644 index 0000000000..b8788d0176 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-null.js @@ -0,0 +1,35 @@ +// 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-array.prototype.slice +description: > + A null value for the @@species constructor is interpreted as `undefined` +info: | + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). +features: [Symbol.species] +---*/ + +var a = []; +var result; + +a.constructor = {}; +a.constructor[Symbol.species] = null; + +result = a.slice(); + +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert(Array.isArray(result), 'result is an Array exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-poisoned.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-poisoned.js new file mode 100644 index 0000000000..dca55c685a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-poisoned.js @@ -0,0 +1,34 @@ +// 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-array.prototype.slice +description: Abrupt completion from `@@species` property access +info: | + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). +features: [Symbol.species] +---*/ + +var a = []; +a.constructor = {}; + +Object.defineProperty(a.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + a.slice(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-undef.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-undef.js new file mode 100644 index 0000000000..f92c033c79 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-undef.js @@ -0,0 +1,36 @@ +// 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-array.prototype.slice +description: > + An undefined value for the @@species constructor triggers the creation of + an Array exotic object +info: | + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). +features: [Symbol.species] +---*/ + +var a = []; +var result; + +a.constructor = {}; +a.constructor[Symbol.species] = undefined; + +result = a.slice(); + +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert(Array.isArray(result), 'result is an Array exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/create-species.js b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species.js new file mode 100644 index 0000000000..f27c43cf12 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species.js @@ -0,0 +1,45 @@ +// 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-array.prototype.slice +description: Species constructor is used to create a new instance +info: | + [...] + 8. Let A be ? ArraySpeciesCreate(O, count). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var thisValue, args, result; +var callCount = 0; +var instance = []; +var Ctor = function() { + callCount += 1; + thisValue = this; + args = arguments; + return instance; +}; +var a = [1, 2, 3, 4, 5]; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; + +result = a.slice(1, -1); + +assert.sameValue(callCount, 1, 'Constructor invoked exactly once'); +assert.sameValue(Object.getPrototypeOf(thisValue), Ctor.prototype); +assert.sameValue(args.length, 1, 'Constructor invoked with a single argument'); +assert.sameValue(args[0], 3); +assert.sameValue(result, instance); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/length-exceeding-integer-limit-proxied-array.js b/js/src/tests/test262/built-ins/Array/prototype/slice/length-exceeding-integer-limit-proxied-array.js new file mode 100644 index 0000000000..115de6fd58 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/length-exceeding-integer-limit-proxied-array.js @@ -0,0 +1,59 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.slice +description: > + Length property is clamped to 2^53-1, test with indices near 2^53-1 and negative indices + and a proxy to an array. +info: | + ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let relativeStart be ? ToInteger(start). + 4. If relativeStart < 0, let k be max((len + relativeStart), 0); + else let k be min(relativeStart, len). + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). + 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); + else let final be min(relativeEnd, len). + ... +includes: [compareArray.js] +features: [exponentiation] +---*/ + +var array = []; +array["9007199254740988"] = "9007199254740988"; +array["9007199254740989"] = "9007199254740989"; +array["9007199254740990"] = "9007199254740990"; +array["9007199254740991"] = "9007199254740991"; + +// Create a proxy to an array object, so IsArray returns true, but we can still +// return a length value exceeding the integer limit. +var proxy = new Proxy(array, { + get(t, pk, r) { + if (pk === "length") + return 2 ** 53 + 2; + return Reflect.get(t, pk, r); + } +}); + +var result = Array.prototype.slice.call(proxy, 9007199254740989); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + 'The value of result is expected to be ["9007199254740989", "9007199254740990"]'); + +var result = Array.prototype.slice.call(proxy, 9007199254740989, 9007199254740990); +assert.compareArray(result, ["9007199254740989"], + 'The value of result is expected to be ["9007199254740989"]'); + +var result = Array.prototype.slice.call(proxy, 9007199254740989, 9007199254740996); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + 'The value of result is expected to be ["9007199254740989", "9007199254740990"]'); + +var result = Array.prototype.slice.call(proxy, -2); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + 'The value of result is expected to be ["9007199254740989", "9007199254740990"]'); + +var result = Array.prototype.slice.call(proxy, -2, -1); +assert.compareArray(result, ["9007199254740989"], + 'The value of result is expected to be ["9007199254740989"]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/length-exceeding-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/slice/length-exceeding-integer-limit.js new file mode 100644 index 0000000000..789447f7de --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/length-exceeding-integer-limit.js @@ -0,0 +1,50 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.slice +description: > + Length property is clamped to 2^53-1, test with indices near 2^53-1 and negative indices. +info: | + ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let relativeStart be ? ToInteger(start). + 4. If relativeStart < 0, let k be max((len + relativeStart), 0); + else let k be min(relativeStart, len). + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). + 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); + else let final be min(relativeEnd, len). + ... +includes: [compareArray.js] +features: [exponentiation] +---*/ + +var arrayLike = { + "9007199254740988": "9007199254740988", + "9007199254740989": "9007199254740989", + "9007199254740990": "9007199254740990", + "9007199254740991": "9007199254740991", + length: 2 ** 53 + 2, +}; + +var result = Array.prototype.slice.call(arrayLike, 9007199254740989); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + 'The value of result is expected to be ["9007199254740989", "9007199254740990"]'); + +var result = Array.prototype.slice.call(arrayLike, 9007199254740989, 9007199254740990); +assert.compareArray(result, ["9007199254740989"], + 'The value of result is expected to be ["9007199254740989"]'); + +var result = Array.prototype.slice.call(arrayLike, 9007199254740989, 9007199254740996); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + 'The value of result is expected to be ["9007199254740989", "9007199254740990"]'); + +var result = Array.prototype.slice.call(arrayLike, -2); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + 'The value of result is expected to be ["9007199254740989", "9007199254740990"]'); + +var result = Array.prototype.slice.call(arrayLike, -2, -1); +assert.compareArray(result, ["9007199254740989"], + 'The value of result is expected to be ["9007199254740989"]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/length.js b/js/src/tests/test262/built-ins/Array/prototype/slice/length.js new file mode 100644 index 0000000000..2d0204600c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.slice +description: > + The "length" property of Array.prototype.slice +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.slice.length, 2); + +verifyNotEnumerable(Array.prototype.slice, 'length'); +verifyNotWritable(Array.prototype.slice, 'length'); +verifyConfigurable(Array.prototype.slice, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/name.js b/js/src/tests/test262/built-ins/Array/prototype/slice/name.js new file mode 100644 index 0000000000..b870be1e66 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.slice +description: > + Array.prototype.slice.name is "slice". +info: | + Array.prototype.slice (start, end) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.slice.name, "slice"); + +verifyNotEnumerable(Array.prototype.slice, "name"); +verifyNotWritable(Array.prototype.slice, "name"); +verifyConfigurable(Array.prototype.slice, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/slice/not-a-constructor.js new file mode 100644 index 0000000000..3504fae508 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/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: > + Array.prototype.slice 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.slice), + false, + 'isConstructor(Array.prototype.slice) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.slice(); +}, '`new Array.prototype.slice()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/slice/prop-desc.js new file mode 100644 index 0000000000..d0cd563ad9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.slice +description: > + "slice" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.slice, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "slice"); +verifyWritable(Array.prototype, "slice"); +verifyConfigurable(Array.prototype, "slice"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/shell.js b/js/src/tests/test262/built-ins/Array/prototype/slice/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/target-array-non-extensible.js b/js/src/tests/test262/built-ins/Array/prototype/slice/target-array-non-extensible.js new file mode 100644 index 0000000000..b470eefb53 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/target-array-non-extensible.js @@ -0,0 +1,41 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.slice +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible) +info: | + Array.prototype.slice ( start, end ) + + [...] + 10. Repeat, while k < final + [...] + c. If kPresent is true, then + [...] + ii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), kValue). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; + +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.slice(0, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/target-array-with-non-configurable-property.js b/js/src/tests/test262/built-ins/Array/prototype/slice/target-array-with-non-configurable-property.js new file mode 100644 index 0000000000..bc5ff6c8bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/target-array-with-non-configurable-property.js @@ -0,0 +1,43 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.slice +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable) +info: | + Array.prototype.slice ( start, end ) + + [...] + 10. Repeat, while k < final + [...] + c. If kPresent is true, then + [...] + ii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), kValue). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + set: function(_value) {}, + configurable: false, + }); +}; + +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.slice(0, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/target-array-with-non-writable-property.js b/js/src/tests/test262/built-ins/Array/prototype/slice/target-array-with-non-writable-property.js new file mode 100644 index 0000000000..7cb226e9e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/target-array-with-non-writable-property.js @@ -0,0 +1,38 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.slice +description: > + Non-writable properties are overwritten by CreateDataPropertyOrThrow. +info: | + 22.1.3.23 Array.prototype.slice ( start, end ) + + ... + 10. Repeat, while k < final + ... + c. If kPresent is true, then + ... + ii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), kValue). + ... +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var a = [1]; +a.constructor = {}; +a.constructor[Symbol.species] = function(len) { + var q = new Array(0); + Object.defineProperty(q, 0, { + value: 0, writable: false, configurable: true, enumerable: false, + }); + return q; +}; + +var r = a.slice(0); + +verifyProperty(r, 0, { + value: 1, writable: true, configurable: true, enumerable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-1.js new file mode 100644 index 0000000000..e5686d5c61 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to undefined throws a TypeError +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.some.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-10.js new file mode 100644 index 0000000000..bee571f686 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-10.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to the Math object +---*/ + +function callbackfn(val, idx, obj) { + return '[object Math]' === Object.prototype.toString.call(obj); +} + +Math.length = 1; +Math[0] = 1; + +assert(Array.prototype.some.call(Math, callbackfn), 'Array.prototype.some.call(Math, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-11.js new file mode 100644 index 0000000000..72a01a2661 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-11.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to Date object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Date; +} + +var obj = new Date(); +obj.length = 2; +obj[0] = 11; +obj[1] = 9; + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-12.js new file mode 100644 index 0000000000..2bb5c20495 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-12.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to RegExp object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof RegExp; +} + +var obj = new RegExp(); +obj.length = 2; +obj[0] = 11; +obj[1] = 9; + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-13.js new file mode 100644 index 0000000000..7bd579c7c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-13.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to the JSON object +---*/ + +function callbackfn(val, idx, obj) { + return '[object JSON]' === Object.prototype.toString.call(obj); +} + +JSON.length = 1; +JSON[0] = 1; + +assert(Array.prototype.some.call(JSON, callbackfn), 'Array.prototype.some.call(JSON, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-14.js new file mode 100644 index 0000000000..850951cfa6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-14.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to Error object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Error; +} + +var obj = new Error(); +obj.length = 1; +obj[0] = 1; + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-15.js new file mode 100644 index 0000000000..0a32218628 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-15.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to the Arguments object +---*/ + +function callbackfn(val, idx, obj) { + return '[object Arguments]' === Object.prototype.toString.call(obj); +} + +var obj = (function() { + return arguments; +}("a", "b")); + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-2.js new file mode 100644 index 0000000000..872b8fc793 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to null throws a TypeError +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.some.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-3.js new file mode 100644 index 0000000000..761a480f82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to boolean primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Boolean; +} + +Boolean.prototype[0] = 1; +Boolean.prototype.length = 1; + +assert(Array.prototype.some.call(false, callbackfn), 'Array.prototype.some.call(false, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-4.js new file mode 100644 index 0000000000..4f71153265 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-4.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to Boolean object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Boolean; +} + +var obj = new Boolean(true); +obj.length = 2; +obj[0] = 11; +obj[1] = 9; + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-5.js new file mode 100644 index 0000000000..883b2f1f9d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-5.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to number primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Number; +} + +Number.prototype[1] = true; +Number.prototype.length = 2; + +assert(Array.prototype.some.call(5, callbackfn), 'Array.prototype.some.call(5, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-6.js new file mode 100644 index 0000000000..9b1063d799 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-6.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to Number object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Number; +} + +var obj = new Number(-128); +obj.length = 2; +obj[0] = 11; +obj[1] = 9; + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-7.js new file mode 100644 index 0000000000..39ddced1e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-7.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to applied to string primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof String; +} + +assert(Array.prototype.some.call("hello\nw_orld\\!", callbackfn), 'Array.prototype.some.call("hello\nw_orld\\!", callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-8.js new file mode 100644 index 0000000000..4fa6c5b17e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-8.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to String object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof String; +} + +var obj = new String("hello\nw_orld\\!"); + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-9.js new file mode 100644 index 0000000000..ecdf02f662 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-1-9.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to Function object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Function; +} + +var obj = function(a, b) { + return a + b; +}; +obj[0] = 11; +obj[1] = 9; + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-1.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-1.js new file mode 100644 index 0000000000..fc7877d8dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is own data property on an + Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: 2 +}; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-10.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-10.js new file mode 100644 index 0000000000..3abc58824f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-10.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an inherited accessor property + on an Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 9; +child[1] = 11; +child[2] = 12; + +assert(Array.prototype.some.call(child, callbackfn1), 'Array.prototype.some.call(child, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(child, callbackfn2), false, 'Array.prototype.some.call(child, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-11.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-11.js new file mode 100644 index 0000000000..12d7578ef8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-11.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an own accessor property + without a get function on an Array-like object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-12.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-12.js new file mode 100644 index 0000000000..43f3078273 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-12.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is own accessor property without a + get function that overrides an inherited accessor property on an + Array-like object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-13.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-13.js new file mode 100644 index 0000000000..3afc23e399 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-13.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is inherited accessor property + without a get function on an Array-like object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 11; +child[1] = 12; + +assert.sameValue(Array.prototype.some.call(child, callbackfn), false, 'Array.prototype.some.call(child, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-14.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-14.js new file mode 100644 index 0000000000..ba200008dc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-14.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' property doesn't exist on an + Array-like object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + 1: 12 +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-17.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-17.js new file mode 100644 index 0000000000..9a17b8b8df --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-17.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some applied to the Arguments object which + implements its own property get method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var func = function(a, b) { + arguments[2] = 12; + return Array.prototype.some.call(arguments, callbackfn1) && + !Array.prototype.some.call(arguments, callbackfn2); +}; + +assert(func(9, 11), 'func(9, 11) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-18.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-18.js new file mode 100644 index 0000000000..72e6722f18 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-18.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some applied to String object which implements its + own property get method +---*/ + +function callbackfn1(val, idx, obj) { + return parseInt(val, 10) > 1; +} + +function callbackfn2(val, idx, obj) { + return parseInt(val, 10) > 2; +} + +var str = new String("12"); + +String.prototype[2] = "3"; + +assert(Array.prototype.some.call(str, callbackfn1), 'Array.prototype.some.call(str, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(str, callbackfn2), false, 'Array.prototype.some.call(str, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-19.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-19.js new file mode 100644 index 0000000000..671ec1f38e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-19.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some applied to Function object which implements + its own property get method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var fun = function(a, b) { + return a + b; +}; +fun[0] = 9; +fun[1] = 11; +fun[2] = 12; + +assert(Array.prototype.some.call(fun, callbackfn1), 'Array.prototype.some.call(fun, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(fun, callbackfn2), false, 'Array.prototype.some.call(fun, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-2.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-2.js new file mode 100644 index 0000000000..ceeb9d14a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-2.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - 'length' is own data property on an Array +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +Array.prototype[2] = 12; + +assert([9, 11].some(callbackfn1), '[9, 11].some(callbackfn1) !== true'); +assert.sameValue([9, 11].some(callbackfn2), false, '[9, 11].some(callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-3.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-3.js new file mode 100644 index 0000000000..bcd898d5d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-3.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an own data property that + overrides an inherited data property on an Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var proto = { + length: 3 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +child[0] = 9; +child[1] = 11; +child[2] = 12; + +assert(Array.prototype.some.call(child, callbackfn1), 'Array.prototype.some.call(child, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(child, callbackfn2), false, 'Array.prototype.some.call(child, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-4.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-4.js new file mode 100644 index 0000000000..b1ec0481e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-4.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an own data property that + overrides an inherited data property on an array +---*/ + +var arrProtoLen = 0; + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +arrProtoLen = Array.prototype.length; +Array.prototype.length = 0; +Array.prototype[2] = 12; + +assert([9, 11].some(callbackfn1), '[9, 11].some(callbackfn1) !== true'); +assert.sameValue([9, 11].some(callbackfn2), false, '[9, 11].some(callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-5.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-5.js new file mode 100644 index 0000000000..6c2554aea9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-5.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an own data property that + overrides an inherited accessor property on an Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); + +child[0] = 9; +child[1] = 11; +child[2] = 12; + +assert(Array.prototype.some.call(child, callbackfn1), 'Array.prototype.some.call(child, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(child, callbackfn2), false, 'Array.prototype.some.call(child, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-6.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-6.js new file mode 100644 index 0000000000..d4341c375d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-6.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an inherited data property on + an Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var proto = { + length: 2 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = 9; +child[1] = 11; +child[2] = 12; + +assert(Array.prototype.some.call(child, callbackfn1), 'Array.prototype.some.call(child, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(child, callbackfn2), false, 'Array.prototype.some.call(child, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-7.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-7.js new file mode 100644 index 0000000000..dec4139f90 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-7.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an own accessor property on an + Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +obj[0] = 9; +obj[1] = 11; +obj[2] = 12; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-8.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-8.js new file mode 100644 index 0000000000..80fbd84219 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-8.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an own accessor property that + overrides an inherited data property on an Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var proto = { + length: 3 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +child[0] = 9; +child[1] = 11; +child[2] = 12; + +assert(Array.prototype.some.call(child, callbackfn1), 'Array.prototype.some.call(child, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(child, callbackfn2), false, 'Array.prototype.some.call(child, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-9.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-9.js new file mode 100644 index 0000000000..77c0f4bf25 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-2-9.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an own accessor property that + overrides an inherited accessor property on an Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var proto = {}; + +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +child[0] = 9; +child[1] = 11; +child[2] = 12; + +assert(Array.prototype.some.call(child, callbackfn1), 'Array.prototype.some.call(child, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(child, callbackfn2), false, 'Array.prototype.some.call(child, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-1.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-1.js new file mode 100644 index 0000000000..4015731a97 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-1.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - value of 'length' is undefined +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + length: undefined +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-10.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-10.js new file mode 100644 index 0000000000..fc00017f5b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-10.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - value of 'length' is a number (value is NaN) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + length: NaN +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-11.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-11.js new file mode 100644 index 0000000000..303735bd8d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-11.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is a string containing a positive + number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: "2" +}; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-12.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-12.js new file mode 100644 index 0000000000..cbd6d7ad8b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-12.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is a string containing a negative + number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: "-4294967294" +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn1), false, 'Array.prototype.some.call(obj, callbackfn1)'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-13.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-13.js new file mode 100644 index 0000000000..7bd999ab0e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-13.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is a string containing a decimal + number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: "2.5" +}; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-14.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-14.js new file mode 100644 index 0000000000..764ae4ffb9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-14.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - 'length' is a string containing +/-Infinity +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var objOne = { + 0: 11, + length: "Infinity" +}; +var objTwo = { + 0: 11, + length: "+Infinity" +}; +var objThree = { + 0: 11, + length: "-Infinity" +}; + +assert(Array.prototype.some.call(objOne, callbackfn), 'Array.prototype.some.call(objOne, callbackfn) !== true'); +assert(Array.prototype.some.call(objTwo, callbackfn), 'Array.prototype.some.call(objTwo, callbackfn) !== true'); +assert.sameValue(Array.prototype.some.call(objThree, callbackfn), false, 'Array.prototype.some.call(objThree, callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-15.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-15.js new file mode 100644 index 0000000000..cf74a9a739 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-15.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is a string containing an + exponential number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: "2E0" +}; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-16.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-16.js new file mode 100644 index 0000000000..6619ada436 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-16.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - 'length' is a string containing a hex number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: "0x0002" +}; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-17.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-17.js new file mode 100644 index 0000000000..9d8840e640 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-17.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is a string containing a number + with leading zeros +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: "0002.00" +}; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-18.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-18.js new file mode 100644 index 0000000000..5f6e71fa33 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-18.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is a string that can't + convert to a number +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + 1: 21, + length: "two" +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-19.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-19.js new file mode 100644 index 0000000000..cf67025184 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-19.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is an Object which has an + own toString method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var toStringAccessed = false; +var obj = { + 0: 9, + 1: 11, + 2: 12, + + length: { + toString: function() { + toStringAccessed = true; + return '2'; + } + } +}; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); +assert(toStringAccessed, 'toStringAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-2.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-2.js new file mode 100644 index 0000000000..0feb782ac7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-2.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some on an Array-like object if 'length' is 1 + (length overridden to true(type conversion)) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 11, + 1: 12, + length: true +}; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-20.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-20.js new file mode 100644 index 0000000000..515a4eecd0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-20.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is an Object which has an + own valueOf method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var valueOfAccessed = false; + +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: { + valueOf: function() { + valueOfAccessed = true; + return 2; + } + } +}; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-21.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-21.js new file mode 100644 index 0000000000..e3304b7f40 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-21.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an object that has an own + valueOf method that returns an object and toString method that + returns a string +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var toStringAccessed = false; +var valueOfAccessed = false; + +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: { + valueOf: function() { + valueOfAccessed = true; + return {}; + }, + toString: function() { + toStringAccessed = true; + return '2'; + } + } +}; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert(toStringAccessed, 'toStringAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-22.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-22.js new file mode 100644 index 0000000000..1e1fb06e59 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-22.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some throws TypeError exception when 'length' is + an object with toString and valueOf methods that don�t return + primitive values +---*/ + +var callbackfnAccessed = false; +var toStringAccessed = false; +var valueOfAccessed = false; + +function callbackfn(val, idx, obj) { + callbackfnAccessed = true; + return val > 10; +} + +var obj = { + 0: 11, + 1: 12, + + length: { + valueOf: function() { + valueOfAccessed = true; + return {}; + }, + toString: function() { + toStringAccessed = true; + return {}; + } + } +}; +assert.throws(TypeError, function() { + Array.prototype.some.call(obj, callbackfn); +}); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(callbackfnAccessed, false, 'callbackfnAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-23.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-23.js new file mode 100644 index 0000000000..3bb1bb83b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-23.js @@ -0,0 +1,51 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some uses inherited valueOf method when 'length' + is an object with an own toString and inherited valueOf methods +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var valueOfAccessed = false; +var toStringAccessed = false; + +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +child.toString = function() { + toStringAccessed = true; + return '1'; +}; + +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: child +}; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-24.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-24.js new file mode 100644 index 0000000000..3d85a9f805 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-24.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 9, + 10: 11, + 11: 12, + length: 11.5 +}; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-25.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-25.js new file mode 100644 index 0000000000..03c16578b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-25.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - value of 'length' is a negative non-integer +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: -4294967294.5 +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn1), false, 'Array.prototype.some.call(obj, callbackfn1)'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-28.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-28.js new file mode 100644 index 0000000000..92e292cbd9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-28.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - value of 'length' is boundary value (2^32) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 12, + length: 4294967296 +}; + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-29.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-29.js new file mode 100644 index 0000000000..c3d0cd6c79 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-29.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is boundary value (2^32 + + 1) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 11, + 1: 12, + length: 4294967297 +}; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert(Array.prototype.some.call(obj, callbackfn2), 'Array.prototype.some.call(obj, callbackfn2) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-3.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-3.js new file mode 100644 index 0000000000..0010be28c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - value of 'length' is a number (value is 0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + length: 0 +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-4.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-4.js new file mode 100644 index 0000000000..94e4e0874c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-4.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - value of 'length' is a number (value is +0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + length: +0 +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-5.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-5.js new file mode 100644 index 0000000000..0edb95879b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-5.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - value of 'length' is a number (value is -0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + length: -0 +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-6.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-6.js new file mode 100644 index 0000000000..0d0986a6cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-6.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is a number (value is + positive) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: 2 +}; + +assert(Array.prototype.some.call(obj, callbackfn1), 'Array.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-7.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-7.js new file mode 100644 index 0000000000..4a37d62b83 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-7.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is a number (value is + negative) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} + +function callbackfn2(val, idx, obj) { + return val > 11; +} + +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: -4294967294 +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn1), false, 'Array.prototype.some.call(obj, callbackfn1)'); +assert.sameValue(Array.prototype.some.call(obj, callbackfn2), false, 'Array.prototype.some.call(obj, callbackfn2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-8.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-8.js new file mode 100644 index 0000000000..2d8a0f93e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-8.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is a number (value is + Infinity) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + length: Infinity +}; + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-9.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-9.js new file mode 100644 index 0000000000..81f18d7fbf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-3-9.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is a number (value is + -Infinity) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + length: -Infinity +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-1.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-1.js new file mode 100644 index 0000000000..acbceed9ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some throws TypeError if callbackfn is undefined +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.some(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-10.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-10.js new file mode 100644 index 0000000000..c5cd6f4ada --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-10.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - the exception is not thrown if exception + was thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.some.call(obj, undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-11.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-11.js new file mode 100644 index 0000000000..c16b34b426 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-11.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - the exception is not thrown if exception + was thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + Array.prototype.some.call(obj, undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-12.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-12.js new file mode 100644 index 0000000000..f46e6e6d32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-12.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - 'callbackfn' is a function +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} + +assert([9, 11].some(callbackfn), '[9, 11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-15.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-15.js new file mode 100644 index 0000000000..d035704277 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-15.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - calling with no callbackfn is the same as + passing undefined for callbackfn +---*/ + +var obj = {}; +var lengthAccessed = false; +var loopAccessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + lengthAccessed = true; + return 20; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + loopAccessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.some.call(obj); +}); +assert(lengthAccessed, 'lengthAccessed !== true'); +assert.sameValue(loopAccessed, false, 'loopAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-2.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-2.js new file mode 100644 index 0000000000..699b64dbe9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-2.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some throws ReferenceError if callbackfn is + unreferenced +---*/ + +var arr = new Array(10); +assert.throws(ReferenceError, function() { + arr.some(foo); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-3.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-3.js new file mode 100644 index 0000000000..27353996cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-3.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some throws TypeError if callbackfn is null +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.some(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-4.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-4.js new file mode 100644 index 0000000000..adafd8b5fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-4.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some throws TypeError if callbackfn is boolean +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.some(true); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-5.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-5.js new file mode 100644 index 0000000000..d91212aa73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-5.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some throws TypeError if callbackfn is number +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.some(5); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-6.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-6.js new file mode 100644 index 0000000000..7fa20de79a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-6.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some throws TypeError if callbackfn is string +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.some("abc"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-7.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-7.js new file mode 100644 index 0000000000..984967efd3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-7.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some throws TypeError if callbackfn is Object + without a Call internal method +---*/ + +var arr = new Array(10); +assert.throws(TypeError, function() { + arr.some(new Object()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-8.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-8.js new file mode 100644 index 0000000000..dacb5ceeff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-8.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - side effects produced by step 2 are visible + when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.some.call(obj, null); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-9.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-9.js new file mode 100644 index 0000000000..c2be0a88e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-4-9.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - side effects produced by step 3 are visible + when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; + +var accessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.some.call(obj, null); +}); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-1-s.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-1-s.js new file mode 100644 index 0000000000..68f7c486da --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-1-s.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - thisArg not passed to strict callbackfn +flags: [noStrict] +---*/ + +var innerThisCorrect = false; + +function callbackfn(val, idx, obj) { + "use strict"; + innerThisCorrect = this === undefined; + return true; +} + +[1].some(callbackfn); + +assert(innerThisCorrect, 'innerThisCorrect !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-1.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-1.js new file mode 100644 index 0000000000..2f2d023f00 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-1.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - thisArg is passed +flags: [noStrict] +---*/ + +(function() { + this._15_4_4_17_5_1 = false; + var _15_4_4_17_5_1 = true; + + function callbackfn(val, idx, obj) { + return this._15_4_4_17_5_1; + } + var arr = [1]; + + assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); +})(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-10.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-10.js new file mode 100644 index 0000000000..b01d637de6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-10.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - Array Object can be used as thisArg +---*/ + +var objArray = []; + +function callbackfn(val, idx, obj) { + return this === objArray; +} + +assert([11].some(callbackfn, objArray), '[11].some(callbackfn, objArray) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-11.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-11.js new file mode 100644 index 0000000000..a13439ad51 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-11.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - String object can be used as thisArg +---*/ + +var objString = new String(); + +function callbackfn(val, idx, obj) { + return this === objString; +} + +assert([11].some(callbackfn, objString), '[11].some(callbackfn, objString) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-12.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-12.js new file mode 100644 index 0000000000..56d787e708 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-12.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - Boolean object can be used as thisArg +---*/ + +var objBoolean = new Boolean(); + +function callbackfn(val, idx, obj) { + return this === objBoolean; +} + +assert([11].some(callbackfn, objBoolean), '[11].some(callbackfn, objBoolean) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-13.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-13.js new file mode 100644 index 0000000000..2749fc791b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-13.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - Number object can be used as thisArg +---*/ + +var objNumber = new Number(); + +function callbackfn(val, idx, obj) { + return this === objNumber; +} + +assert([11].some(callbackfn, objNumber), '[11].some(callbackfn, objNumber) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-14.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-14.js new file mode 100644 index 0000000000..f7fd30cac7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-14.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - the Math object can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this === Math; +} + +assert([11].some(callbackfn, Math), '[11].some(callbackfn, Math) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-15.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-15.js new file mode 100644 index 0000000000..e2ed7c34b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-15.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - Date object can be used as thisArg +---*/ + +var objDate = new Date(); + +function callbackfn(val, idx, obj) { + return this === objDate; +} + +assert([11].some(callbackfn, objDate), '[11].some(callbackfn, objDate) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-16.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-16.js new file mode 100644 index 0000000000..138dc2a029 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-16.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - RegExp object can be used as thisArg +---*/ + +var objRegExp = new RegExp(); + +function callbackfn(val, idx, obj) { + return this === objRegExp; +} + +assert([11].some(callbackfn, objRegExp), '[11].some(callbackfn, objRegExp) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-17.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-17.js new file mode 100644 index 0000000000..288c302fdf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-17.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - the JSON object can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this === JSON; +} + +assert([11].some(callbackfn, JSON), '[11].some(callbackfn, JSON) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-18.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-18.js new file mode 100644 index 0000000000..3aec4d53e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-18.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - Error object can be used as thisArg +---*/ + +var objError = new RangeError(); + +function callbackfn(val, idx, obj) { + return this === objError; +} + +assert([11].some(callbackfn, objError), '[11].some(callbackfn, objError) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-19.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-19.js new file mode 100644 index 0000000000..3e1e046c5a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-19.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - the Arguments object can be used as thisArg +---*/ + +var arg; + +function callbackfn(val, idx, obj) { + return this === arg; +} + +(function fun() { + arg = arguments; +}(1, 2, 3)); + +assert([11].some(callbackfn, arg), '[11].some(callbackfn, arg) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-2.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-2.js new file mode 100644 index 0000000000..ca0aa799a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-2.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - thisArg is Object +---*/ + +var res = false; +var o = new Object(); +o.res = true; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +var arr = [1]; + +assert.sameValue(arr.some(callbackfn, o), true, 'arr.some(callbackfn, o)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-21.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-21.js new file mode 100644 index 0000000000..24a2e2906b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-21.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - the global object can be used as thisArg +---*/ + +var global = this; + +function callbackfn(val, idx, obj) { + return this === global; +} + +assert([11].some(callbackfn, this), '[11].some(callbackfn, global) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-22.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-22.js new file mode 100644 index 0000000000..5089e4e2fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-22.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - boolean primitive can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === false; +} + +assert([11].some(callbackfn, false), '[11].some(callbackfn, false) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-23.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-23.js new file mode 100644 index 0000000000..418086d116 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-23.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - number primitive can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === 101; +} + +assert([11].some(callbackfn, 101), '[11].some(callbackfn, 101) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-24.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-24.js new file mode 100644 index 0000000000..518655319e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-24.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - string primitive can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === "abc"; +} + +assert([11].some(callbackfn, "abc"), '[11].some(callbackfn, "abc") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-25.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-25.js new file mode 100644 index 0000000000..f4ea752cc8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-25.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - thisArg not passed +flags: [noStrict] +---*/ + +function innerObj() { + this._15_4_4_17_5_25 = true; + var _15_4_4_17_5_25 = false; + + function callbackfn(val, idx, obj) { + return this._15_4_4_17_5_25; + } + var arr = [1]; + this.retVal = !arr.some(callbackfn); +} + +assert(new innerObj().retVal, 'new innerObj().retVal !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-3.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-3.js new file mode 100644 index 0000000000..f571ffbcfe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-3.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - thisArg is Array +---*/ + +var res = false; +var a = new Array(); +a.res = true; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +var arr = [1]; + +assert.sameValue(arr.some(callbackfn, a), true, 'arr.some(callbackfn, a)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-4.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-4.js new file mode 100644 index 0000000000..a867b5812b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-4.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - thisArg is object from object + template(prototype) +---*/ + +var res = false; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +function foo() {} +foo.prototype.res = true; +var f = new foo(); +var arr = [1]; + +assert.sameValue(arr.some(callbackfn, f), true, 'arr.some(callbackfn,f)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-5.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-5.js new file mode 100644 index 0000000000..a3e2f839cb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-5.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - thisArg is object from object template +---*/ + +var res = false; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +function foo() {} +var f = new foo(); +f.res = true; +var arr = [1]; + +assert.sameValue(arr.some(callbackfn, f), true, 'arr.some(callbackfn,f)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-6.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-6.js new file mode 100644 index 0000000000..22810c4ba3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-6.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - thisArg is function +---*/ + +var res = false; + +function callbackfn(val, idx, obj) +{ + return this.res; +} + +function foo() {} +foo.res = true; +var arr = [1]; + +assert.sameValue(arr.some(callbackfn, foo), true, 'arr.some(callbackfn,foo)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-7.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-7.js new file mode 100644 index 0000000000..93772a1273 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-7.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - built-in functions can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this === eval; +} + +assert([11].some(callbackfn, eval), '[11].some(callbackfn, eval) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-9.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-9.js new file mode 100644 index 0000000000..3743731429 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-5-9.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - Function Object can be used as thisArg +---*/ + +var objFunction = function() {}; + +function callbackfn(val, idx, obj) { + return this === objFunction; +} + +assert([11].some(callbackfn, objFunction), '[11].some(callbackfn, objFunction) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-1.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-1.js new file mode 100644 index 0000000000..b3dc43d070 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-1.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some considers new elements added to array after + it is called +---*/ + +var calledForThree = false; + +function callbackfn(val, idx, obj) +{ + arr[2] = 3; + if (val !== 3) + calledForThree = true; + + return false; +} + +var arr = [1, 2, , 4, 5]; + +var val = arr.some(callbackfn); + +assert(calledForThree, 'calledForThree !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-2.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-2.js new file mode 100644 index 0000000000..5f1ea0cdf2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-2.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some considers new value of elements in array + after it is called +---*/ + +function callbackfn(val, idx, obj) +{ + arr[4] = 6; + if (val < 6) + return false; + else + return true; +} + +var arr = [1, 2, 3, 4, 5]; + + +assert.sameValue(arr.some(callbackfn), true, 'arr.some(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-3.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-3.js new file mode 100644 index 0000000000..90294014d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-3.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some doesn't visit deleted elements in array after + it is called +---*/ + +function callbackfn(val, idx, obj) +{ + delete arr[2]; + if (val !== 3) + return false; + else + return true; +} + +var arr = [1, 2, 3, 4, 5]; + + +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-4.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-4.js new file mode 100644 index 0000000000..ee3cb4ac72 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-4.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some doesn't visit deleted elements when + Array.length is decreased +---*/ + +function callbackfn(val, idx, obj) +{ + arr.length = 3; + if (val < 4) + return false; + else + return true; +} + +var arr = [1, 2, 3, 4, 6]; + + +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-5.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-5.js new file mode 100644 index 0000000000..b3bd45a377 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-5.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some doesn't consider newly added elements in + sparse array +---*/ + +function callbackfn(val, idx, obj) +{ + arr[1000] = 5; + if (val < 5) + return false; + else + return true; +} + +var arr = new Array(10); +arr[1] = 1; +arr[2] = 2; + + +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-6.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-6.js new file mode 100644 index 0000000000..64ac2a2ed3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-6.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some visits deleted element in array after the + call when same index is also present in prototype +---*/ + +function callbackfn(val, idx, obj) +{ + delete arr[4]; + if (val < 5) + return false; + else + return true; +} + + +Array.prototype[4] = 5; +var arr = [1, 2, 3, 4, 5]; + +var res = arr.some(callbackfn); +delete Array.prototype[4]; + +assert.sameValue(res, true, 'res'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-8.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-8.js new file mode 100644 index 0000000000..7d7b613744 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-8.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - no observable effects occur if length is 0 +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} + +var obj = { + 0: 11, + 1: 12, + length: 0 +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-9.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-9.js new file mode 100644 index 0000000000..65f67b382d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-9.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - modifications to length don't change number + of iterations +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + return val > 10; +} + +var obj = { + 0: 9, + 2: 12, + length: 3 +}; + +Object.defineProperty(obj, "1", { + get: function() { + obj.length = 2; + return 8; + }, + configurable: true +}); + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); +assert.sameValue(called, 3, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-1.js new file mode 100644 index 0000000000..6530da092d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-1.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - callbackfn not called for indexes never + been assigned values +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + callCnt++; + return false; +} + +var arr = new Array(10); +arr[1] = undefined; +arr.some(callbackfn); + +assert.sameValue(callCnt, 1, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-10.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-10.js new file mode 100644 index 0000000000..a33e5639b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-10.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - deleting property of prototype causes + prototype index property not to be visited on an Array-like Object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return idx === 1; +} +var arr = { + 2: 2, + length: 20 +}; + +Object.defineProperty(arr, "0", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; + +assert.sameValue(Array.prototype.some.call(arr, callbackfn), false, 'Array.prototype.some.call(arr, callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-11.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-11.js new file mode 100644 index 0000000000..9e52508595 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-11.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - deleting property of prototype causes + prototype index property not to be visited on an Array +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return idx === 1; +} +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + delete Array.prototype[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; + +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-12.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-12.js new file mode 100644 index 0000000000..cab3ebcd10 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-12.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return true; + } else { + return false; + } +} +var arr = { + 0: 0, + 1: 111, + 2: 2, + length: 10 +}; + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; + +assert(Array.prototype.some.call(arr, callbackfn), 'Array.prototype.some.call(arr, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-13.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-13.js new file mode 100644 index 0000000000..c609035a58 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-13.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return true; + } else { + return false; + } +} +var arr = [0, 111, 2]; + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; + +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-14.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-14.js new file mode 100644 index 0000000000..62bb2d6423 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-14.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - decreasing length of array causes index + property not to be visited +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return idx === 3; +} +var arr = [0, 1, 2, "last"]; + +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-15.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-15.js new file mode 100644 index 0000000000..80ae4f1339 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-15.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - decreasing length of array with prototype + property causes prototype index property to be visited +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "prototype") { + return true; + } else { + return false; + } +} +var arr = [0, 1, 2]; + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-16.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-16.js new file mode 100644 index 0000000000..1d42f045b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-16.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - decreasing length of array does not delete + non-configurable properties +flags: [noStrict] +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "unconfigurable") { + return true; + } else { + return false; + } +} + +var arr = [0, 1, 2]; + +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); + +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-2.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-2.js new file mode 100644 index 0000000000..6a58a9d162 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-2.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - added properties in step 2 are visible here +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "length") { + return true; + } else { + return false; + } +} + +var arr = {}; + +Object.defineProperty(arr, "length", { + get: function() { + arr[2] = "length"; + return 3; + }, + configurable: true +}); + +assert(Array.prototype.some.call(arr, callbackfn), 'Array.prototype.some.call(arr, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-3.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-3.js new file mode 100644 index 0000000000..3ee6f6184d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-3.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - deleted properties in step 2 are visible + here +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return idx === 2; +} +var arr = { + 2: 6.99, + 8: 19 +}; + +Object.defineProperty(arr, "length", { + get: function() { + delete arr[2]; + return 10; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.some.call(arr, callbackfn), false, 'Array.prototype.some.call(arr, callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-4.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-4.js new file mode 100644 index 0000000000..e2116777bf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-4.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - properties added into own object after + current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return true; + } else { + return false; + } +} + +var arr = { + length: 2 +}; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert(Array.prototype.some.call(arr, callbackfn), 'Array.prototype.some.call(arr, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-5.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-5.js new file mode 100644 index 0000000000..4e5f64cedd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-5.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - properties added into own object after + current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return true; + } else { + return false; + } +} + +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-6.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-6.js new file mode 100644 index 0000000000..866ab83ae5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-6.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - properties can be added to prototype after + current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + return true; + } else { + return false; + } +} +var arr = { + length: 2 +}; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert(Array.prototype.some.call(arr, callbackfn), 'Array.prototype.some.call(arr, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-7.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-7.js new file mode 100644 index 0000000000..cadb08bf1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-7.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - properties can be added to prototype after + current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + return true; + } else { + return false; + } +} +var arr = [0, , 2]; + +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(Array.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-8.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-8.js new file mode 100644 index 0000000000..b953631ba4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-8.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - deleting own property causes index property + not to be visited on an Array-like object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return idx === 1; +} +var arr = { + length: 2 +}; + +Object.defineProperty(arr, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.some.call(arr, callbackfn), false, 'Array.prototype.some.call(arr, callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-9.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-9.js new file mode 100644 index 0000000000..72daa217d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-b-9.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - deleting own property causes index property + not to be visited on an Array +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return idx === 1; +} +var arr = [1, 2]; + +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-1.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-1.js new file mode 100644 index 0000000000..7d32330b89 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-1.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own data + property on an Array-like object +---*/ + +var kValue = {}; + +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val === kValue; + } + return false; +} + +var obj = { + 5: kValue, + length: 100 +}; + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-10.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-10.js new file mode 100644 index 0000000000..63e8ed2d66 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-10.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property on an Array +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 10) { + return val === kValue; + } + return false; +} + +var arr = []; + +Object.defineProperty(arr, "10", { + get: function() { + return kValue; + }, + configurable: true +}); + +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-11.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-11.js new file mode 100644 index 0000000000..c15d49c876 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-11.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === kValue; + } + return false; +} + +var proto = { + 1: 6 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 10; + +Object.defineProperty(child, "1", { + get: function() { + return kValue; + }, + configurable: true +}); + +assert(Array.prototype.some.call(child, callbackfn), 'Array.prototype.some.call(child, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-12.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-12.js new file mode 100644 index 0000000000..c7c720d446 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-12.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === kValue; + } + return false; +} + +var arr = []; + +Array.prototype[1] = 100; +Object.defineProperty(arr, "1", { + get: function() { + return kValue; + }, + configurable: true +}); + +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-13.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-13.js new file mode 100644 index 0000000000..5da957c962 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-13.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === kValue; + } + return false; +} + +var proto = {}; + +Object.defineProperty(proto, "1", { + get: function() { + return 5; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 10; + +Object.defineProperty(child, "1", { + get: function() { + return kValue; + }, + configurable: true +}); + + +assert(Array.prototype.some.call(child, callbackfn), 'Array.prototype.some.call(child, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-14.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-14.js new file mode 100644 index 0000000000..19f8c662ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-14.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === kValue; + } + return false; +} + +var arr = []; +Object.defineProperty(arr, "1", { + get: function() { + return kValue; + }, + configurable: true +}); + +Object.defineProperty(Array.prototype, "1", { + get: function() { + return 10; + }, + configurable: true +}); + +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-15.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-15.js new file mode 100644 index 0000000000..a1edeb465d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-15.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === kValue; + } + return false; +} + +var proto = {}; + +Object.defineProperty(proto, "1", { + get: function() { + return kValue; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 20; + +assert(Array.prototype.some.call(child, callbackfn), 'Array.prototype.some.call(child, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-16.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-16.js new file mode 100644 index 0000000000..e7a9005b5e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-16.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is inherited + accessor property on an Array +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === kValue; + } + return false; +} + +Object.defineProperty(Array.prototype, "1", { + get: function() { + return kValue; + }, + configurable: true +}); + +assert([, , ].some(callbackfn), '[, , ].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-17.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-17.js new file mode 100644 index 0000000000..195403672c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-17.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return typeof val === "undefined"; + } + return false; +} + +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-18.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-18.js new file mode 100644 index 0000000000..fbe5ee379a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-18.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return typeof val === "undefined"; + } + return false; +} + +var arr = []; + +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-19.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-19.js new file mode 100644 index 0000000000..ead6bb8a67 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-19.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return typeof val === "undefined"; + } + return false; +} + +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); + +Object.prototype[1] = 10; + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-2.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-2.js new file mode 100644 index 0000000000..d062719e21 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-2.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own data + property on an Array +---*/ + +var kValue = {}; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return kValue === val; + } + return false; +} + +assert([kValue].some(callbackfn), '[kValue].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-20.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-20.js new file mode 100644 index 0000000000..1fe7b44883 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-20.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return typeof val === "undefined"; + } + return false; +} + +var arr = []; + +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +Array.prototype[0] = 100; + +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-21.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-21.js new file mode 100644 index 0000000000..abef840c25 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-21.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return typeof val === "undefined"; + } + return false; +} + +var proto = {}; +Object.defineProperty(proto, "1", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; + +assert(Array.prototype.some.call(child, callbackfn), 'Array.prototype.some.call(child, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-22.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-22.js new file mode 100644 index 0000000000..d7e07d4566 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-22.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return typeof val === "undefined"; + } + return false; +} + +Object.defineProperty(Array.prototype, "0", { + set: function() {}, + configurable: true +}); + +assert([, ].some(callbackfn), '[, ].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-25.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-25.js new file mode 100644 index 0000000000..98353a5ebe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-25.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - This object is the Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } + return false; +} + +var func = function(a, b) { + return Array.prototype.some.call(arguments, callbackfn); +}; + +assert(func(11), 'func(11) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-26.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-26.js new file mode 100644 index 0000000000..c2ef229b2a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-26.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - This object is the Arguments object which + implements its own property get method (number of arguments equals + number of parameters) +---*/ + +var firstResult = false; +var secondResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + firstResult = (val === 11); + return false; + } else if (idx === 1) { + secondResult = (val === 9); + return false; + } else { + return true; + } +} + +var func = function(a, b) { + return Array.prototype.some.call(arguments, callbackfn); +}; + +assert.sameValue(func(11, 9), false, 'func(11, 9)'); +assert(firstResult, 'firstResult !== true'); +assert(secondResult, 'secondResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-27.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-27.js new file mode 100644 index 0000000000..ccae948b80 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-27.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - This object is the Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +var firstResult = false; +var secondResult = false; +var thirdResult = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + firstResult = (val === 11); + return false; + } else if (idx === 1) { + secondResult = (val === 12); + return false; + } else if (idx === 2) { + thirdResult = (val === 9); + return false; + } else { + return true; + } +} + +var func = function(a, b) { + return Array.prototype.some.call(arguments, callbackfn); +}; + +assert.sameValue(func(11, 12, 9), false, 'func(11, 12, 9)'); +assert(firstResult, 'firstResult !== true'); +assert(secondResult, 'secondResult !== true'); +assert(thirdResult, 'thirdResult !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-28.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-28.js new file mode 100644 index 0000000000..cf84f1ed5f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-28.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element changed by getter on previous + iterations is observed on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === 12; + } + return false; +} + +var arr = []; +var helpVerifyVar = 11; + +Object.defineProperty(arr, "1", { + get: function() { + return helpVerifyVar; + }, + set: function(args) { + helpVerifyVar = args; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + arr[1] = 12; + return 9; + }, + configurable: true +}); + +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-29.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-29.js new file mode 100644 index 0000000000..282c17991c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-29.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element changed by getter on previous + iterations on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === 12; + } + return false; +} + +var obj = { + length: 2 +}; +var helpVerifyVar = 11; + +Object.defineProperty(obj, "1", { + get: function() { + return helpVerifyVar; + }, + set: function(args) { + helpVerifyVar = args; + }, + configurable: true +}); + +Object.defineProperty(obj, "0", { + get: function() { + obj[1] = 12; + return 11; + }, + configurable: true +}); + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-3.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-3.js new file mode 100644 index 0000000000..6f60e78b19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-3.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val === kValue; + } + return false; +} + +var proto = { + 5: 100 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[5] = kValue; +child.length = 10; + +assert(Array.prototype.some.call(child, callbackfn), 'Array.prototype.some.call(child, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-30.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-30.js new file mode 100644 index 0000000000..f9e410867e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-30.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - unhandled exceptions happened in getter + terminate iteration on an Array-like object +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } + return true; +} + +var obj = { + length: 20 +}; +Object.defineProperty(obj, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + Array.prototype.some.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-31.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-31.js new file mode 100644 index 0000000000..93e96ea829 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-31.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - unhandled exceptions happened in getter + terminate iteration on an Array +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + if (idx > 0) { + accessed = true; + } + return true; +} + +var arr = []; +arr[10] = 100; +Object.defineProperty(arr, "0", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.some(callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-4.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-4.js new file mode 100644 index 0000000000..8ddf2a0258 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-4.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} + +Array.prototype[0] = 11; + +assert([kValue].some(callbackfn), '[kValue].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-5.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-5.js new file mode 100644 index 0000000000..34e60b4307 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-5.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var kValue = 1000; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} + +var proto = {}; + +Object.defineProperty(proto, "0", { + get: function() { + return 5; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +Object.defineProperty(child, "0", { + value: kValue, + configurable: true +}); + +assert(Array.prototype.some.call(child, callbackfn), 'Array.prototype.some.call(child, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-6.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-6.js new file mode 100644 index 0000000000..72335246dc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-6.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +var kValue = 1000; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 9; + }, + configurable: true +}); + +assert([kValue].some(callbackfn), '[kValue].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-7.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-7.js new file mode 100644 index 0000000000..dbb1dc4e78 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-7.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is inherited data + property on an Array-like object +---*/ + +var kValue = 'abc'; + +function callbackfn(val, idx, obj) { + if (5 === idx) { + return kValue === val; + } + return false; +} + +var proto = { + 5: kValue +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 10; + +assert(Array.prototype.some.call(child, callbackfn), 'Array.prototype.some.call(child, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-8.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-8.js new file mode 100644 index 0000000000..2a45790a7e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-8.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is inherited data + property on an Array +---*/ + +var kValue = {}; + +function callbackfn(val, idx, obj) { + if (0 === idx) { + return kValue === val; + } + return false; +} + +Array.prototype[0] = kValue; + +assert([, ].some(callbackfn), '[, ].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-9.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-9.js new file mode 100644 index 0000000000..df00017030 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-i-9.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property on an Array-like object +---*/ + +var kValue = "abc"; + +function callbackfn(val, idx, obj) { + if (idx === 10) { + return val === kValue; + } + return false; +} + +var obj = { + length: 20 +}; + +Object.defineProperty(obj, "10", { + get: function() { + return kValue; + }, + configurable: true +}); + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-1.js new file mode 100644 index 0000000000..9237e93517 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-1.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - callbackfn called with correct parameters +---*/ + +function callbackfn(val, idx, obj) +{ + if (obj[idx] === val) + return false; + else + return true; +} + +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-10.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-10.js new file mode 100644 index 0000000000..4d9508992f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-10.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - callbackfn is called with 1 formal parameter +---*/ + +function callbackfn(val) { + return val > 10; +} + +assert([11, 12].some(callbackfn), '[11, 12].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-11.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-11.js new file mode 100644 index 0000000000..2b32d00728 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-11.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - callbackfn is called with 2 formal parameter +---*/ + +function callbackfn(val, idx) { + return val > 10 && arguments[2][idx] === val; +} + +assert([9, 12].some(callbackfn), '[9, 12].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-12.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-12.js new file mode 100644 index 0000000000..7863078409 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-12.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - callbackfn is called with 3 formal parameter +---*/ + +function callbackfn(val, idx, obj) { + return val > 10 && obj[idx] === val; +} + +assert([9, 12].some(callbackfn), '[9, 12].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-13.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-13.js new file mode 100644 index 0000000000..f4c13f8624 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-13.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - callbackfn that uses arguments object to + get parameter value +---*/ + +function callbackfn() { + return arguments[2][arguments[1]] === arguments[0]; +} + +assert([9, 12].some(callbackfn), '[9, 12].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-16.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-16.js new file mode 100644 index 0000000000..9212609bc9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-16.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'this' of 'callback' is a Boolean object + when 'T' is not an object ('T' is a boolean primitive) +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === false; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert(Array.prototype.some.call(obj, callbackfn, false), 'Array.prototype.some.call(obj, callbackfn, false) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-17.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-17.js new file mode 100644 index 0000000000..15bcacc7a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-17.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'this' of 'callbackfn' is a Number object + when T is not an object (T is a number primitive) +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === 5; +} + +var obj = { + 0: 11, + length: 1 +}; + +assert(Array.prototype.some.call(obj, callbackfn, 5), 'Array.prototype.some.call(obj, callbackfn, 5) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-18.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-18.js new file mode 100644 index 0000000000..39c12246e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-18.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'this' of 'callbackfn' is an String object + when T is not an object (T is a string primitive) +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === "hello!"; +} + +var obj = { + 0: 11, + 1: 9, + length: 2 +}; + +assert(Array.prototype.some.call(obj, callbackfn, "hello!"), 'Array.prototype.some.call(obj, callbackfn, "hello!") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-19.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-19.js new file mode 100644 index 0000000000..0ddd9a122f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-19.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - non-indexed properties are not called +---*/ + +var called = 0; + +function callbackfn(val, idx, obj) { + called++; + return val === 11; +} + +var obj = { + 0: 9, + 10: 8, + non_index_property: 11, + length: 20 +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert.sameValue(called, 2, 'called'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-2.js new file mode 100644 index 0000000000..d790c0d9d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-2.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - callbackfn takes 3 arguments +---*/ + +function callbackfn(val, idx, obj) +{ + if (arguments.length === 3) //verify if callbackfn was called with 3 parameters + return false; + else + return true; +} + +var arr = [0, 1, true, null, new Object(), "five"]; +arr[999999] = -6.6; + + +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-20.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-20.js new file mode 100644 index 0000000000..7f3af49e48 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-20.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - callbackfn called with correct parameters + (thisArg is correct) +---*/ + +var thisArg = { + threshold: 10 +}; + +function callbackfn(val, idx, obj) { + return this === thisArg; +} + +var obj = { + 0: 11, + length: 2 +}; + +assert(Array.prototype.some.call(obj, callbackfn, thisArg), 'Array.prototype.some.call(obj, callbackfn, thisArg) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-21.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-21.js new file mode 100644 index 0000000000..de229bed17 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-21.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - callbackfn called with correct parameters + (kValue is correct) +---*/ + +var firstIndex = false; +var secondIndex = false; + +function callbackfn(val, idx, obj) { + if (idx === 0) { + firstIndex = (val === 11); + return false; + } + if (idx === 1) { + secondIndex = (val === 12); + return false; + } +} + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert(firstIndex, 'firstIndex !== true'); +assert(secondIndex, 'secondIndex !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-22.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-22.js new file mode 100644 index 0000000000..ff3b2ef5a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-22.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - callbackfn called with correct parameters + (the index k is correct) +---*/ + +var firstIndex = false; +var secondIndex = false; + +function callbackfn(val, idx, obj) { + if (val === 11) { + firstIndex = (idx === 0); + return false; + } + if (val === 12) { + secondIndex = (idx === 1); + return false; + } +} + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert(firstIndex, 'firstIndex !== true'); +assert(secondIndex, 'secondIndex !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-23.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-23.js new file mode 100644 index 0000000000..9593217eff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-23.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - callbackfn called with correct parameters + (this object O is correct) +---*/ + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; + +function callbackfn(val, idx, o) { + return obj === o; +} + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-3.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-3.js new file mode 100644 index 0000000000..4b67ca2d5c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-3.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some immediately returns true if callbackfn + returns true +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + callCnt++; + if (idx > 5) + return true; + else + return false; +} + +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + +assert.sameValue(arr.some(callbackfn), true, 'arr.some(callbackfn)'); +assert.sameValue(callCnt, 7, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-4.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-4.js new file mode 100644 index 0000000000..f86b680bea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-4.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - k values are passed in ascending numeric + order +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +var lastIdx = 0; +var called = 0; + +function callbackfn(val, idx, o) { + called++; + if (lastIdx !== idx) { + return true; + } else { + lastIdx++; + return false; + } +} + +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); +assert.sameValue(arr.length, called, 'arr.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-5.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-5.js new file mode 100644 index 0000000000..af59cc4bd5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-5.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - k values are accessed during each iteration + and not prior to starting the loop +---*/ + +var kIndex = []; + +//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(val, idx, obj) { + //Each position should be visited one time, which means k is accessed one time during iterations. + if (typeof kIndex[idx] === "undefined") { + //when current position is visited, its previous index should has been visited. + if (idx !== 0 && typeof kIndex[idx - 1] === "undefined") { + return true; + } + kIndex[idx] = 1; + return false; + } else { + return true; + } +} + +assert.sameValue([11, 12, 13, 14].some(callbackfn, undefined), false, '[11, 12, 13, 14].some(callbackfn, undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-6.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-6.js new file mode 100644 index 0000000000..439922d525 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-6.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - arguments to callbackfn are self consistent +---*/ + +var obj = { + 0: 11, + length: 1 +}; +var thisArg = {}; + +function callbackfn() { + return this === thisArg && arguments[0] === 11 && arguments[1] === 0 && arguments[2] === obj; +} + +assert(Array.prototype.some.call(obj, callbackfn, thisArg), 'Array.prototype.some.call(obj, callbackfn, thisArg) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-7.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-7.js new file mode 100644 index 0000000000..424bdad9f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-7.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - unhandled exceptions happened in callbackfn + terminate iteration +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + if (idx > 0) { + accessed = true; + } + if (idx === 0) { + throw new Error("Exception occurred in callbackfn"); + } + return false; +} + +var obj = { + 0: 9, + 1: 100, + 10: 11, + length: 20 +}; +assert.throws(Error, function() { + Array.prototype.some.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-8.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-8.js new file mode 100644 index 0000000000..d1d0e59d0b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-8.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element changed by callbackfn on previous + iterations is observed +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + obj[idx + 1] = 11; + } + return val > 10; +} + +var obj = { + 0: 9, + 1: 8, + length: 2 +}; + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-9.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-9.js new file mode 100644 index 0000000000..21e425cfa3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-ii-9.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - callbackfn is called with 0 formal parameter +---*/ + +function callbackfn() { + return true; +} + +assert([11, 12].some(callbackfn), '[11, 12].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-1.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-1.js new file mode 100644 index 0000000000..8b20b97e34 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-1.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - return value of callbackfn is undefined +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return undefined; +} + +var obj = { + 0: 11, + length: 2 +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-10.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-10.js new file mode 100644 index 0000000000..0d3d412585 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-10.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is Infinity) +---*/ + +function callbackfn(val, idx, obj) { + return Infinity; +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-11.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-11.js new file mode 100644 index 0000000000..c595f486cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-11.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is -Infinity) +---*/ + +function callbackfn(val, idx, obj) { + return -Infinity; +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-12.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-12.js new file mode 100644 index 0000000000..a49cebbbd8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-12.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is NaN) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return NaN; +} + +assert.sameValue([11].some(callbackfn), false, '[11].some(callbackfn)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-13.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-13.js new file mode 100644 index 0000000000..50d47f4d95 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-13.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is an empty + string +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return ""; +} + +assert.sameValue([11].some(callbackfn), false, '[11].some(callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-14.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-14.js new file mode 100644 index 0000000000..36e3e63669 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-14.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a non-empty + string +---*/ + +function callbackfn(val, idx, obj) { + return "non-empty string"; +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-15.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-15.js new file mode 100644 index 0000000000..e723c0a03b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-15.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is Function + object +---*/ + +function callbackfn(val, idx, obj) { + return function() {}; +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-16.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-16.js new file mode 100644 index 0000000000..a9d3fd03aa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-16.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is an Array + object +---*/ + +function callbackfn(val, idx, obj) { + return new Array(10); +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-17.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-17.js new file mode 100644 index 0000000000..a66052bd57 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-17.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a String + object +---*/ + +function callbackfn(val, idx, obj) { + return new String(); +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-18.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-18.js new file mode 100644 index 0000000000..39d4b1abd6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-18.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a Boolean + object +---*/ + +function callbackfn(val, idx, obj) { + return new Boolean(); +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-19.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-19.js new file mode 100644 index 0000000000..7912be6aab --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-19.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a Number + object +---*/ + +function callbackfn(val, idx, obj) { + return new Number(); +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-2.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-2.js new file mode 100644 index 0000000000..8afd00913c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-2.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - return value of callbackfn is null +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return null; +} + +var obj = { + 0: 11, + length: 2 +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-20.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-20.js new file mode 100644 index 0000000000..14524e58d3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-20.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is the Math + object +---*/ + +function callbackfn(val, idx, obj) { + return Math; +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-21.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-21.js new file mode 100644 index 0000000000..7a3113dc94 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-21.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - return value of callbackfn is a Date object +---*/ + +function callbackfn(val, idx, obj) { + return new Date(); +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-22.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-22.js new file mode 100644 index 0000000000..80c0331b73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-22.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a RegExp + object +---*/ + +function callbackfn(val, idx, obj) { + return new RegExp(); +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-23.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-23.js new file mode 100644 index 0000000000..1f93886842 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-23.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is the JSON + object +---*/ + +function callbackfn(val, idx, obj) { + return JSON; +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-24.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-24.js new file mode 100644 index 0000000000..7be613c304 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-24.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is an Error + object +---*/ + +function callbackfn(val, idx, obj) { + return new EvalError(); +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-25.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-25.js new file mode 100644 index 0000000000..954bf4351b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-25.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is the Arguments + object +---*/ + +function callbackfn(val, idx, obj) { + return arguments; +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-26.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-26.js new file mode 100644 index 0000000000..4b1d75d24f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-26.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is the global + object +---*/ + +var global = this; + +function callbackfn(val, idx, obj) { + return global; +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-28.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-28.js new file mode 100644 index 0000000000..b324d55630 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-28.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - true prevents further side effects +---*/ + +var result = false; + +function callbackfn(val, idx, obj) { + if (idx > 1) { + result = true; + } + return val > 10; +} + +var obj = { + length: 20 +}; + +Object.defineProperty(obj, "0", { + get: function() { + return 8; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + return 11; + }, + configurable: true +}); + +Object.defineProperty(obj, "2", { + get: function() { + result = true; + return 11; + }, + configurable: true +}); + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); +assert.sameValue(result, false, 'result'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-29.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-29.js new file mode 100644 index 0000000000..ad0377ef5b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-29.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value (new Boolean(false)) of + callbackfn is treated as true value +---*/ + +function callbackfn() { + return new Boolean(false); +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-3.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-3.js new file mode 100644 index 0000000000..2cedc30bd6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-3.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a boolean + (value is false) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return false; +} + +var obj = { + 0: 11, + length: 2 +}; + +assert.sameValue(Array.prototype.some.call(obj, callbackfn), false, 'Array.prototype.some.call(obj, callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-4.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-4.js new file mode 100644 index 0000000000..35e1dd57b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-4.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a boolean + (value is true) +---*/ + +function callbackfn(val, idx, obj) { + return true; +} + +var obj = { + 0: 11, + length: 2 +}; + +assert(Array.prototype.some.call(obj, callbackfn), 'Array.prototype.some.call(obj, callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-5.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-5.js new file mode 100644 index 0000000000..c734f493fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-5.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is 0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return 0; +} + +assert.sameValue([11].some(callbackfn), false, '[11].some(callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-6.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-6.js new file mode 100644 index 0000000000..3b5808297a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-6.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is +0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return +0; +} + +assert.sameValue([11].some(callbackfn), false, '[11].some(callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-7.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-7.js new file mode 100644 index 0000000000..b27bbc2dac --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-7.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is -0) +---*/ + +var accessed = false; + +function callbackfn(val, idx, obj) { + accessed = true; + return -0; +} + +assert.sameValue([11].some(callbackfn), false, '[11].some(callbackfn)'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-8.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-8.js new file mode 100644 index 0000000000..04fe2776e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-8.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is positive number) +---*/ + +function callbackfn(val, idx, obj) { + return 5; +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-9.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-9.js new file mode 100644 index 0000000000..3b4b4ff0c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-7-c-iii-9.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is negative number) +---*/ + +function callbackfn(val, idx, obj) { + return -5; +} + +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-1.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-1.js new file mode 100644 index 0000000000..ac586cce1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some returns false if 'length' is 0 (empty array) +---*/ + +function cb() {} +var i = [].some(cb); + +assert.sameValue(i, false, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-10.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-10.js new file mode 100644 index 0000000000..75e26d272c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-10.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - subclassed array when length is reduced +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 2; + +function cb(val) +{ + if (val > 2) + return true; + else + return false; +} +var i = f.some(cb); + + +assert.sameValue(i, false, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-11.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-11.js new file mode 100644 index 0000000000..6b99c3592d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-11.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false when all calls to callbackfn + return false +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + callCnt++; + return false; +} + +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); +assert.sameValue(callCnt, 10, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-12.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-12.js new file mode 100644 index 0000000000..bc2dd24423 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-12.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some doesn't mutate the array on which it is + called on +---*/ + +function callbackfn(val, idx, obj) +{ + return true; +} +var arr = [1, 2, 3, 4, 5]; +arr.some(callbackfn); + +assert.sameValue(arr[0], 1, 'arr[0]'); +assert.sameValue(arr[1], 2, 'arr[1]'); +assert.sameValue(arr[2], 3, 'arr[2]'); +assert.sameValue(arr[3], 4, 'arr[3]'); +assert.sameValue(arr[4], 5, 'arr[4]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-13.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-13.js new file mode 100644 index 0000000000..db3ffc740e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-13.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some doesn't visit expandos +---*/ + +var callCnt = 0; + +function callbackfn(val, idx, obj) +{ + callCnt++; + return false; +} + +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +arr["i"] = 10; +arr[true] = 11; + + +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); +assert.sameValue(callCnt, 10, 'callCnt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-2.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-2.js new file mode 100644 index 0000000000..1a0b486a2f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-2.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false if 'length' is 0 (subclassed + Array, length overridden to null (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = null; + +function cb() {} +var i = f.some(cb); + + +assert.sameValue(i, false, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-3.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-3.js new file mode 100644 index 0000000000..4a38a24b1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-3.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false if 'length' is 0 (subclassed + Array, length overridden to false (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = false; + +function cb() {} +var i = f.some(cb); + + +assert.sameValue(i, false, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-4.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-4.js new file mode 100644 index 0000000000..aface909a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-4.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false if 'length' is 0 (subclassed + Array, length overridden to 0 (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 0; + +function cb() {} +var i = f.some(cb); + + +assert.sameValue(i, false, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-5.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-5.js new file mode 100644 index 0000000000..59e2e53391 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-5.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false if 'length' is 0 (subclassed + Array, length overridden to '0' (type conversion)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = '0'; + +function cb() {} +var i = f.some(cb); + + +assert.sameValue(i, false, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-6.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-6.js new file mode 100644 index 0000000000..b3294f99f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-6.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false if 'length' is 0 (subclassed + Array, length overridden with obj with valueOf) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; + +function cb() {} +var i = f.some(cb); + + +assert.sameValue(i, false, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-7.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-7.js new file mode 100644 index 0000000000..b8fbd51b3b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-7.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false if 'length' is 0 (subclassed + Array, length overridden with obj w/o valueOf (toString)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. + +function cb() {} +var i = f.some(cb); + + +assert.sameValue(i, false, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-8.js b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-8.js new file mode 100644 index 0000000000..fdf21af1af --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/15.4.4.17-8-8.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false if 'length' is 0 (subclassed + Array, length overridden with [] +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +f.length = []; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. + +function cb() {} +var i = f.some(cb); + + +assert.sameValue(i, false, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/browser.js b/js/src/tests/test262/built-ins/Array/prototype/some/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/some/call-with-boolean.js new file mode 100644 index 0000000000..755711e5ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/call-with-boolean.js @@ -0,0 +1,20 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to boolean primitive +---*/ + +assert.sameValue( + Array.prototype.some.call(true, () => {}), + false, + 'Array.prototype.some.call(true, () => {}) must return false' +); +assert.sameValue( + Array.prototype.some.call(false, () => {}), + false, + 'Array.prototype.some.call(false, () => {}) must return false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/some/callbackfn-resize-arraybuffer.js new file mode 100644 index 0000000000..0f42d15717 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/callbackfn-resize-arraybuffer.js @@ -0,0 +1,74 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.some +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.some.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, expectedElements, 'elements (shrink)'); + assert.compareArray(indices, expectedIndices, 'indices (shrink)'); + assert.compareArray(arrays, expectedArrays, 'arrays (shrink)'); + assert.sameValue(result, false, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = Array.prototype.some.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, false, 'result (grow)'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/length.js b/js/src/tests/test262/built-ins/Array/prototype/some/length.js new file mode 100644 index 0000000000..4afccd4124 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + The "length" property of Array.prototype.some +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.some.length, 1); + +verifyNotEnumerable(Array.prototype.some, 'length'); +verifyNotWritable(Array.prototype.some, 'length'); +verifyConfigurable(Array.prototype.some, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/name.js b/js/src/tests/test262/built-ins/Array/prototype/some/name.js new file mode 100644 index 0000000000..3ccefd3f61 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some.name is "some". +info: | + Array.prototype.some ( callbackfn [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.some.name, "some"); + +verifyNotEnumerable(Array.prototype.some, "name"); +verifyNotWritable(Array.prototype.some, "name"); +verifyConfigurable(Array.prototype.some, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/some/not-a-constructor.js new file mode 100644 index 0000000000..cff54f8d96 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/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: > + Array.prototype.some 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, arrow-function] +---*/ + +assert.sameValue(isConstructor(Array.prototype.some), false, 'isConstructor(Array.prototype.some) must return false'); + +assert.throws(TypeError, () => { + new Array.prototype.some(() => {}); +}, '`new Array.prototype.some(() => {})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/some/prop-desc.js new file mode 100644 index 0000000000..31c84e6a9b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.some +description: > + "some" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.some, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "some"); +verifyWritable(Array.prototype, "some"); +verifyConfigurable(Array.prototype, "some"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/shell.js b/js/src/tests/test262/built-ins/Array/prototype/some/shell.js new file mode 100644 index 0000000000..05fecd6ef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/some/shell.js @@ -0,0 +1,161 @@ +// GENERATED, DO NOT EDIT +// file: testTypedArray.js +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - floatArrayConstructors + - nonClampedIntArrayConstructors + - intArrayConstructors + - typedArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - nonAtomicsFriendlyTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +var floatArrayConstructors = [ + Float64Array, + Float32Array +]; + +var nonClampedIntArrayConstructors = [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array +]; + +var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]); + +// Float16Array is a newer feature +// adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it +if (typeof Float16Array !== 'undefined') { + floatArrayConstructors.push(Float16Array); +} + +/** + * Array containing every non-bigint typed array constructor. + */ + +var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]); +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} + +/** + * Checks if the given argument is one of the float-based TypedArray constructors. + * + * @param {constructor} ctor - the value to check + * @returns {boolean} + */ +function isFloatTypedArrayConstructor(arg) { + return floatArrayConstructors.indexOf(arg) !== -1; +} + +/** + * Determines the precision of the given float-based TypedArray constructor. + * + * @param {constructor} ctor - the value to check + * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively. + */ +function floatTypedArrayConstructorPrecision(FA) { + if (typeof Float16Array !== "undefined" && FA === Float16Array) { + return "half"; + } else if (FA === Float32Array) { + return "single"; + } else if (FA === Float64Array) { + return "double"; + } else { + throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray"); + } +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.1_T1.js new file mode 100644 index 0000000000..af681151b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.1_T1.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If this object does not have a property named by ToString(j), + and this object does not have a property named by ToString(k), return +0 +esid: sec-array.prototype.sort +description: If comparefn is undefined, use SortCompare operator +---*/ + +var x = new Array(2); +x.sort(); + +if (x.length !== 2) { + throw new Test262Error('#1: var x = new Array(2); x.sort(); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== undefined) { + throw new Test262Error('#2: var x = new Array(2); x.sort(); x[0] === undefined. Actual: ' + (x[0])); +} + +if (x[1] !== undefined) { + throw new Test262Error('#3: var x = new Array(2); x.sort(); x[1] === undefined. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.2_T1.js new file mode 100644 index 0000000000..95ccc2f4c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.2_T1.js @@ -0,0 +1,45 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If this object does not have a property named by + ToString(j), return 1. If this object does not have a property + named by ToString(k), return -1 +esid: sec-array.prototype.sort +description: If comparefn is undefined, use SortCompare operator +---*/ + +var x = new Array(2); +x[1] = 1; +x.sort(); + +if (x.length !== 2) { + throw new Test262Error('#1: var x = new Array(2); x[1] = 1; x.sort(); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 1) { + throw new Test262Error('#2: var x = new Array(2); x[1] = 1; x.sort(); x[0] === 1. Actual: ' + (x[0])); +} + +if (x[1] !== undefined) { + throw new Test262Error('#3: var x = new Array(2); x[1] = 1; x.sort(); x[1] === undefined. Actual: ' + (x[1])); +} + +var x = new Array(2); +x[0] = 1; +x.sort(); + +if (x.length !== 2) { + throw new Test262Error('#4: var x = new Array(2); x[0] = 1; x.sort(); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 1) { + throw new Test262Error('#5: var x = new Array(2); x[0] = 1; x.sort(); x[0] === 1. Actual: ' + (x[0])); +} + +if (x[1] !== undefined) { + throw new Test262Error('#6: var x = new Array(2); x[0] = 1; x.sort(); x[1] === undefined. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.2_T2.js new file mode 100644 index 0000000000..5c10674217 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.2_T2.js @@ -0,0 +1,51 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If this object does not have a property named by + ToString(j), return 1. If this object does not have a property + named by ToString(k), return -1 +esid: sec-array.prototype.sort +description: If comparefn is not undefined +---*/ + +var myComparefn = function(x, y) { + if (x === undefined) return -1; + if (y === undefined) return 1; + return 0; +} + +var x = new Array(2); +x[1] = 1; +x.sort(myComparefn); + +if (x.length !== 2) { + throw new Test262Error('#1: var x = new Array(2); x[1] = 1; x.sort(myComparefn); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 1) { + throw new Test262Error('#2: var x = new Array(2); x[1] = 1; x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0])); +} + +if (x[1] !== undefined) { + throw new Test262Error('#3: var x = new Array(2); x[1] = 1; x.sort(myComparefn); x[1] === undefined. Actual: ' + (x[1])); +} + +var x = new Array(2); +x[0] = 1; +x.sort(myComparefn); + +if (x.length !== 2) { + throw new Test262Error('#4: var x = new Array(2); x[0] = 1; x.sort(myComparefn); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 1) { + throw new Test262Error('#5: var x = new Array(2); x[0] = 1; x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0])); +} + +if (x[1] !== undefined) { + throw new Test262Error('#6: var x = new Array(2); x[0] = 1; x.sort(myComparefn); x[1] === undefined. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.3_T1.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.3_T1.js new file mode 100644 index 0000000000..6a6d330506 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.3_T1.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If [[Get]] ToString(j) and [[Get]] ToString(k) + are both undefined, return +0 +esid: sec-array.prototype.sort +description: If comparefn is undefined, use SortCompare operator +---*/ + +var x = new Array(undefined, undefined); +x.sort(); + +if (x.length !== 2) { + throw new Test262Error('#1: var x = new Array(undefined, undefined); x.sort(); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== undefined) { + throw new Test262Error('#2: var x = new Array(undefined, undefined); x.sort(); x[0] === undefined. Actual: ' + (x[0])); +} + +if (x[1] !== undefined) { + throw new Test262Error('#3: var x = new Array(undefined, undefined); x.sort(); x[1] === undefined. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.4_T1.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.4_T1.js new file mode 100644 index 0000000000..425c2361dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.4_T1.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If [[Get]] ToString(j) is undefined, return 1. + If [[]Get] ToString(k) is undefined, return -1 +esid: sec-array.prototype.sort +description: If comparefn is undefined, use SortCompare operator +---*/ + +var x = new Array(undefined, 1); +x.sort(); + +if (x.length !== 2) { + throw new Test262Error('#1: var x = new Array(undefined, 1); x.sort(); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 1) { + throw new Test262Error('#2: var x = new Array(undefined, 1); x.sort(); x[0] === 1. Actual: ' + (x[0])); +} + +if (x[1] !== undefined) { + throw new Test262Error('#3: var x = new Array(undefined, 1); x.sort(); x[1] === undefined. Actual: ' + (x[1])); +} + +var x = new Array(1, undefined); +x.sort(); + +if (x.length !== 2) { + throw new Test262Error('#4: var x = new Array(1, undefined); x.sort(); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 1) { + throw new Test262Error('#5: var x = new Array(1, undefined); x.sort(); x[0] === 1. Actual: ' + (x[0])); +} + +if (x[1] !== undefined) { + throw new Test262Error('#6: var x = new Array(1, undefined); x.sort(); x[1] === undefined. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.4_T2.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.4_T2.js new file mode 100644 index 0000000000..c0ab63090a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.4_T2.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If [[Get]] ToString(j) is undefined, return 1. + If [[]Get] ToString(k) is undefined, return -1 +esid: sec-array.prototype.sort +description: If comparefn is not undefined +---*/ + +var myComparefn = function(x, y) { + if (x === undefined) return -1; + if (y === undefined) return 1; + return 0; +} + +var x = new Array(undefined, 1); +x.sort(myComparefn); + +if (x.length !== 2) { + throw new Test262Error('#1: var x = new Array(undefined, 1); x.sort(myComparefn); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 1) { + throw new Test262Error('#2: var x = new Array(undefined, 1); x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0])); +} + +if (x[1] !== undefined) { + throw new Test262Error('#3: var x = new Array(undefined, 1); x.sort(myComparefn); x[1] === undefined. Actual: ' + (x[1])); +} + +var x = new Array(1, undefined); +x.sort(myComparefn); + +if (x.length !== 2) { + throw new Test262Error('#4: var x = new Array(1, undefined); x.sort(myComparefn); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 1) { + throw new Test262Error('#5: var x = new Array(1, undefined); x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0])); +} + +if (x[1] !== undefined) { + throw new Test262Error('#6: var x = new Array(1, undefined); x.sort(myComparefn); x[1] === undefined. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.5_T1.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.5_T1.js new file mode 100644 index 0000000000..250933dd96 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.5_T1.js @@ -0,0 +1,40 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If comparefn is undefined, use SortCompare operator +esid: sec-array.prototype.sort +description: Checking sort() and sort(undefined) +---*/ + +var x = new Array(1, 0); +x.sort(); + +if (x.length !== 2) { + throw new Test262Error('#1: var x = new Array(1,0); x.sort(); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#2: var x = new Array(1,0); x.sort(); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#3: var x = new Array(1,0); x.sort(); x[1] === 1. Actual: ' + (x[1])); +} + +var x = new Array(1, 0); +x.sort(undefined); + +if (x.length !== 2) { + throw new Test262Error('#4: var x = new Array(1,0); x.sort(undefined); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#5: var x = new Array(1,0); x.sort(undefined); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#6: var x = new Array(1,0); x.sort(undefined); x[1] === 1. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T1.js new file mode 100644 index 0000000000..b4c988eec5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T1.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If ToString([[Get]] ToString(j)) < ToString([[Get]] ToString(k)), return -1. + If ToString([[Get]] ToString(j)) > ToString([[Get]] ToString(k)), return 1; + return -1 +esid: sec-array.prototype.sort +description: Checking ENGLISH ALPHABET +---*/ + +var alphabetR = ["z", "y", "x", "w", "v", "u", "t", "s", "r", "q", "p", "o", "n", "M", "L", "K", "J", "I", "H", "G", "F", "E", "D", "C", "B", "A"]; +var alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]; + +alphabetR.sort(); +var result = true; +for (var i = 0; i < 26; i++) { + if (alphabetR[i] !== alphabet[i]) result = false; +} + +if (result !== true) { + throw new Test262Error('#1: CHECK ENGLISH ALPHABET'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T2.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T2.js new file mode 100644 index 0000000000..e6e8ac1fc8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T2.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If ToString([[Get]] ToString(j)) < ToString([[Get]] ToString(k)), return -1. + If ToString([[Get]] ToString(j)) > ToString([[Get]] ToString(k)), return 1; + return -1 +esid: sec-array.prototype.sort +description: Checking RUSSIAN ALPHABET +---*/ + +var alphabetR = ["ё", "я", "ю", "э", "ь", "ы", "ъ", "щ", "ш", "ч", "ц", "х", "ф", "у", "т", "с", "р", "П", "О", "Н", "М", "Л", "К", "Й", "И", "З", "Ж", "Е", "Д", "Г", "В", "Б", "А"]; +var alphabet = ["А", "Б", "В", "Г", "Д", "Е", "Ж", "З", "И", "Й", "К", "Л", "М", "Н", "О", "П", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", "ь", "э", "ю", "я", "ё"]; + +alphabetR.sort(); +var result = true; +for (var i = 0; i < 26; i++) { + if (alphabetR[i] !== alphabet[i]) result = false; +} + +if (result !== true) { + throw new Test262Error('#1: CHECK RUSSIAN ALPHABET'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T3.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T3.js new file mode 100644 index 0000000000..d68d37b134 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T3.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If ToString([[Get]] ToString(j)) < ToString([[Get]] ToString(k)), return -1. + If ToString([[Get]] ToString(j)) > ToString([[Get]] ToString(k)), return 1; + return -1 +esid: sec-array.prototype.sort +description: Checking ToString operator +---*/ + +var obj = { + valueOf: function() { + return 1 + }, + toString: function() { + return -2 + } +}; +var alphabetR = [undefined, 2, 1, "X", -1, "a", true, obj, NaN, Infinity]; +var alphabet = [-1, obj, 1, 2, Infinity, NaN, "X", "a", true, undefined]; + +alphabetR.sort(); +var result = true; +for (var i = 0; i < 10; i++) { + if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) { + if (alphabetR[i] !== alphabet[i]) result = false; + } +} + +if (result !== true) { + throw new Test262Error('#1: Check ToString operator'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.2_T1.js new file mode 100644 index 0000000000..0473e9f881 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.2_T1.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: My comparefn is inverse implementation comparefn +esid: sec-array.prototype.sort +description: Checking ENGLISH ALPHABET +---*/ + +var alphabetR = ["z", "y", "x", "w", "v", "u", "t", "s", "r", "q", "p", "o", "n", "M", "L", "K", "J", "I", "H", "G", "F", "E", "D", "C", "B", "A"]; +var alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]; + +var myComparefn = function(x, y) { + var xS = String(x); + var yS = String(y); + if (xS < yS) return 1 + if (xS > yS) return -1; + return 0; +} + +alphabet.sort(myComparefn); +var result = true; +for (var i = 0; i < 26; i++) { + if (alphabetR[i] !== alphabet[i]) result = false; +} + +if (result !== true) { + throw new Test262Error('#1: CHECK ENGLISH ALPHABET'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.2_T2.js new file mode 100644 index 0000000000..4c719c957f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.2_T2.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: My comparefn is inverse implementation comparefn +esid: sec-array.prototype.sort +description: Checking RUSSIAN ALPHABET +---*/ + +var alphabetR = ["ё", "я", "ю", "э", "ь", "ы", "ъ", "щ", "ш", "ч", "ц", "х", "ф", "у", "т", "с", "р", "П", "О", "Н", "М", "Л", "К", "Й", "И", "З", "Ж", "Е", "Д", "Г", "В", "Б", "А"]; +var alphabet = ["А", "Б", "В", "Г", "Д", "Е", "Ж", "З", "И", "Й", "К", "Л", "М", "Н", "О", "П", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", "ь", "э", "ю", "я", "ё"]; + +var myComparefn = function(x, y) { + var xS = String(x); + var yS = String(y); + if (xS < yS) return 1 + if (xS > yS) return -1; + return 0; +} + +alphabet.sort(myComparefn); +var result = true; +for (var i = 0; i < 26; i++) { + if (alphabetR[i] !== alphabet[i]) result = false; +} + +if (result !== true) { + throw new Test262Error('#1: CHECK RUSSIAN ALPHABET'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.2_T3.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.2_T3.js new file mode 100644 index 0000000000..3eef7ab2be --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.2_T3.js @@ -0,0 +1,41 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: My comparefn is inverse implementation comparefn +esid: sec-array.prototype.sort +description: Checking ToString operator +---*/ + +var obj = { + valueOf: function() { + return 1 + }, + toString: function() { + return -2 + } +}; +var alphabetR = [undefined, 2, 1, "X", -1, "a", true, obj, NaN, Infinity]; +var alphabet = [true, "a", "X", NaN, Infinity, 2, 1, obj, -1, undefined]; + +var myComparefn = function(x, y) { + var xS = String(x); + var yS = String(y); + if (xS < yS) return 1 + if (xS > yS) return -1; + return 0; +} + +alphabetR.sort(myComparefn); +var result = true; +for (var i = 0; i < 10; i++) { + if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) { + if (alphabetR[i] !== alphabet[i]) result = false; + } +} + +if (result !== true) { + throw new Test262Error('#1: Check ToString operator'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A3_T1.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A3_T1.js new file mode 100644 index 0000000000..7add56c4b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A3_T1.js @@ -0,0 +1,54 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The sort function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.sort +description: If comparefn is undefined, use SortCompare operator +---*/ + +var obj = { + valueOf: function() { + return 1 + }, + toString: function() { + return -2 + } +}; +var alphabetR = { + 0: undefined, + 1: 2, + 2: 1, + 3: "X", + 4: -1, + 5: "a", + 6: true, + 7: obj, + 8: NaN, + 9: Infinity +}; +alphabetR.sort = Array.prototype.sort; +alphabetR.length = 10; +var alphabet = [-1, obj, 1, 2, Infinity, NaN, "X", "a", true, undefined]; + +alphabetR.sort(); + +alphabetR.getClass = Object.prototype.toString; +if (alphabetR.getClass() !== "[object " + "Object" + "]") { + throw new Test262Error('#0: alphabetR.sort() is Object object, not Array object'); +} + +var result = true; +for (var i = 0; i < 10; i++) { + if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) { + if (alphabetR[i] !== alphabet[i]) result = false; + } +} + +if (result !== true) { + throw new Test262Error('#1: Check ToString operator'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A3_T2.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A3_T2.js new file mode 100644 index 0000000000..34b9e54b68 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A3_T2.js @@ -0,0 +1,62 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The sort function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.sort +description: If comparefn is not undefined +---*/ + +var obj = { + valueOf: function() { + return 1 + }, + toString: function() { + return -2 + } +}; +var alphabetR = { + 0: undefined, + 1: 2, + 2: 1, + 3: "X", + 4: -1, + 5: "a", + 6: true, + 7: obj, + 8: NaN, + 9: Infinity +}; +alphabetR.sort = Array.prototype.sort; +alphabetR.length = 10; +var alphabet = [true, "a", "X", NaN, Infinity, 2, 1, obj, -1, undefined]; + +var myComparefn = function(x, y) { + var xS = String(x); + var yS = String(y); + if (xS < yS) return 1 + if (xS > yS) return -1; + return 0; +} + +alphabetR.sort(myComparefn); + +alphabetR.getClass = Object.prototype.toString; +if (alphabetR.getClass() !== "[object " + "Object" + "]") { + throw new Test262Error('#0: alphabetR.sort() is Object object, not Array object'); +} + +var result = true; +for (var i = 0; i < 10; i++) { + if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) { + if (alphabetR[i] !== alphabet[i]) result = false; + } +} + +if (result !== true) { + throw new Test262Error('#1: Check ToString operator'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A4_T3.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A4_T3.js new file mode 100644 index 0000000000..75938b93c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A4_T3.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.sort +description: length = -4294967294 +---*/ + +var obj = {}; +obj.sort = Array.prototype.sort; +obj[0] = "z"; +obj[1] = "y"; +obj[2] = "x"; +obj.length = -4294967294; + +if (obj.sort() !== obj) { + throw new Test262Error('#1: var obj = {}; obj.sort = Array.prototype.sort; obj[0] = "z"; obj[1] = "y"; obj[2] = "x"; obj.length = -4294967294; obj.sort() === obj. Actual: ' + (obj.sort())); +} + +if (obj.length !== -4294967294) { + throw new Test262Error('#2: var obj = {}; obj.sort = Array.prototype.sort; obj[0] = "z"; obj[1] = "y"; obj[2] = "x"; obj.length = -4294967294; obj.sort(); obj.length === -4294967294. Actual: ' + (obj.length)); +} + +if (obj[0] !== "z") { + throw new Test262Error('#3: var obj = {}; obj.sort = Array.prototype.sort; obj[0] = "z"; obj[1] = "y"; obj[2] = "x"; obj.length = -4294967294; obj.sort(); obj[0] === "z". Actual: ' + (obj[0])); +} + +if (obj[1] !== "y") { + throw new Test262Error('#4: var obj = {}; obj.sort = Array.prototype.sort; obj[0] = "z"; obj[1] = "y"; obj[2] = "x"; obj.length = -4294967294; obj.sort(); obj[1] === "y". Actual: ' + (obj[1])); +} + +if (obj[2] !== "x") { + throw new Test262Error('#5: var obj = {}; obj.sort = Array.prototype.sort; obj[0] = "z"; obj[1] = "y"; obj[2] = "x"; obj.length = -4294967294; obj.sort(); obj[2] === "x". Actual: ' + (obj[2])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A5_T1.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A5_T1.js new file mode 100644 index 0000000000..18eaabaf40 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A5_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Array.sort should not eat exceptions +esid: sec-array.prototype.sort +description: comparefn function throw "error" +---*/ + +assert.throws(Test262Error, () => { + var myComparefn = function(x, y) { + throw new Test262Error(); + } + var x = [1, 0]; + x.sort(myComparefn); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A6_T2.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A6_T2.js new file mode 100644 index 0000000000..1b75ec229a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A6_T2.js @@ -0,0 +1,63 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.sort +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Array.prototype[1] = -1; +var x = [1, 0]; +x.length = 2; +x.sort(); + +if (x[0] !== 0) { + throw new Test262Error('#1: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#2: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x[1] === 1. Actual: ' + (x[1])); +} + +x.length = 0; + +if (x[0] !== undefined) { + throw new Test262Error('#3: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x.length = 0; x[0] === undefined. Actual: ' + (x[0])); +} + +if (x[1] !== -1) { + throw new Test262Error('#4: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x.length = 0; x[1] === -1. Actual: ' + (x[1])); +} + +Object.prototype[1] = -1; +Object.prototype.length = 2; +Object.prototype.sort = Array.prototype.sort; +x = { + 0: 1, + 1: 0 +}; +x.sort(); + +if (x[0] !== 0) { + throw new Test262Error('#5: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = Array.prototype.sort; x = {0:1,1:0}; x.sort(); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#6: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = Array.prototype.sort; x = {0:1,1:0}; x.sort(); x[1] === 1. Actual: ' + (x[1])); +} + +delete x[0]; +delete x[1]; + +if (x[0] !== undefined) { + throw new Test262Error('#7: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = Array.prototype.sort; x = {0:1,1:0}; x.sort(); delete x[0]; delete x[1]; x[0] === undefined. Actual: ' + (x[0])); +} + +if (x[1] !== -1) { + throw new Test262Error('#8: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = Array.prototype.sort; x = {0:1,1:0}; x.sort(); delete x[0]; delete x[1]; x[1] === -1. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A8.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A8.js new file mode 100644 index 0000000000..7aa320b0ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A8.js @@ -0,0 +1,25 @@ +// Copyright 2011 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Call the comparefn passing undefined as the this value (step 13b) +esid: sec-array.prototype.sort +description: comparefn tests that its this value is undefined +flags: [noStrict] +---*/ + +var global = this; +[2, 3].sort(function(x, y) { + "use strict"; + + if (this === global) { + throw new Test262Error('#1: Sort leaks global'); + } + if (this !== undefined) { + throw new Test262Error('#2: Sort comparefn should be called with this===undefined. ' + + 'Actual: ' + this); + } + return x - y; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/browser.js b/js/src/tests/test262/built-ins/Array/prototype/sort/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/bug_596_1.js b/js/src/tests/test262/built-ins/Array/prototype/sort/bug_596_1.js new file mode 100644 index 0000000000..0298cbc442 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/bug_596_1.js @@ -0,0 +1,26 @@ +// Copyright (c) 2014 Thomas Dahlstrom. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + The SortCompare abstract operation calls ToString() for identical + elements (step 14/15) +author: Thomas Dahlstrom (tdahlstrom@gmail.com) +---*/ + +var counter = 0; +var object = { + toString: function() { + counter++; + return ""; + } +}; + +[object, object].sort(); +if (counter < 2) { + // sort calls ToString() for each element at least once + throw new Test262Error('#1: [object, object].sort(); counter < 2. Actual: ' + (counter)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/bug_596_2.js b/js/src/tests/test262/built-ins/Array/prototype/sort/bug_596_2.js new file mode 100644 index 0000000000..7caa4a9f2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/bug_596_2.js @@ -0,0 +1,57 @@ +// Copyright (c) 2014 Thomas Dahlstrom. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Array.prototype.sort does not change non-existent elements to + undefined elements, that means holes are preserved (cf. spec text + about [[Delete]] and sparse arrays) +author: Thomas Dahlstrom (tdahlstrom@gmail.com) +---*/ + +var array = ['a', , void 0]; + +//CHECK#1 +if (array.length !== 3) { + throw new Test262Error('#1: array.length !== 3. Actual: ' + (array.length)) +} + +//CHECK#2 +if (array.hasOwnProperty('0') !== true) { + throw new Test262Error("#2: array.hasOwnProperty('0'). Actual: " + array.hasOwnProperty('0')); +} + +//CHECK#3 +if (array.hasOwnProperty('1') !== false) { + throw new Test262Error("#3: array.hasOwnProperty('1'). Actual: " + array.hasOwnProperty('1')); +} + +//CHECK#4 +if (array.hasOwnProperty('2') !== true) { + throw new Test262Error("#4: array.hasOwnProperty('2'). Actual: " + array.hasOwnProperty('2')); +} + +array.sort(); + +//CHECK#5 +if (array.length !== 3) { + throw new Test262Error('#5: array.length !== 3. Actual: ' + (array.length)) +} + +//CHECK#6 +if (array.hasOwnProperty('0') !== true) { + throw new Test262Error("#6: array.hasOwnProperty('0'). Actual: " + array.hasOwnProperty('0')); +} + +//CHECK#7 +if (array.hasOwnProperty('1') !== true) { + throw new Test262Error("#7: array.hasOwnProperty('1'). Actual: " + array.hasOwnProperty('1')); +} + +//CHECK#8 +if (array.hasOwnProperty('2') !== false) { + throw new Test262Error("#8: array.hasOwnProperty('2'). Actual: " + array.hasOwnProperty('2')); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/call-with-primitive.js b/js/src/tests/test262/built-ins/Array/prototype/sort/call-with-primitive.js new file mode 100644 index 0000000000..f1d1554da8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/call-with-primitive.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + This value is coerced to an object. +info: | + Array.prototype.sort ( comparefn ) + + [...] + 2. Let obj be ? ToObject(this value). + [...] + 12. Return obj. +features: [Symbol, BigInt] +---*/ + +assert.throws(TypeError, function() { + [].sort.call(undefined); +}, "undefined"); + +assert.throws(TypeError, function() { + [].sort.call(null); +}, "null"); + +assert([].sort.call(false) instanceof Boolean, "boolean"); +assert([].sort.call(0) instanceof Number, "number"); +assert([].sort.call("") instanceof String, "string"); +assert([].sort.call(Symbol()) instanceof Symbol, "symbol"); +assert([].sort.call(0n) instanceof BigInt, "bigint"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/comparefn-nonfunction-call-throws.js b/js/src/tests/test262/built-ins/Array/prototype/sort/comparefn-nonfunction-call-throws.js new file mode 100644 index 0000000000..bef7ff158b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/comparefn-nonfunction-call-throws.js @@ -0,0 +1,97 @@ +// Copyright (C) 2017 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.sort +description: throws on a non-undefined non-function +info: | + 22.1.3.25 Array.prototype.sort ( comparefn ) + + Upon entry, the following steps are performed to initialize evaluation + of the sort function: + + ... + 1. If _comparefn_ is not *undefined* and IsCallable(_comparefn_) is *false*, throw a *TypeError* exception. + ... +features: [Symbol] +---*/ + +var sample = [1]; +var poisoned = { + get length() { + throw new Test262Error("IsCallable(comparefn) should be observed before this.length"); + } +}; + +assert.throws(TypeError, function() { + sample.sort(null); +}, "sample.sort(null);"); + +assert.throws(TypeError, function() { + [].sort.call(poisoned, null); +}, "[].sort.call(poisoned, null);"); + +assert.throws(TypeError, function() { + sample.sort(true); +}, "sample.sort(true);"); + +assert.throws(TypeError, function() { + [].sort.call(poisoned, true); +}, "[].sort.call(poisoned, true);"); + +assert.throws(TypeError, function() { + sample.sort(false); +}, "sample.sort(false);"); + +assert.throws(TypeError, function() { + [].sort.call(poisoned, false); +}, "[].sort.call(poisoned, false);"); + +assert.throws(TypeError, function() { + sample.sort(''); +}, "sample.sort('');"); + +assert.throws(TypeError, function() { + [].sort.call(poisoned, ''); +}, "[].sort.call(poisoned, '');"); + +assert.throws(TypeError, function() { + sample.sort(/a/g); +}, "sample.sort(/a/g);"); + +assert.throws(TypeError, function() { + [].sort.call(poisoned, /a/g); +}, "[].sort.call(poisoned, /a/g);"); + +assert.throws(TypeError, function() { + sample.sort(42); +}, "sample.sort(42);"); + +assert.throws(TypeError, function() { + [].sort.call(poisoned, 42); +}, "[].sort.call(poisoned, 42);"); + +assert.throws(TypeError, function() { + sample.sort([]); +}, "sample.sort([]);"); + +assert.throws(TypeError, function() { + [].sort.call(poisoned, []); +}, "[].sort.call(poisoned, []);"); + +assert.throws(TypeError, function() { + sample.sort({}); +}, "sample.sort({});"); + +assert.throws(TypeError, function() { + [].sort.call(poisoned, {}); +}, "[].sort.call(poisoned, {});"); + +assert.throws(TypeError, function() { + sample.sort(Symbol()); +}, "sample.sort(Symbol());"); + +assert.throws(TypeError, function() { + [].sort.call(poisoned, Symbol()); +}, "[].sort.call(poisoned, Symbol());"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/length.js b/js/src/tests/test262/built-ins/Array/prototype/sort/length.js new file mode 100644 index 0000000000..67a6be2969 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + The "length" property of Array.prototype.sort +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.sort.length, 1); + +verifyNotEnumerable(Array.prototype.sort, 'length'); +verifyNotWritable(Array.prototype.sort, 'length'); +verifyConfigurable(Array.prototype.sort, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/name.js b/js/src/tests/test262/built-ins/Array/prototype/sort/name.js new file mode 100644 index 0000000000..5ec58a1bb8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Array.prototype.sort.name is "sort". +info: | + Array.prototype.sort (comparefn) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.sort.name, "sort"); + +verifyNotEnumerable(Array.prototype.sort, "name"); +verifyNotWritable(Array.prototype.sort, "name"); +verifyConfigurable(Array.prototype.sort, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/sort/not-a-constructor.js new file mode 100644 index 0000000000..e9dd5a40d3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/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: > + Array.prototype.sort 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, arrow-function] +---*/ + +assert.sameValue(isConstructor(Array.prototype.sort), false, 'isConstructor(Array.prototype.sort) must return false'); + +assert.throws(TypeError, () => { + new Array.prototype.sort(); +}, '`new Array.prototype.sort()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-comparefn-throws.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-comparefn-throws.js new file mode 100644 index 0000000000..3c5950982e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-comparefn-throws.js @@ -0,0 +1,54 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const logs = []; + +Object.defineProperty(Object.prototype, '2', { + get() { + logs.push('get'); + return 4; + }, + set(v) { + logs.push(`set with ${v}`); + } +}); +const array = [undefined, 3, /*hole*/, 2, undefined, /*hole*/, 1]; +let count = 0; +try { + array.sort((a, b) => { + if (++count === 3) { + throw new Error('lolwat'); + } + return b - a; + }); +} catch (exception) { + logs.push(exception.message); +} + +assert.sameValue(logs[0], 'get'); +assert.sameValue(logs[1], 'lolwat'); +assert.sameValue(logs.length, 2); + +assert.sameValue(array[0], undefined); +assert.sameValue(array[1], 3); +assert.sameValue('2' in array, true); +assert.sameValue(array.hasOwnProperty('2'), false); +assert.sameValue(array[3], 2); +assert.sameValue(array[4], undefined); +assert.sameValue('5' in array, false); +assert.sameValue(array.hasOwnProperty('5'), false); +assert.sameValue(array[6], 1); +assert.sameValue(array.length, 7); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-appends-elements.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-appends-elements.js new file mode 100644 index 0000000000..d1f7ad7194 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-appends-elements.js @@ -0,0 +1,51 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + array.push('foo'); + array.push('bar'); + return this.foo; + }, + set(v) { + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue('2' in array, true); +assert.sameValue(array.hasOwnProperty('2'), true); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array[8], 'foo'); +assert.sameValue(array[9], 'bar'); +assert.sameValue(array.length, 10); +assert.sameValue(array.foo, 'c'); + +assert.sameValue(array[2], 'c'); +assert.sameValue(array[10], 'foo'); +assert.sameValue(array[11], 'bar'); +assert.sameValue(array.length, 12); +assert.sameValue(array.foo, 'c'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-decreases-length.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-decreases-length.js new file mode 100644 index 0000000000..c184ad10bf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-decreases-length.js @@ -0,0 +1,41 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + array.length = array.length - 2; + return this.foo; + }, + set(v) { + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'b'); +assert.sameValue(array[1], 'c'); +assert.sameValue(array[3], undefined); +assert.sameValue(array[4], undefined); +assert.sameValue('5' in array, false); +assert.sameValue(array.hasOwnProperty('5'), false); +assert.sameValue(array.length, 6); +assert.sameValue(array.foo, undefined); + +assert.sameValue(array[2], undefined); +assert.sameValue(array.length, 4); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-deletes-predecessor.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-deletes-predecessor.js new file mode 100644 index 0000000000..01348cf269 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-deletes-predecessor.js @@ -0,0 +1,45 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + delete array[1]; + return this.foo; + }, + set(v) { + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'c'); + +assert.sameValue(array[2], 'c'); +assert.sameValue('1' in array, false); +assert.sameValue(array.hasOwnProperty(1), false); +assert.sameValue(array.length, 8); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-deletes-successor.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-deletes-successor.js new file mode 100644 index 0000000000..4e52b7228c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-deletes-successor.js @@ -0,0 +1,46 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + delete array[3]; + return this.foo; + }, + set(v) { + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'c'); +assert.sameValue(array[3], undefined); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue('6' in array, false); +assert.sameValue(array.hasOwnProperty('6'), false); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'd'); + +assert.sameValue(array[2], 'd'); +assert.sameValue('3' in array, false); +assert.sameValue(array.hasOwnProperty(3), false); +assert.sameValue(array.length, 8); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-increases-length.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-increases-length.js new file mode 100644 index 0000000000..e7d9fbf855 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-increases-length.js @@ -0,0 +1,51 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + array.length = array.length + 2; + return this.foo; + }, + set(v) { + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue('8' in array, false); +assert.sameValue(array.hasOwnProperty('8'), false); +assert.sameValue('9' in array, false); +assert.sameValue(array.hasOwnProperty('9'), false); +assert.sameValue(array.length, 10); +assert.sameValue(array.foo, 'c'); + +assert.sameValue(array[2], 'c'); +assert.sameValue('10' in array, false); +assert.sameValue(array.hasOwnProperty('10'), false); +assert.sameValue('11' in array, false); +assert.sameValue(array.hasOwnProperty('11'), false); +assert.sameValue(array.length, 12); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-pops-elements.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-pops-elements.js new file mode 100644 index 0000000000..8fb67f84e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-pops-elements.js @@ -0,0 +1,42 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + array.pop(); + array.pop(); + return this.foo; + }, + set(v) { + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'b'); +assert.sameValue(array[1], 'c'); +assert.sameValue(array[3], undefined); +assert.sameValue(array[4], undefined); +assert.sameValue('5' in array, false); +assert.sameValue(array.hasOwnProperty('5'), false); +assert.sameValue(array.length, 6); +assert.sameValue(array.foo, undefined); + +assert.sameValue(array[2], undefined); +assert.sameValue(array.length, 4); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-sets-predecessor.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-sets-predecessor.js new file mode 100644 index 0000000000..ed440f22ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-sets-predecessor.js @@ -0,0 +1,43 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + array[1] = 'foobar'; + return this.foo; + }, + set(v) { + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'c'); + +assert.sameValue(array[2], 'c'); +assert.sameValue(array[1], 'foobar'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-sets-successor.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-sets-successor.js new file mode 100644 index 0000000000..e6534ab021 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-getter-sets-successor.js @@ -0,0 +1,43 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + array[3] = 'foobar'; + return this.foo; + }, + set(v) { + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'c'); +assert.sameValue(array[3], 'foobar'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'd'); + +assert.sameValue(array[2], 'd'); +assert.sameValue(array[3], 'foobar'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-prototype-accessors.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-prototype-accessors.js new file mode 100644 index 0000000000..ccad0bbf50 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-prototype-accessors.js @@ -0,0 +1,44 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const logs = []; + +Object.defineProperty(Object.prototype, '2', { + get() { + logs.push('get'); + return 4; + }, + set(v) { + logs.push(`set with ${v}`); + } +}); +const array = [undefined, 3, /*hole*/, 2, undefined, /*hole*/, 1]; +array.sort(); + +assert.sameValue(logs[0], 'get'); +assert.sameValue(logs[1], 'set with 3'); +assert.sameValue(logs.length, 2); + +assert.sameValue(array[0], 1); +assert.sameValue(array[1], 2); +assert.sameValue('2' in array, true); +assert.sameValue(array.hasOwnProperty('2'), false); +assert.sameValue(array[3], 4); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue('6' in array, false); +assert.sameValue(array.hasOwnProperty('6'), false); +assert.sameValue(array.length, 7); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-prototype-element.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-prototype-element.js new file mode 100644 index 0000000000..18051f01a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-prototype-element.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +Object.prototype[2] = 4; +const array = [undefined, 3, /*hole*/, 2, undefined, /*hole*/, 1]; +array.sort(); + +assert.sameValue(array[0], 1); +assert.sameValue(array[1], 2); +assert.sameValue(array[2], 3); +assert.sameValue(array[3], 4); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue('6' in array, false); +assert.sameValue(array.hasOwnProperty('6'), false); +assert.sameValue(array.length, 7); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-appends-elements.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-appends-elements.js new file mode 100644 index 0000000000..b5d7d8bdfb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-appends-elements.js @@ -0,0 +1,44 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + array.push('foo'); + array.push('bar'); + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array[8], 'foo'); +assert.sameValue(array[9], 'bar'); +assert.sameValue(array.length, 10); +assert.sameValue(array.foo, 'c'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-decreases-length.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-decreases-length.js new file mode 100644 index 0000000000..7d3fff0ebf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-decreases-length.js @@ -0,0 +1,39 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + array.length = array.length - 2; + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue(array.length, 7); +assert.sameValue(array.foo, 'c'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-deletes-predecessor.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-deletes-predecessor.js new file mode 100644 index 0000000000..483917d83b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-deletes-predecessor.js @@ -0,0 +1,42 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + delete array[1]; + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'a'); +assert.sameValue('1' in array, false); +assert.sameValue(array.hasOwnProperty(1), false); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'c'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-deletes-successor.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-deletes-successor.js new file mode 100644 index 0000000000..f78b134f14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-deletes-successor.js @@ -0,0 +1,41 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + delete array[3]; + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'c'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-increases-length.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-increases-length.js new file mode 100644 index 0000000000..bb95633fea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-increases-length.js @@ -0,0 +1,45 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + array.length = array.length + 2; + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue('8' in array, false); +assert.sameValue(array.hasOwnProperty('8'), false); +assert.sameValue('9' in array, false); +assert.sameValue(array.hasOwnProperty('9'), false); +assert.sameValue(array.length, 10); +assert.sameValue(array.foo, 'c'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-pops-elements.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-pops-elements.js new file mode 100644 index 0000000000..27b5731308 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-pops-elements.js @@ -0,0 +1,40 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + array.pop(); + array.pop(); + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue(array.length, 7); +assert.sameValue(array.foo, 'c'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-sets-predecessor.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-sets-predecessor.js new file mode 100644 index 0000000000..95c7987196 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-sets-predecessor.js @@ -0,0 +1,41 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + array[1] = 'foobar'; + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'foobar'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'c'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-sets-successor.js b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-sets-successor.js new file mode 100644 index 0000000000..adae4922bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/precise-setter-sets-successor.js @@ -0,0 +1,41 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; + +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + array[3] = 'foobar'; + this.foo = v; + } +}); + +array.sort(); + +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'c'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/sort/prop-desc.js new file mode 100644 index 0000000000..a1844b2aea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + "sort" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.sort, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "sort"); +verifyWritable(Array.prototype, "sort"); +verifyConfigurable(Array.prototype, "sort"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/shell.js b/js/src/tests/test262/built-ins/Array/prototype/sort/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/stability-11-elements.js b/js/src/tests/test262/built-ins/Array/prototype/sort/stability-11-elements.js new file mode 100644 index 0000000000..2505b5228a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/stability-11-elements.js @@ -0,0 +1,38 @@ +// Copyright (C) 2018 Mathias Bynens. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Stability of Array.prototype.sort for an array with 11 elements. +info: | + The sort is required to be stable (that is, elements that compare equal + remain in their original order). + The array length of 11 was chosen because V8 used an unstable + QuickSort for arrays with more than 10 elements until v7.0 (September + 2018). https://v8.dev/blog/array-sort +---*/ + +const array = [ + { name: 'A', rating: 2 }, + { name: 'B', rating: 3 }, + { name: 'C', rating: 2 }, + { name: 'D', rating: 4 }, + { name: 'E', rating: 3 }, + { name: 'F', rating: 3 }, + { name: 'G', rating: 4 }, + { name: 'H', rating: 3 }, + { name: 'I', rating: 2 }, + { name: 'J', rating: 2 }, + { name: 'K', rating: 2 }, +]; +assert.sameValue(array.length, 11); + +// Sort the elements by `rating` in descending order. +// (This updates `array` in place.) +array.sort((a, b) => b.rating - a.rating); + +const reduced = array.reduce((acc, element) => acc + element.name, ''); +assert.sameValue(reduced, 'DGBEFHACIJK'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/stability-2048-elements.js b/js/src/tests/test262/built-ins/Array/prototype/sort/stability-2048-elements.js new file mode 100644 index 0000000000..e791036a26 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/stability-2048-elements.js @@ -0,0 +1,2083 @@ +// Copyright (C) 2018 Mathias Bynens. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Stability of Array.prototype.sort for an array with 2048 elements. +info: | + The sort is required to be stable (that is, elements that compare equal + remain in their original order). + The array length of 2048 was chosen because as of late 2018, Chakra + uses merge sort for arrays with 2048 or more elements. It uses + insertion sort for smaller arrays. + https://github.com/Microsoft/ChakraCore/pull/5724/files#diff-85203ec16f5961eb4c18e4253bb42140R337 +---*/ + +const array = [ + { name: 'A000', rating: 2 }, + { name: 'A001', rating: 2 }, + { name: 'A002', rating: 2 }, + { name: 'A003', rating: 2 }, + { name: 'A004', rating: 2 }, + { name: 'A005', rating: 2 }, + { name: 'A006', rating: 2 }, + { name: 'A007', rating: 2 }, + { name: 'A008', rating: 2 }, + { name: 'A009', rating: 2 }, + { name: 'A010', rating: 2 }, + { name: 'A011', rating: 2 }, + { name: 'A012', rating: 2 }, + { name: 'A013', rating: 2 }, + { name: 'A014', rating: 2 }, + { name: 'A015', rating: 2 }, + { name: 'A016', rating: 2 }, + { name: 'A017', rating: 2 }, + { name: 'A018', rating: 2 }, + { name: 'A019', rating: 2 }, + { name: 'A020', rating: 2 }, + { name: 'A021', rating: 2 }, + { name: 'A022', rating: 2 }, + { name: 'A023', rating: 2 }, + { name: 'A024', rating: 2 }, + { name: 'A025', rating: 2 }, + { name: 'A026', rating: 2 }, + { name: 'A027', rating: 2 }, + { name: 'A028', rating: 2 }, + { name: 'A029', rating: 2 }, + { name: 'A030', rating: 2 }, + { name: 'A031', rating: 2 }, + { name: 'A032', rating: 2 }, + { name: 'A033', rating: 2 }, + { name: 'A034', rating: 2 }, + { name: 'A035', rating: 2 }, + { name: 'A036', rating: 2 }, + { name: 'A037', rating: 2 }, + { name: 'A038', rating: 2 }, + { name: 'A039', rating: 2 }, + { name: 'A040', rating: 2 }, + { name: 'A041', rating: 2 }, + { name: 'A042', rating: 2 }, + { name: 'A043', rating: 2 }, + { name: 'A044', rating: 2 }, + { name: 'A045', rating: 2 }, + { name: 'A046', rating: 2 }, + { name: 'A047', rating: 2 }, + { name: 'A048', rating: 2 }, + { name: 'A049', rating: 2 }, + { name: 'A050', rating: 2 }, + { name: 'A051', rating: 2 }, + { name: 'A052', rating: 2 }, + { name: 'A053', rating: 2 }, + { name: 'A054', rating: 2 }, + { name: 'A055', rating: 2 }, + { name: 'A056', rating: 2 }, + { name: 'A057', rating: 2 }, + { name: 'A058', rating: 2 }, + { name: 'A059', rating: 2 }, + { name: 'A060', rating: 2 }, + { name: 'A061', rating: 2 }, + { name: 'A062', rating: 2 }, + { name: 'A063', rating: 2 }, + { name: 'A064', rating: 2 }, + { name: 'A065', rating: 2 }, + { name: 'A066', rating: 2 }, + { name: 'A067', rating: 2 }, + { name: 'A068', rating: 2 }, + { name: 'A069', rating: 2 }, + { name: 'A070', rating: 2 }, + { name: 'A071', rating: 2 }, + { name: 'A072', rating: 2 }, + { name: 'A073', rating: 2 }, + { name: 'A074', rating: 2 }, + { name: 'A075', rating: 2 }, + { name: 'A076', rating: 2 }, + { name: 'A077', rating: 2 }, + { name: 'A078', rating: 2 }, + { name: 'A079', rating: 2 }, + { name: 'A080', rating: 2 }, + { name: 'A081', rating: 2 }, + { name: 'A082', rating: 2 }, + { name: 'A083', rating: 2 }, + { name: 'A084', rating: 2 }, + { name: 'A085', rating: 2 }, + { name: 'A086', rating: 2 }, + { name: 'A087', rating: 2 }, + { name: 'A088', rating: 2 }, + { name: 'A089', rating: 2 }, + { name: 'A090', rating: 2 }, + { name: 'A091', rating: 2 }, + { name: 'A092', rating: 2 }, + { name: 'A093', rating: 2 }, + { name: 'A094', rating: 2 }, + { name: 'A095', rating: 2 }, + { name: 'A096', rating: 2 }, + { name: 'A097', rating: 2 }, + { name: 'A098', rating: 2 }, + { name: 'A099', rating: 2 }, + { name: 'A100', rating: 2 }, + { name: 'A101', rating: 2 }, + { name: 'A102', rating: 2 }, + { name: 'A103', rating: 2 }, + { name: 'A104', rating: 2 }, + { name: 'A105', rating: 2 }, + { name: 'A106', rating: 2 }, + { name: 'A107', rating: 2 }, + { name: 'A108', rating: 2 }, + { name: 'A109', rating: 2 }, + { name: 'A110', rating: 2 }, + { name: 'A111', rating: 2 }, + { name: 'A112', rating: 2 }, + { name: 'A113', rating: 2 }, + { name: 'A114', rating: 2 }, + { name: 'A115', rating: 2 }, + { name: 'A116', rating: 2 }, + { name: 'A117', rating: 2 }, + { name: 'A118', rating: 2 }, + { name: 'A119', rating: 2 }, + { name: 'A120', rating: 2 }, + { name: 'A121', rating: 2 }, + { name: 'A122', rating: 2 }, + { name: 'A123', rating: 2 }, + { name: 'A124', rating: 2 }, + { name: 'A125', rating: 2 }, + { name: 'A126', rating: 2 }, + { name: 'A127', rating: 2 }, + { name: 'A128', rating: 2 }, + { name: 'A129', rating: 2 }, + { name: 'A130', rating: 2 }, + { name: 'A131', rating: 2 }, + { name: 'A132', rating: 2 }, + { name: 'A133', rating: 2 }, + { name: 'A134', rating: 2 }, + { name: 'A135', rating: 2 }, + { name: 'A136', rating: 2 }, + { name: 'A137', rating: 2 }, + { name: 'A138', rating: 2 }, + { name: 'A139', rating: 2 }, + { name: 'A140', rating: 2 }, + { name: 'A141', rating: 2 }, + { name: 'A142', rating: 2 }, + { name: 'A143', rating: 2 }, + { name: 'A144', rating: 2 }, + { name: 'A145', rating: 2 }, + { name: 'A146', rating: 2 }, + { name: 'A147', rating: 2 }, + { name: 'A148', rating: 2 }, + { name: 'A149', rating: 2 }, + { name: 'A150', rating: 2 }, + { name: 'A151', rating: 2 }, + { name: 'A152', rating: 2 }, + { name: 'A153', rating: 2 }, + { name: 'A154', rating: 2 }, + { name: 'A155', rating: 2 }, + { name: 'A156', rating: 2 }, + { name: 'A157', rating: 2 }, + { name: 'A158', rating: 2 }, + { name: 'A159', rating: 2 }, + { name: 'A160', rating: 2 }, + { name: 'A161', rating: 2 }, + { name: 'A162', rating: 2 }, + { name: 'A163', rating: 2 }, + { name: 'A164', rating: 2 }, + { name: 'A165', rating: 2 }, + { name: 'A166', rating: 2 }, + { name: 'A167', rating: 2 }, + { name: 'A168', rating: 2 }, + { name: 'A169', rating: 2 }, + { name: 'A170', rating: 2 }, + { name: 'A171', rating: 2 }, + { name: 'A172', rating: 2 }, + { name: 'A173', rating: 2 }, + { name: 'A174', rating: 2 }, + { name: 'A175', rating: 2 }, + { name: 'A176', rating: 2 }, + { name: 'A177', rating: 2 }, + { name: 'A178', rating: 2 }, + { name: 'A179', rating: 2 }, + { name: 'A180', rating: 2 }, + { name: 'A181', rating: 2 }, + { name: 'A182', rating: 2 }, + { name: 'A183', rating: 2 }, + { name: 'A184', rating: 2 }, + { name: 'A185', rating: 2 }, + { name: 'A186', rating: 2 }, + { name: 'B000', rating: 3 }, + { name: 'B001', rating: 3 }, + { name: 'B002', rating: 3 }, + { name: 'B003', rating: 3 }, + { name: 'B004', rating: 3 }, + { name: 'B005', rating: 3 }, + { name: 'B006', rating: 3 }, + { name: 'B007', rating: 3 }, + { name: 'B008', rating: 3 }, + { name: 'B009', rating: 3 }, + { name: 'B010', rating: 3 }, + { name: 'B011', rating: 3 }, + { name: 'B012', rating: 3 }, + { name: 'B013', rating: 3 }, + { name: 'B014', rating: 3 }, + { name: 'B015', rating: 3 }, + { name: 'B016', rating: 3 }, + { name: 'B017', rating: 3 }, + { name: 'B018', rating: 3 }, + { name: 'B019', rating: 3 }, + { name: 'B020', rating: 3 }, + { name: 'B021', rating: 3 }, + { name: 'B022', rating: 3 }, + { name: 'B023', rating: 3 }, + { name: 'B024', rating: 3 }, + { name: 'B025', rating: 3 }, + { name: 'B026', rating: 3 }, + { name: 'B027', rating: 3 }, + { name: 'B028', rating: 3 }, + { name: 'B029', rating: 3 }, + { name: 'B030', rating: 3 }, + { name: 'B031', rating: 3 }, + { name: 'B032', rating: 3 }, + { name: 'B033', rating: 3 }, + { name: 'B034', rating: 3 }, + { name: 'B035', rating: 3 }, + { name: 'B036', rating: 3 }, + { name: 'B037', rating: 3 }, + { name: 'B038', rating: 3 }, + { name: 'B039', rating: 3 }, + { name: 'B040', rating: 3 }, + { name: 'B041', rating: 3 }, + { name: 'B042', rating: 3 }, + { name: 'B043', rating: 3 }, + { name: 'B044', rating: 3 }, + { name: 'B045', rating: 3 }, + { name: 'B046', rating: 3 }, + { name: 'B047', rating: 3 }, + { name: 'B048', rating: 3 }, + { name: 'B049', rating: 3 }, + { name: 'B050', rating: 3 }, + { name: 'B051', rating: 3 }, + { name: 'B052', rating: 3 }, + { name: 'B053', rating: 3 }, + { name: 'B054', rating: 3 }, + { name: 'B055', rating: 3 }, + { name: 'B056', rating: 3 }, + { name: 'B057', rating: 3 }, + { name: 'B058', rating: 3 }, + { name: 'B059', rating: 3 }, + { name: 'B060', rating: 3 }, + { name: 'B061', rating: 3 }, + { name: 'B062', rating: 3 }, + { name: 'B063', rating: 3 }, + { name: 'B064', rating: 3 }, + { name: 'B065', rating: 3 }, + { name: 'B066', rating: 3 }, + { name: 'B067', rating: 3 }, + { name: 'B068', rating: 3 }, + { name: 'B069', rating: 3 }, + { name: 'B070', rating: 3 }, + { name: 'B071', rating: 3 }, + { name: 'B072', rating: 3 }, + { name: 'B073', rating: 3 }, + { name: 'B074', rating: 3 }, + { name: 'B075', rating: 3 }, + { name: 'B076', rating: 3 }, + { name: 'B077', rating: 3 }, + { name: 'B078', rating: 3 }, + { name: 'B079', rating: 3 }, + { name: 'B080', rating: 3 }, + { name: 'B081', rating: 3 }, + { name: 'B082', rating: 3 }, + { name: 'B083', rating: 3 }, + { name: 'B084', rating: 3 }, + { name: 'B085', rating: 3 }, + { name: 'B086', rating: 3 }, + { name: 'B087', rating: 3 }, + { name: 'B088', rating: 3 }, + { name: 'B089', rating: 3 }, + { name: 'B090', rating: 3 }, + { name: 'B091', rating: 3 }, + { name: 'B092', rating: 3 }, + { name: 'B093', rating: 3 }, + { name: 'B094', rating: 3 }, + { name: 'B095', rating: 3 }, + { name: 'B096', rating: 3 }, + { name: 'B097', rating: 3 }, + { name: 'B098', rating: 3 }, + { name: 'B099', rating: 3 }, + { name: 'B100', rating: 3 }, + { name: 'B101', rating: 3 }, + { name: 'B102', rating: 3 }, + { name: 'B103', rating: 3 }, + { name: 'B104', rating: 3 }, + { name: 'B105', rating: 3 }, + { name: 'B106', rating: 3 }, + { name: 'B107', rating: 3 }, + { name: 'B108', rating: 3 }, + { name: 'B109', rating: 3 }, + { name: 'B110', rating: 3 }, + { name: 'B111', rating: 3 }, + { name: 'B112', rating: 3 }, + { name: 'B113', rating: 3 }, + { name: 'B114', rating: 3 }, + { name: 'B115', rating: 3 }, + { name: 'B116', rating: 3 }, + { name: 'B117', rating: 3 }, + { name: 'B118', rating: 3 }, + { name: 'B119', rating: 3 }, + { name: 'B120', rating: 3 }, + { name: 'B121', rating: 3 }, + { name: 'B122', rating: 3 }, + { name: 'B123', rating: 3 }, + { name: 'B124', rating: 3 }, + { name: 'B125', rating: 3 }, + { name: 'B126', rating: 3 }, + { name: 'B127', rating: 3 }, + { name: 'B128', rating: 3 }, + { name: 'B129', rating: 3 }, + { name: 'B130', rating: 3 }, + { name: 'B131', rating: 3 }, + { name: 'B132', rating: 3 }, + { name: 'B133', rating: 3 }, + { name: 'B134', rating: 3 }, + { name: 'B135', rating: 3 }, + { name: 'B136', rating: 3 }, + { name: 'B137', rating: 3 }, + { name: 'B138', rating: 3 }, + { name: 'B139', rating: 3 }, + { name: 'B140', rating: 3 }, + { name: 'B141', rating: 3 }, + { name: 'B142', rating: 3 }, + { name: 'B143', rating: 3 }, + { name: 'B144', rating: 3 }, + { name: 'B145', rating: 3 }, + { name: 'B146', rating: 3 }, + { name: 'B147', rating: 3 }, + { name: 'B148', rating: 3 }, + { name: 'B149', rating: 3 }, + { name: 'B150', rating: 3 }, + { name: 'B151', rating: 3 }, + { name: 'B152', rating: 3 }, + { name: 'B153', rating: 3 }, + { name: 'B154', rating: 3 }, + { name: 'B155', rating: 3 }, + { name: 'B156', rating: 3 }, + { name: 'B157', rating: 3 }, + { name: 'B158', rating: 3 }, + { name: 'B159', rating: 3 }, + { name: 'B160', rating: 3 }, + { name: 'B161', rating: 3 }, + { name: 'B162', rating: 3 }, + { name: 'B163', rating: 3 }, + { name: 'B164', rating: 3 }, + { name: 'B165', rating: 3 }, + { name: 'B166', rating: 3 }, + { name: 'B167', rating: 3 }, + { name: 'B168', rating: 3 }, + { name: 'B169', rating: 3 }, + { name: 'B170', rating: 3 }, + { name: 'B171', rating: 3 }, + { name: 'B172', rating: 3 }, + { name: 'B173', rating: 3 }, + { name: 'B174', rating: 3 }, + { name: 'B175', rating: 3 }, + { name: 'B176', rating: 3 }, + { name: 'B177', rating: 3 }, + { name: 'B178', rating: 3 }, + { name: 'B179', rating: 3 }, + { name: 'B180', rating: 3 }, + { name: 'B181', rating: 3 }, + { name: 'B182', rating: 3 }, + { name: 'B183', rating: 3 }, + { name: 'B184', rating: 3 }, + { name: 'B185', rating: 3 }, + { name: 'B186', rating: 3 }, + { name: 'C000', rating: 2 }, + { name: 'C001', rating: 2 }, + { name: 'C002', rating: 2 }, + { name: 'C003', rating: 2 }, + { name: 'C004', rating: 2 }, + { name: 'C005', rating: 2 }, + { name: 'C006', rating: 2 }, + { name: 'C007', rating: 2 }, + { name: 'C008', rating: 2 }, + { name: 'C009', rating: 2 }, + { name: 'C010', rating: 2 }, + { name: 'C011', rating: 2 }, + { name: 'C012', rating: 2 }, + { name: 'C013', rating: 2 }, + { name: 'C014', rating: 2 }, + { name: 'C015', rating: 2 }, + { name: 'C016', rating: 2 }, + { name: 'C017', rating: 2 }, + { name: 'C018', rating: 2 }, + { name: 'C019', rating: 2 }, + { name: 'C020', rating: 2 }, + { name: 'C021', rating: 2 }, + { name: 'C022', rating: 2 }, + { name: 'C023', rating: 2 }, + { name: 'C024', rating: 2 }, + { name: 'C025', rating: 2 }, + { name: 'C026', rating: 2 }, + { name: 'C027', rating: 2 }, + { name: 'C028', rating: 2 }, + { name: 'C029', rating: 2 }, + { name: 'C030', rating: 2 }, + { name: 'C031', rating: 2 }, + { name: 'C032', rating: 2 }, + { name: 'C033', rating: 2 }, + { name: 'C034', rating: 2 }, + { name: 'C035', rating: 2 }, + { name: 'C036', rating: 2 }, + { name: 'C037', rating: 2 }, + { name: 'C038', rating: 2 }, + { name: 'C039', rating: 2 }, + { name: 'C040', rating: 2 }, + { name: 'C041', rating: 2 }, + { name: 'C042', rating: 2 }, + { name: 'C043', rating: 2 }, + { name: 'C044', rating: 2 }, + { name: 'C045', rating: 2 }, + { name: 'C046', rating: 2 }, + { name: 'C047', rating: 2 }, + { name: 'C048', rating: 2 }, + { name: 'C049', rating: 2 }, + { name: 'C050', rating: 2 }, + { name: 'C051', rating: 2 }, + { name: 'C052', rating: 2 }, + { name: 'C053', rating: 2 }, + { name: 'C054', rating: 2 }, + { name: 'C055', rating: 2 }, + { name: 'C056', rating: 2 }, + { name: 'C057', rating: 2 }, + { name: 'C058', rating: 2 }, + { name: 'C059', rating: 2 }, + { name: 'C060', rating: 2 }, + { name: 'C061', rating: 2 }, + { name: 'C062', rating: 2 }, + { name: 'C063', rating: 2 }, + { name: 'C064', rating: 2 }, + { name: 'C065', rating: 2 }, + { name: 'C066', rating: 2 }, + { name: 'C067', rating: 2 }, + { name: 'C068', rating: 2 }, + { name: 'C069', rating: 2 }, + { name: 'C070', rating: 2 }, + { name: 'C071', rating: 2 }, + { name: 'C072', rating: 2 }, + { name: 'C073', rating: 2 }, + { name: 'C074', rating: 2 }, + { name: 'C075', rating: 2 }, + { name: 'C076', rating: 2 }, + { name: 'C077', rating: 2 }, + { name: 'C078', rating: 2 }, + { name: 'C079', rating: 2 }, + { name: 'C080', rating: 2 }, + { name: 'C081', rating: 2 }, + { name: 'C082', rating: 2 }, + { name: 'C083', rating: 2 }, + { name: 'C084', rating: 2 }, + { name: 'C085', rating: 2 }, + { name: 'C086', rating: 2 }, + { name: 'C087', rating: 2 }, + { name: 'C088', rating: 2 }, + { name: 'C089', rating: 2 }, + { name: 'C090', rating: 2 }, + { name: 'C091', rating: 2 }, + { name: 'C092', rating: 2 }, + { name: 'C093', rating: 2 }, + { name: 'C094', rating: 2 }, + { name: 'C095', rating: 2 }, + { name: 'C096', rating: 2 }, + { name: 'C097', rating: 2 }, + { name: 'C098', rating: 2 }, + { name: 'C099', rating: 2 }, + { name: 'C100', rating: 2 }, + { name: 'C101', rating: 2 }, + { name: 'C102', rating: 2 }, + { name: 'C103', rating: 2 }, + { name: 'C104', rating: 2 }, + { name: 'C105', rating: 2 }, + { name: 'C106', rating: 2 }, + { name: 'C107', rating: 2 }, + { name: 'C108', rating: 2 }, + { name: 'C109', rating: 2 }, + { name: 'C110', rating: 2 }, + { name: 'C111', rating: 2 }, + { name: 'C112', rating: 2 }, + { name: 'C113', rating: 2 }, + { name: 'C114', rating: 2 }, + { name: 'C115', rating: 2 }, + { name: 'C116', rating: 2 }, + { name: 'C117', rating: 2 }, + { name: 'C118', rating: 2 }, + { name: 'C119', rating: 2 }, + { name: 'C120', rating: 2 }, + { name: 'C121', rating: 2 }, + { name: 'C122', rating: 2 }, + { name: 'C123', rating: 2 }, + { name: 'C124', rating: 2 }, + { name: 'C125', rating: 2 }, + { name: 'C126', rating: 2 }, + { name: 'C127', rating: 2 }, + { name: 'C128', rating: 2 }, + { name: 'C129', rating: 2 }, + { name: 'C130', rating: 2 }, + { name: 'C131', rating: 2 }, + { name: 'C132', rating: 2 }, + { name: 'C133', rating: 2 }, + { name: 'C134', rating: 2 }, + { name: 'C135', rating: 2 }, + { name: 'C136', rating: 2 }, + { name: 'C137', rating: 2 }, + { name: 'C138', rating: 2 }, + { name: 'C139', rating: 2 }, + { name: 'C140', rating: 2 }, + { name: 'C141', rating: 2 }, + { name: 'C142', rating: 2 }, + { name: 'C143', rating: 2 }, + { name: 'C144', rating: 2 }, + { name: 'C145', rating: 2 }, + { name: 'C146', rating: 2 }, + { name: 'C147', rating: 2 }, + { name: 'C148', rating: 2 }, + { name: 'C149', rating: 2 }, + { name: 'C150', rating: 2 }, + { name: 'C151', rating: 2 }, + { name: 'C152', rating: 2 }, + { name: 'C153', rating: 2 }, + { name: 'C154', rating: 2 }, + { name: 'C155', rating: 2 }, + { name: 'C156', rating: 2 }, + { name: 'C157', rating: 2 }, + { name: 'C158', rating: 2 }, + { name: 'C159', rating: 2 }, + { name: 'C160', rating: 2 }, + { name: 'C161', rating: 2 }, + { name: 'C162', rating: 2 }, + { name: 'C163', rating: 2 }, + { name: 'C164', rating: 2 }, + { name: 'C165', rating: 2 }, + { name: 'C166', rating: 2 }, + { name: 'C167', rating: 2 }, + { name: 'C168', rating: 2 }, + { name: 'C169', rating: 2 }, + { name: 'C170', rating: 2 }, + { name: 'C171', rating: 2 }, + { name: 'C172', rating: 2 }, + { name: 'C173', rating: 2 }, + { name: 'C174', rating: 2 }, + { name: 'C175', rating: 2 }, + { name: 'C176', rating: 2 }, + { name: 'C177', rating: 2 }, + { name: 'C178', rating: 2 }, + { name: 'C179', rating: 2 }, + { name: 'C180', rating: 2 }, + { name: 'C181', rating: 2 }, + { name: 'C182', rating: 2 }, + { name: 'C183', rating: 2 }, + { name: 'C184', rating: 2 }, + { name: 'C185', rating: 2 }, + { name: 'C186', rating: 2 }, + { name: 'D000', rating: 4 }, + { name: 'D001', rating: 4 }, + { name: 'D002', rating: 4 }, + { name: 'D003', rating: 4 }, + { name: 'D004', rating: 4 }, + { name: 'D005', rating: 4 }, + { name: 'D006', rating: 4 }, + { name: 'D007', rating: 4 }, + { name: 'D008', rating: 4 }, + { name: 'D009', rating: 4 }, + { name: 'D010', rating: 4 }, + { name: 'D011', rating: 4 }, + { name: 'D012', rating: 4 }, + { name: 'D013', rating: 4 }, + { name: 'D014', rating: 4 }, + { name: 'D015', rating: 4 }, + { name: 'D016', rating: 4 }, + { name: 'D017', rating: 4 }, + { name: 'D018', rating: 4 }, + { name: 'D019', rating: 4 }, + { name: 'D020', rating: 4 }, + { name: 'D021', rating: 4 }, + { name: 'D022', rating: 4 }, + { name: 'D023', rating: 4 }, + { name: 'D024', rating: 4 }, + { name: 'D025', rating: 4 }, + { name: 'D026', rating: 4 }, + { name: 'D027', rating: 4 }, + { name: 'D028', rating: 4 }, + { name: 'D029', rating: 4 }, + { name: 'D030', rating: 4 }, + { name: 'D031', rating: 4 }, + { name: 'D032', rating: 4 }, + { name: 'D033', rating: 4 }, + { name: 'D034', rating: 4 }, + { name: 'D035', rating: 4 }, + { name: 'D036', rating: 4 }, + { name: 'D037', rating: 4 }, + { name: 'D038', rating: 4 }, + { name: 'D039', rating: 4 }, + { name: 'D040', rating: 4 }, + { name: 'D041', rating: 4 }, + { name: 'D042', rating: 4 }, + { name: 'D043', rating: 4 }, + { name: 'D044', rating: 4 }, + { name: 'D045', rating: 4 }, + { name: 'D046', rating: 4 }, + { name: 'D047', rating: 4 }, + { name: 'D048', rating: 4 }, + { name: 'D049', rating: 4 }, + { name: 'D050', rating: 4 }, + { name: 'D051', rating: 4 }, + { name: 'D052', rating: 4 }, + { name: 'D053', rating: 4 }, + { name: 'D054', rating: 4 }, + { name: 'D055', rating: 4 }, + { name: 'D056', rating: 4 }, + { name: 'D057', rating: 4 }, + { name: 'D058', rating: 4 }, + { name: 'D059', rating: 4 }, + { name: 'D060', rating: 4 }, + { name: 'D061', rating: 4 }, + { name: 'D062', rating: 4 }, + { name: 'D063', rating: 4 }, + { name: 'D064', rating: 4 }, + { name: 'D065', rating: 4 }, + { name: 'D066', rating: 4 }, + { name: 'D067', rating: 4 }, + { name: 'D068', rating: 4 }, + { name: 'D069', rating: 4 }, + { name: 'D070', rating: 4 }, + { name: 'D071', rating: 4 }, + { name: 'D072', rating: 4 }, + { name: 'D073', rating: 4 }, + { name: 'D074', rating: 4 }, + { name: 'D075', rating: 4 }, + { name: 'D076', rating: 4 }, + { name: 'D077', rating: 4 }, + { name: 'D078', rating: 4 }, + { name: 'D079', rating: 4 }, + { name: 'D080', rating: 4 }, + { name: 'D081', rating: 4 }, + { name: 'D082', rating: 4 }, + { name: 'D083', rating: 4 }, + { name: 'D084', rating: 4 }, + { name: 'D085', rating: 4 }, + { name: 'D086', rating: 4 }, + { name: 'D087', rating: 4 }, + { name: 'D088', rating: 4 }, + { name: 'D089', rating: 4 }, + { name: 'D090', rating: 4 }, + { name: 'D091', rating: 4 }, + { name: 'D092', rating: 4 }, + { name: 'D093', rating: 4 }, + { name: 'D094', rating: 4 }, + { name: 'D095', rating: 4 }, + { name: 'D096', rating: 4 }, + { name: 'D097', rating: 4 }, + { name: 'D098', rating: 4 }, + { name: 'D099', rating: 4 }, + { name: 'D100', rating: 4 }, + { name: 'D101', rating: 4 }, + { name: 'D102', rating: 4 }, + { name: 'D103', rating: 4 }, + { name: 'D104', rating: 4 }, + { name: 'D105', rating: 4 }, + { name: 'D106', rating: 4 }, + { name: 'D107', rating: 4 }, + { name: 'D108', rating: 4 }, + { name: 'D109', rating: 4 }, + { name: 'D110', rating: 4 }, + { name: 'D111', rating: 4 }, + { name: 'D112', rating: 4 }, + { name: 'D113', rating: 4 }, + { name: 'D114', rating: 4 }, + { name: 'D115', rating: 4 }, + { name: 'D116', rating: 4 }, + { name: 'D117', rating: 4 }, + { name: 'D118', rating: 4 }, + { name: 'D119', rating: 4 }, + { name: 'D120', rating: 4 }, + { name: 'D121', rating: 4 }, + { name: 'D122', rating: 4 }, + { name: 'D123', rating: 4 }, + { name: 'D124', rating: 4 }, + { name: 'D125', rating: 4 }, + { name: 'D126', rating: 4 }, + { name: 'D127', rating: 4 }, + { name: 'D128', rating: 4 }, + { name: 'D129', rating: 4 }, + { name: 'D130', rating: 4 }, + { name: 'D131', rating: 4 }, + { name: 'D132', rating: 4 }, + { name: 'D133', rating: 4 }, + { name: 'D134', rating: 4 }, + { name: 'D135', rating: 4 }, + { name: 'D136', rating: 4 }, + { name: 'D137', rating: 4 }, + { name: 'D138', rating: 4 }, + { name: 'D139', rating: 4 }, + { name: 'D140', rating: 4 }, + { name: 'D141', rating: 4 }, + { name: 'D142', rating: 4 }, + { name: 'D143', rating: 4 }, + { name: 'D144', rating: 4 }, + { name: 'D145', rating: 4 }, + { name: 'D146', rating: 4 }, + { name: 'D147', rating: 4 }, + { name: 'D148', rating: 4 }, + { name: 'D149', rating: 4 }, + { name: 'D150', rating: 4 }, + { name: 'D151', rating: 4 }, + { name: 'D152', rating: 4 }, + { name: 'D153', rating: 4 }, + { name: 'D154', rating: 4 }, + { name: 'D155', rating: 4 }, + { name: 'D156', rating: 4 }, + { name: 'D157', rating: 4 }, + { name: 'D158', rating: 4 }, + { name: 'D159', rating: 4 }, + { name: 'D160', rating: 4 }, + { name: 'D161', rating: 4 }, + { name: 'D162', rating: 4 }, + { name: 'D163', rating: 4 }, + { name: 'D164', rating: 4 }, + { name: 'D165', rating: 4 }, + { name: 'D166', rating: 4 }, + { name: 'D167', rating: 4 }, + { name: 'D168', rating: 4 }, + { name: 'D169', rating: 4 }, + { name: 'D170', rating: 4 }, + { name: 'D171', rating: 4 }, + { name: 'D172', rating: 4 }, + { name: 'D173', rating: 4 }, + { name: 'D174', rating: 4 }, + { name: 'D175', rating: 4 }, + { name: 'D176', rating: 4 }, + { name: 'D177', rating: 4 }, + { name: 'D178', rating: 4 }, + { name: 'D179', rating: 4 }, + { name: 'D180', rating: 4 }, + { name: 'D181', rating: 4 }, + { name: 'D182', rating: 4 }, + { name: 'D183', rating: 4 }, + { name: 'D184', rating: 4 }, + { name: 'D185', rating: 4 }, + { name: 'D186', rating: 4 }, + { name: 'E000', rating: 3 }, + { name: 'E001', rating: 3 }, + { name: 'E002', rating: 3 }, + { name: 'E003', rating: 3 }, + { name: 'E004', rating: 3 }, + { name: 'E005', rating: 3 }, + { name: 'E006', rating: 3 }, + { name: 'E007', rating: 3 }, + { name: 'E008', rating: 3 }, + { name: 'E009', rating: 3 }, + { name: 'E010', rating: 3 }, + { name: 'E011', rating: 3 }, + { name: 'E012', rating: 3 }, + { name: 'E013', rating: 3 }, + { name: 'E014', rating: 3 }, + { name: 'E015', rating: 3 }, + { name: 'E016', rating: 3 }, + { name: 'E017', rating: 3 }, + { name: 'E018', rating: 3 }, + { name: 'E019', rating: 3 }, + { name: 'E020', rating: 3 }, + { name: 'E021', rating: 3 }, + { name: 'E022', rating: 3 }, + { name: 'E023', rating: 3 }, + { name: 'E024', rating: 3 }, + { name: 'E025', rating: 3 }, + { name: 'E026', rating: 3 }, + { name: 'E027', rating: 3 }, + { name: 'E028', rating: 3 }, + { name: 'E029', rating: 3 }, + { name: 'E030', rating: 3 }, + { name: 'E031', rating: 3 }, + { name: 'E032', rating: 3 }, + { name: 'E033', rating: 3 }, + { name: 'E034', rating: 3 }, + { name: 'E035', rating: 3 }, + { name: 'E036', rating: 3 }, + { name: 'E037', rating: 3 }, + { name: 'E038', rating: 3 }, + { name: 'E039', rating: 3 }, + { name: 'E040', rating: 3 }, + { name: 'E041', rating: 3 }, + { name: 'E042', rating: 3 }, + { name: 'E043', rating: 3 }, + { name: 'E044', rating: 3 }, + { name: 'E045', rating: 3 }, + { name: 'E046', rating: 3 }, + { name: 'E047', rating: 3 }, + { name: 'E048', rating: 3 }, + { name: 'E049', rating: 3 }, + { name: 'E050', rating: 3 }, + { name: 'E051', rating: 3 }, + { name: 'E052', rating: 3 }, + { name: 'E053', rating: 3 }, + { name: 'E054', rating: 3 }, + { name: 'E055', rating: 3 }, + { name: 'E056', rating: 3 }, + { name: 'E057', rating: 3 }, + { name: 'E058', rating: 3 }, + { name: 'E059', rating: 3 }, + { name: 'E060', rating: 3 }, + { name: 'E061', rating: 3 }, + { name: 'E062', rating: 3 }, + { name: 'E063', rating: 3 }, + { name: 'E064', rating: 3 }, + { name: 'E065', rating: 3 }, + { name: 'E066', rating: 3 }, + { name: 'E067', rating: 3 }, + { name: 'E068', rating: 3 }, + { name: 'E069', rating: 3 }, + { name: 'E070', rating: 3 }, + { name: 'E071', rating: 3 }, + { name: 'E072', rating: 3 }, + { name: 'E073', rating: 3 }, + { name: 'E074', rating: 3 }, + { name: 'E075', rating: 3 }, + { name: 'E076', rating: 3 }, + { name: 'E077', rating: 3 }, + { name: 'E078', rating: 3 }, + { name: 'E079', rating: 3 }, + { name: 'E080', rating: 3 }, + { name: 'E081', rating: 3 }, + { name: 'E082', rating: 3 }, + { name: 'E083', rating: 3 }, + { name: 'E084', rating: 3 }, + { name: 'E085', rating: 3 }, + { name: 'E086', rating: 3 }, + { name: 'E087', rating: 3 }, + { name: 'E088', rating: 3 }, + { name: 'E089', rating: 3 }, + { name: 'E090', rating: 3 }, + { name: 'E091', rating: 3 }, + { name: 'E092', rating: 3 }, + { name: 'E093', rating: 3 }, + { name: 'E094', rating: 3 }, + { name: 'E095', rating: 3 }, + { name: 'E096', rating: 3 }, + { name: 'E097', rating: 3 }, + { name: 'E098', rating: 3 }, + { name: 'E099', rating: 3 }, + { name: 'E100', rating: 3 }, + { name: 'E101', rating: 3 }, + { name: 'E102', rating: 3 }, + { name: 'E103', rating: 3 }, + { name: 'E104', rating: 3 }, + { name: 'E105', rating: 3 }, + { name: 'E106', rating: 3 }, + { name: 'E107', rating: 3 }, + { name: 'E108', rating: 3 }, + { name: 'E109', rating: 3 }, + { name: 'E110', rating: 3 }, + { name: 'E111', rating: 3 }, + { name: 'E112', rating: 3 }, + { name: 'E113', rating: 3 }, + { name: 'E114', rating: 3 }, + { name: 'E115', rating: 3 }, + { name: 'E116', rating: 3 }, + { name: 'E117', rating: 3 }, + { name: 'E118', rating: 3 }, + { name: 'E119', rating: 3 }, + { name: 'E120', rating: 3 }, + { name: 'E121', rating: 3 }, + { name: 'E122', rating: 3 }, + { name: 'E123', rating: 3 }, + { name: 'E124', rating: 3 }, + { name: 'E125', rating: 3 }, + { name: 'E126', rating: 3 }, + { name: 'E127', rating: 3 }, + { name: 'E128', rating: 3 }, + { name: 'E129', rating: 3 }, + { name: 'E130', rating: 3 }, + { name: 'E131', rating: 3 }, + { name: 'E132', rating: 3 }, + { name: 'E133', rating: 3 }, + { name: 'E134', rating: 3 }, + { name: 'E135', rating: 3 }, + { name: 'E136', rating: 3 }, + { name: 'E137', rating: 3 }, + { name: 'E138', rating: 3 }, + { name: 'E139', rating: 3 }, + { name: 'E140', rating: 3 }, + { name: 'E141', rating: 3 }, + { name: 'E142', rating: 3 }, + { name: 'E143', rating: 3 }, + { name: 'E144', rating: 3 }, + { name: 'E145', rating: 3 }, + { name: 'E146', rating: 3 }, + { name: 'E147', rating: 3 }, + { name: 'E148', rating: 3 }, + { name: 'E149', rating: 3 }, + { name: 'E150', rating: 3 }, + { name: 'E151', rating: 3 }, + { name: 'E152', rating: 3 }, + { name: 'E153', rating: 3 }, + { name: 'E154', rating: 3 }, + { name: 'E155', rating: 3 }, + { name: 'E156', rating: 3 }, + { name: 'E157', rating: 3 }, + { name: 'E158', rating: 3 }, + { name: 'E159', rating: 3 }, + { name: 'E160', rating: 3 }, + { name: 'E161', rating: 3 }, + { name: 'E162', rating: 3 }, + { name: 'E163', rating: 3 }, + { name: 'E164', rating: 3 }, + { name: 'E165', rating: 3 }, + { name: 'E166', rating: 3 }, + { name: 'E167', rating: 3 }, + { name: 'E168', rating: 3 }, + { name: 'E169', rating: 3 }, + { name: 'E170', rating: 3 }, + { name: 'E171', rating: 3 }, + { name: 'E172', rating: 3 }, + { name: 'E173', rating: 3 }, + { name: 'E174', rating: 3 }, + { name: 'E175', rating: 3 }, + { name: 'E176', rating: 3 }, + { name: 'E177', rating: 3 }, + { name: 'E178', rating: 3 }, + { name: 'E179', rating: 3 }, + { name: 'E180', rating: 3 }, + { name: 'E181', rating: 3 }, + { name: 'E182', rating: 3 }, + { name: 'E183', rating: 3 }, + { name: 'E184', rating: 3 }, + { name: 'E185', rating: 3 }, + { name: 'E186', rating: 3 }, + { name: 'F000', rating: 3 }, + { name: 'F001', rating: 3 }, + { name: 'F002', rating: 3 }, + { name: 'F003', rating: 3 }, + { name: 'F004', rating: 3 }, + { name: 'F005', rating: 3 }, + { name: 'F006', rating: 3 }, + { name: 'F007', rating: 3 }, + { name: 'F008', rating: 3 }, + { name: 'F009', rating: 3 }, + { name: 'F010', rating: 3 }, + { name: 'F011', rating: 3 }, + { name: 'F012', rating: 3 }, + { name: 'F013', rating: 3 }, + { name: 'F014', rating: 3 }, + { name: 'F015', rating: 3 }, + { name: 'F016', rating: 3 }, + { name: 'F017', rating: 3 }, + { name: 'F018', rating: 3 }, + { name: 'F019', rating: 3 }, + { name: 'F020', rating: 3 }, + { name: 'F021', rating: 3 }, + { name: 'F022', rating: 3 }, + { name: 'F023', rating: 3 }, + { name: 'F024', rating: 3 }, + { name: 'F025', rating: 3 }, + { name: 'F026', rating: 3 }, + { name: 'F027', rating: 3 }, + { name: 'F028', rating: 3 }, + { name: 'F029', rating: 3 }, + { name: 'F030', rating: 3 }, + { name: 'F031', rating: 3 }, + { name: 'F032', rating: 3 }, + { name: 'F033', rating: 3 }, + { name: 'F034', rating: 3 }, + { name: 'F035', rating: 3 }, + { name: 'F036', rating: 3 }, + { name: 'F037', rating: 3 }, + { name: 'F038', rating: 3 }, + { name: 'F039', rating: 3 }, + { name: 'F040', rating: 3 }, + { name: 'F041', rating: 3 }, + { name: 'F042', rating: 3 }, + { name: 'F043', rating: 3 }, + { name: 'F044', rating: 3 }, + { name: 'F045', rating: 3 }, + { name: 'F046', rating: 3 }, + { name: 'F047', rating: 3 }, + { name: 'F048', rating: 3 }, + { name: 'F049', rating: 3 }, + { name: 'F050', rating: 3 }, + { name: 'F051', rating: 3 }, + { name: 'F052', rating: 3 }, + { name: 'F053', rating: 3 }, + { name: 'F054', rating: 3 }, + { name: 'F055', rating: 3 }, + { name: 'F056', rating: 3 }, + { name: 'F057', rating: 3 }, + { name: 'F058', rating: 3 }, + { name: 'F059', rating: 3 }, + { name: 'F060', rating: 3 }, + { name: 'F061', rating: 3 }, + { name: 'F062', rating: 3 }, + { name: 'F063', rating: 3 }, + { name: 'F064', rating: 3 }, + { name: 'F065', rating: 3 }, + { name: 'F066', rating: 3 }, + { name: 'F067', rating: 3 }, + { name: 'F068', rating: 3 }, + { name: 'F069', rating: 3 }, + { name: 'F070', rating: 3 }, + { name: 'F071', rating: 3 }, + { name: 'F072', rating: 3 }, + { name: 'F073', rating: 3 }, + { name: 'F074', rating: 3 }, + { name: 'F075', rating: 3 }, + { name: 'F076', rating: 3 }, + { name: 'F077', rating: 3 }, + { name: 'F078', rating: 3 }, + { name: 'F079', rating: 3 }, + { name: 'F080', rating: 3 }, + { name: 'F081', rating: 3 }, + { name: 'F082', rating: 3 }, + { name: 'F083', rating: 3 }, + { name: 'F084', rating: 3 }, + { name: 'F085', rating: 3 }, + { name: 'F086', rating: 3 }, + { name: 'F087', rating: 3 }, + { name: 'F088', rating: 3 }, + { name: 'F089', rating: 3 }, + { name: 'F090', rating: 3 }, + { name: 'F091', rating: 3 }, + { name: 'F092', rating: 3 }, + { name: 'F093', rating: 3 }, + { name: 'F094', rating: 3 }, + { name: 'F095', rating: 3 }, + { name: 'F096', rating: 3 }, + { name: 'F097', rating: 3 }, + { name: 'F098', rating: 3 }, + { name: 'F099', rating: 3 }, + { name: 'F100', rating: 3 }, + { name: 'F101', rating: 3 }, + { name: 'F102', rating: 3 }, + { name: 'F103', rating: 3 }, + { name: 'F104', rating: 3 }, + { name: 'F105', rating: 3 }, + { name: 'F106', rating: 3 }, + { name: 'F107', rating: 3 }, + { name: 'F108', rating: 3 }, + { name: 'F109', rating: 3 }, + { name: 'F110', rating: 3 }, + { name: 'F111', rating: 3 }, + { name: 'F112', rating: 3 }, + { name: 'F113', rating: 3 }, + { name: 'F114', rating: 3 }, + { name: 'F115', rating: 3 }, + { name: 'F116', rating: 3 }, + { name: 'F117', rating: 3 }, + { name: 'F118', rating: 3 }, + { name: 'F119', rating: 3 }, + { name: 'F120', rating: 3 }, + { name: 'F121', rating: 3 }, + { name: 'F122', rating: 3 }, + { name: 'F123', rating: 3 }, + { name: 'F124', rating: 3 }, + { name: 'F125', rating: 3 }, + { name: 'F126', rating: 3 }, + { name: 'F127', rating: 3 }, + { name: 'F128', rating: 3 }, + { name: 'F129', rating: 3 }, + { name: 'F130', rating: 3 }, + { name: 'F131', rating: 3 }, + { name: 'F132', rating: 3 }, + { name: 'F133', rating: 3 }, + { name: 'F134', rating: 3 }, + { name: 'F135', rating: 3 }, + { name: 'F136', rating: 3 }, + { name: 'F137', rating: 3 }, + { name: 'F138', rating: 3 }, + { name: 'F139', rating: 3 }, + { name: 'F140', rating: 3 }, + { name: 'F141', rating: 3 }, + { name: 'F142', rating: 3 }, + { name: 'F143', rating: 3 }, + { name: 'F144', rating: 3 }, + { name: 'F145', rating: 3 }, + { name: 'F146', rating: 3 }, + { name: 'F147', rating: 3 }, + { name: 'F148', rating: 3 }, + { name: 'F149', rating: 3 }, + { name: 'F150', rating: 3 }, + { name: 'F151', rating: 3 }, + { name: 'F152', rating: 3 }, + { name: 'F153', rating: 3 }, + { name: 'F154', rating: 3 }, + { name: 'F155', rating: 3 }, + { name: 'F156', rating: 3 }, + { name: 'F157', rating: 3 }, + { name: 'F158', rating: 3 }, + { name: 'F159', rating: 3 }, + { name: 'F160', rating: 3 }, + { name: 'F161', rating: 3 }, + { name: 'F162', rating: 3 }, + { name: 'F163', rating: 3 }, + { name: 'F164', rating: 3 }, + { name: 'F165', rating: 3 }, + { name: 'F166', rating: 3 }, + { name: 'F167', rating: 3 }, + { name: 'F168', rating: 3 }, + { name: 'F169', rating: 3 }, + { name: 'F170', rating: 3 }, + { name: 'F171', rating: 3 }, + { name: 'F172', rating: 3 }, + { name: 'F173', rating: 3 }, + { name: 'F174', rating: 3 }, + { name: 'F175', rating: 3 }, + { name: 'F176', rating: 3 }, + { name: 'F177', rating: 3 }, + { name: 'F178', rating: 3 }, + { name: 'F179', rating: 3 }, + { name: 'F180', rating: 3 }, + { name: 'F181', rating: 3 }, + { name: 'F182', rating: 3 }, + { name: 'F183', rating: 3 }, + { name: 'F184', rating: 3 }, + { name: 'F185', rating: 3 }, + { name: 'F186', rating: 3 }, + { name: 'G000', rating: 4 }, + { name: 'G001', rating: 4 }, + { name: 'G002', rating: 4 }, + { name: 'G003', rating: 4 }, + { name: 'G004', rating: 4 }, + { name: 'G005', rating: 4 }, + { name: 'G006', rating: 4 }, + { name: 'G007', rating: 4 }, + { name: 'G008', rating: 4 }, + { name: 'G009', rating: 4 }, + { name: 'G010', rating: 4 }, + { name: 'G011', rating: 4 }, + { name: 'G012', rating: 4 }, + { name: 'G013', rating: 4 }, + { name: 'G014', rating: 4 }, + { name: 'G015', rating: 4 }, + { name: 'G016', rating: 4 }, + { name: 'G017', rating: 4 }, + { name: 'G018', rating: 4 }, + { name: 'G019', rating: 4 }, + { name: 'G020', rating: 4 }, + { name: 'G021', rating: 4 }, + { name: 'G022', rating: 4 }, + { name: 'G023', rating: 4 }, + { name: 'G024', rating: 4 }, + { name: 'G025', rating: 4 }, + { name: 'G026', rating: 4 }, + { name: 'G027', rating: 4 }, + { name: 'G028', rating: 4 }, + { name: 'G029', rating: 4 }, + { name: 'G030', rating: 4 }, + { name: 'G031', rating: 4 }, + { name: 'G032', rating: 4 }, + { name: 'G033', rating: 4 }, + { name: 'G034', rating: 4 }, + { name: 'G035', rating: 4 }, + { name: 'G036', rating: 4 }, + { name: 'G037', rating: 4 }, + { name: 'G038', rating: 4 }, + { name: 'G039', rating: 4 }, + { name: 'G040', rating: 4 }, + { name: 'G041', rating: 4 }, + { name: 'G042', rating: 4 }, + { name: 'G043', rating: 4 }, + { name: 'G044', rating: 4 }, + { name: 'G045', rating: 4 }, + { name: 'G046', rating: 4 }, + { name: 'G047', rating: 4 }, + { name: 'G048', rating: 4 }, + { name: 'G049', rating: 4 }, + { name: 'G050', rating: 4 }, + { name: 'G051', rating: 4 }, + { name: 'G052', rating: 4 }, + { name: 'G053', rating: 4 }, + { name: 'G054', rating: 4 }, + { name: 'G055', rating: 4 }, + { name: 'G056', rating: 4 }, + { name: 'G057', rating: 4 }, + { name: 'G058', rating: 4 }, + { name: 'G059', rating: 4 }, + { name: 'G060', rating: 4 }, + { name: 'G061', rating: 4 }, + { name: 'G062', rating: 4 }, + { name: 'G063', rating: 4 }, + { name: 'G064', rating: 4 }, + { name: 'G065', rating: 4 }, + { name: 'G066', rating: 4 }, + { name: 'G067', rating: 4 }, + { name: 'G068', rating: 4 }, + { name: 'G069', rating: 4 }, + { name: 'G070', rating: 4 }, + { name: 'G071', rating: 4 }, + { name: 'G072', rating: 4 }, + { name: 'G073', rating: 4 }, + { name: 'G074', rating: 4 }, + { name: 'G075', rating: 4 }, + { name: 'G076', rating: 4 }, + { name: 'G077', rating: 4 }, + { name: 'G078', rating: 4 }, + { name: 'G079', rating: 4 }, + { name: 'G080', rating: 4 }, + { name: 'G081', rating: 4 }, + { name: 'G082', rating: 4 }, + { name: 'G083', rating: 4 }, + { name: 'G084', rating: 4 }, + { name: 'G085', rating: 4 }, + { name: 'G086', rating: 4 }, + { name: 'G087', rating: 4 }, + { name: 'G088', rating: 4 }, + { name: 'G089', rating: 4 }, + { name: 'G090', rating: 4 }, + { name: 'G091', rating: 4 }, + { name: 'G092', rating: 4 }, + { name: 'G093', rating: 4 }, + { name: 'G094', rating: 4 }, + { name: 'G095', rating: 4 }, + { name: 'G096', rating: 4 }, + { name: 'G097', rating: 4 }, + { name: 'G098', rating: 4 }, + { name: 'G099', rating: 4 }, + { name: 'G100', rating: 4 }, + { name: 'G101', rating: 4 }, + { name: 'G102', rating: 4 }, + { name: 'G103', rating: 4 }, + { name: 'G104', rating: 4 }, + { name: 'G105', rating: 4 }, + { name: 'G106', rating: 4 }, + { name: 'G107', rating: 4 }, + { name: 'G108', rating: 4 }, + { name: 'G109', rating: 4 }, + { name: 'G110', rating: 4 }, + { name: 'G111', rating: 4 }, + { name: 'G112', rating: 4 }, + { name: 'G113', rating: 4 }, + { name: 'G114', rating: 4 }, + { name: 'G115', rating: 4 }, + { name: 'G116', rating: 4 }, + { name: 'G117', rating: 4 }, + { name: 'G118', rating: 4 }, + { name: 'G119', rating: 4 }, + { name: 'G120', rating: 4 }, + { name: 'G121', rating: 4 }, + { name: 'G122', rating: 4 }, + { name: 'G123', rating: 4 }, + { name: 'G124', rating: 4 }, + { name: 'G125', rating: 4 }, + { name: 'G126', rating: 4 }, + { name: 'G127', rating: 4 }, + { name: 'G128', rating: 4 }, + { name: 'G129', rating: 4 }, + { name: 'G130', rating: 4 }, + { name: 'G131', rating: 4 }, + { name: 'G132', rating: 4 }, + { name: 'G133', rating: 4 }, + { name: 'G134', rating: 4 }, + { name: 'G135', rating: 4 }, + { name: 'G136', rating: 4 }, + { name: 'G137', rating: 4 }, + { name: 'G138', rating: 4 }, + { name: 'G139', rating: 4 }, + { name: 'G140', rating: 4 }, + { name: 'G141', rating: 4 }, + { name: 'G142', rating: 4 }, + { name: 'G143', rating: 4 }, + { name: 'G144', rating: 4 }, + { name: 'G145', rating: 4 }, + { name: 'G146', rating: 4 }, + { name: 'G147', rating: 4 }, + { name: 'G148', rating: 4 }, + { name: 'G149', rating: 4 }, + { name: 'G150', rating: 4 }, + { name: 'G151', rating: 4 }, + { name: 'G152', rating: 4 }, + { name: 'G153', rating: 4 }, + { name: 'G154', rating: 4 }, + { name: 'G155', rating: 4 }, + { name: 'G156', rating: 4 }, + { name: 'G157', rating: 4 }, + { name: 'G158', rating: 4 }, + { name: 'G159', rating: 4 }, + { name: 'G160', rating: 4 }, + { name: 'G161', rating: 4 }, + { name: 'G162', rating: 4 }, + { name: 'G163', rating: 4 }, + { name: 'G164', rating: 4 }, + { name: 'G165', rating: 4 }, + { name: 'G166', rating: 4 }, + { name: 'G167', rating: 4 }, + { name: 'G168', rating: 4 }, + { name: 'G169', rating: 4 }, + { name: 'G170', rating: 4 }, + { name: 'G171', rating: 4 }, + { name: 'G172', rating: 4 }, + { name: 'G173', rating: 4 }, + { name: 'G174', rating: 4 }, + { name: 'G175', rating: 4 }, + { name: 'G176', rating: 4 }, + { name: 'G177', rating: 4 }, + { name: 'G178', rating: 4 }, + { name: 'G179', rating: 4 }, + { name: 'G180', rating: 4 }, + { name: 'G181', rating: 4 }, + { name: 'G182', rating: 4 }, + { name: 'G183', rating: 4 }, + { name: 'G184', rating: 4 }, + { name: 'G185', rating: 4 }, + { name: 'G186', rating: 4 }, + { name: 'H000', rating: 3 }, + { name: 'H001', rating: 3 }, + { name: 'H002', rating: 3 }, + { name: 'H003', rating: 3 }, + { name: 'H004', rating: 3 }, + { name: 'H005', rating: 3 }, + { name: 'H006', rating: 3 }, + { name: 'H007', rating: 3 }, + { name: 'H008', rating: 3 }, + { name: 'H009', rating: 3 }, + { name: 'H010', rating: 3 }, + { name: 'H011', rating: 3 }, + { name: 'H012', rating: 3 }, + { name: 'H013', rating: 3 }, + { name: 'H014', rating: 3 }, + { name: 'H015', rating: 3 }, + { name: 'H016', rating: 3 }, + { name: 'H017', rating: 3 }, + { name: 'H018', rating: 3 }, + { name: 'H019', rating: 3 }, + { name: 'H020', rating: 3 }, + { name: 'H021', rating: 3 }, + { name: 'H022', rating: 3 }, + { name: 'H023', rating: 3 }, + { name: 'H024', rating: 3 }, + { name: 'H025', rating: 3 }, + { name: 'H026', rating: 3 }, + { name: 'H027', rating: 3 }, + { name: 'H028', rating: 3 }, + { name: 'H029', rating: 3 }, + { name: 'H030', rating: 3 }, + { name: 'H031', rating: 3 }, + { name: 'H032', rating: 3 }, + { name: 'H033', rating: 3 }, + { name: 'H034', rating: 3 }, + { name: 'H035', rating: 3 }, + { name: 'H036', rating: 3 }, + { name: 'H037', rating: 3 }, + { name: 'H038', rating: 3 }, + { name: 'H039', rating: 3 }, + { name: 'H040', rating: 3 }, + { name: 'H041', rating: 3 }, + { name: 'H042', rating: 3 }, + { name: 'H043', rating: 3 }, + { name: 'H044', rating: 3 }, + { name: 'H045', rating: 3 }, + { name: 'H046', rating: 3 }, + { name: 'H047', rating: 3 }, + { name: 'H048', rating: 3 }, + { name: 'H049', rating: 3 }, + { name: 'H050', rating: 3 }, + { name: 'H051', rating: 3 }, + { name: 'H052', rating: 3 }, + { name: 'H053', rating: 3 }, + { name: 'H054', rating: 3 }, + { name: 'H055', rating: 3 }, + { name: 'H056', rating: 3 }, + { name: 'H057', rating: 3 }, + { name: 'H058', rating: 3 }, + { name: 'H059', rating: 3 }, + { name: 'H060', rating: 3 }, + { name: 'H061', rating: 3 }, + { name: 'H062', rating: 3 }, + { name: 'H063', rating: 3 }, + { name: 'H064', rating: 3 }, + { name: 'H065', rating: 3 }, + { name: 'H066', rating: 3 }, + { name: 'H067', rating: 3 }, + { name: 'H068', rating: 3 }, + { name: 'H069', rating: 3 }, + { name: 'H070', rating: 3 }, + { name: 'H071', rating: 3 }, + { name: 'H072', rating: 3 }, + { name: 'H073', rating: 3 }, + { name: 'H074', rating: 3 }, + { name: 'H075', rating: 3 }, + { name: 'H076', rating: 3 }, + { name: 'H077', rating: 3 }, + { name: 'H078', rating: 3 }, + { name: 'H079', rating: 3 }, + { name: 'H080', rating: 3 }, + { name: 'H081', rating: 3 }, + { name: 'H082', rating: 3 }, + { name: 'H083', rating: 3 }, + { name: 'H084', rating: 3 }, + { name: 'H085', rating: 3 }, + { name: 'H086', rating: 3 }, + { name: 'H087', rating: 3 }, + { name: 'H088', rating: 3 }, + { name: 'H089', rating: 3 }, + { name: 'H090', rating: 3 }, + { name: 'H091', rating: 3 }, + { name: 'H092', rating: 3 }, + { name: 'H093', rating: 3 }, + { name: 'H094', rating: 3 }, + { name: 'H095', rating: 3 }, + { name: 'H096', rating: 3 }, + { name: 'H097', rating: 3 }, + { name: 'H098', rating: 3 }, + { name: 'H099', rating: 3 }, + { name: 'H100', rating: 3 }, + { name: 'H101', rating: 3 }, + { name: 'H102', rating: 3 }, + { name: 'H103', rating: 3 }, + { name: 'H104', rating: 3 }, + { name: 'H105', rating: 3 }, + { name: 'H106', rating: 3 }, + { name: 'H107', rating: 3 }, + { name: 'H108', rating: 3 }, + { name: 'H109', rating: 3 }, + { name: 'H110', rating: 3 }, + { name: 'H111', rating: 3 }, + { name: 'H112', rating: 3 }, + { name: 'H113', rating: 3 }, + { name: 'H114', rating: 3 }, + { name: 'H115', rating: 3 }, + { name: 'H116', rating: 3 }, + { name: 'H117', rating: 3 }, + { name: 'H118', rating: 3 }, + { name: 'H119', rating: 3 }, + { name: 'H120', rating: 3 }, + { name: 'H121', rating: 3 }, + { name: 'H122', rating: 3 }, + { name: 'H123', rating: 3 }, + { name: 'H124', rating: 3 }, + { name: 'H125', rating: 3 }, + { name: 'H126', rating: 3 }, + { name: 'H127', rating: 3 }, + { name: 'H128', rating: 3 }, + { name: 'H129', rating: 3 }, + { name: 'H130', rating: 3 }, + { name: 'H131', rating: 3 }, + { name: 'H132', rating: 3 }, + { name: 'H133', rating: 3 }, + { name: 'H134', rating: 3 }, + { name: 'H135', rating: 3 }, + { name: 'H136', rating: 3 }, + { name: 'H137', rating: 3 }, + { name: 'H138', rating: 3 }, + { name: 'H139', rating: 3 }, + { name: 'H140', rating: 3 }, + { name: 'H141', rating: 3 }, + { name: 'H142', rating: 3 }, + { name: 'H143', rating: 3 }, + { name: 'H144', rating: 3 }, + { name: 'H145', rating: 3 }, + { name: 'H146', rating: 3 }, + { name: 'H147', rating: 3 }, + { name: 'H148', rating: 3 }, + { name: 'H149', rating: 3 }, + { name: 'H150', rating: 3 }, + { name: 'H151', rating: 3 }, + { name: 'H152', rating: 3 }, + { name: 'H153', rating: 3 }, + { name: 'H154', rating: 3 }, + { name: 'H155', rating: 3 }, + { name: 'H156', rating: 3 }, + { name: 'H157', rating: 3 }, + { name: 'H158', rating: 3 }, + { name: 'H159', rating: 3 }, + { name: 'H160', rating: 3 }, + { name: 'H161', rating: 3 }, + { name: 'H162', rating: 3 }, + { name: 'H163', rating: 3 }, + { name: 'H164', rating: 3 }, + { name: 'H165', rating: 3 }, + { name: 'H166', rating: 3 }, + { name: 'H167', rating: 3 }, + { name: 'H168', rating: 3 }, + { name: 'H169', rating: 3 }, + { name: 'H170', rating: 3 }, + { name: 'H171', rating: 3 }, + { name: 'H172', rating: 3 }, + { name: 'H173', rating: 3 }, + { name: 'H174', rating: 3 }, + { name: 'H175', rating: 3 }, + { name: 'H176', rating: 3 }, + { name: 'H177', rating: 3 }, + { name: 'H178', rating: 3 }, + { name: 'H179', rating: 3 }, + { name: 'H180', rating: 3 }, + { name: 'H181', rating: 3 }, + { name: 'H182', rating: 3 }, + { name: 'H183', rating: 3 }, + { name: 'H184', rating: 3 }, + { name: 'H185', rating: 3 }, + { name: 'H186', rating: 3 }, + { name: 'I000', rating: 2 }, + { name: 'I001', rating: 2 }, + { name: 'I002', rating: 2 }, + { name: 'I003', rating: 2 }, + { name: 'I004', rating: 2 }, + { name: 'I005', rating: 2 }, + { name: 'I006', rating: 2 }, + { name: 'I007', rating: 2 }, + { name: 'I008', rating: 2 }, + { name: 'I009', rating: 2 }, + { name: 'I010', rating: 2 }, + { name: 'I011', rating: 2 }, + { name: 'I012', rating: 2 }, + { name: 'I013', rating: 2 }, + { name: 'I014', rating: 2 }, + { name: 'I015', rating: 2 }, + { name: 'I016', rating: 2 }, + { name: 'I017', rating: 2 }, + { name: 'I018', rating: 2 }, + { name: 'I019', rating: 2 }, + { name: 'I020', rating: 2 }, + { name: 'I021', rating: 2 }, + { name: 'I022', rating: 2 }, + { name: 'I023', rating: 2 }, + { name: 'I024', rating: 2 }, + { name: 'I025', rating: 2 }, + { name: 'I026', rating: 2 }, + { name: 'I027', rating: 2 }, + { name: 'I028', rating: 2 }, + { name: 'I029', rating: 2 }, + { name: 'I030', rating: 2 }, + { name: 'I031', rating: 2 }, + { name: 'I032', rating: 2 }, + { name: 'I033', rating: 2 }, + { name: 'I034', rating: 2 }, + { name: 'I035', rating: 2 }, + { name: 'I036', rating: 2 }, + { name: 'I037', rating: 2 }, + { name: 'I038', rating: 2 }, + { name: 'I039', rating: 2 }, + { name: 'I040', rating: 2 }, + { name: 'I041', rating: 2 }, + { name: 'I042', rating: 2 }, + { name: 'I043', rating: 2 }, + { name: 'I044', rating: 2 }, + { name: 'I045', rating: 2 }, + { name: 'I046', rating: 2 }, + { name: 'I047', rating: 2 }, + { name: 'I048', rating: 2 }, + { name: 'I049', rating: 2 }, + { name: 'I050', rating: 2 }, + { name: 'I051', rating: 2 }, + { name: 'I052', rating: 2 }, + { name: 'I053', rating: 2 }, + { name: 'I054', rating: 2 }, + { name: 'I055', rating: 2 }, + { name: 'I056', rating: 2 }, + { name: 'I057', rating: 2 }, + { name: 'I058', rating: 2 }, + { name: 'I059', rating: 2 }, + { name: 'I060', rating: 2 }, + { name: 'I061', rating: 2 }, + { name: 'I062', rating: 2 }, + { name: 'I063', rating: 2 }, + { name: 'I064', rating: 2 }, + { name: 'I065', rating: 2 }, + { name: 'I066', rating: 2 }, + { name: 'I067', rating: 2 }, + { name: 'I068', rating: 2 }, + { name: 'I069', rating: 2 }, + { name: 'I070', rating: 2 }, + { name: 'I071', rating: 2 }, + { name: 'I072', rating: 2 }, + { name: 'I073', rating: 2 }, + { name: 'I074', rating: 2 }, + { name: 'I075', rating: 2 }, + { name: 'I076', rating: 2 }, + { name: 'I077', rating: 2 }, + { name: 'I078', rating: 2 }, + { name: 'I079', rating: 2 }, + { name: 'I080', rating: 2 }, + { name: 'I081', rating: 2 }, + { name: 'I082', rating: 2 }, + { name: 'I083', rating: 2 }, + { name: 'I084', rating: 2 }, + { name: 'I085', rating: 2 }, + { name: 'I086', rating: 2 }, + { name: 'I087', rating: 2 }, + { name: 'I088', rating: 2 }, + { name: 'I089', rating: 2 }, + { name: 'I090', rating: 2 }, + { name: 'I091', rating: 2 }, + { name: 'I092', rating: 2 }, + { name: 'I093', rating: 2 }, + { name: 'I094', rating: 2 }, + { name: 'I095', rating: 2 }, + { name: 'I096', rating: 2 }, + { name: 'I097', rating: 2 }, + { name: 'I098', rating: 2 }, + { name: 'I099', rating: 2 }, + { name: 'I100', rating: 2 }, + { name: 'I101', rating: 2 }, + { name: 'I102', rating: 2 }, + { name: 'I103', rating: 2 }, + { name: 'I104', rating: 2 }, + { name: 'I105', rating: 2 }, + { name: 'I106', rating: 2 }, + { name: 'I107', rating: 2 }, + { name: 'I108', rating: 2 }, + { name: 'I109', rating: 2 }, + { name: 'I110', rating: 2 }, + { name: 'I111', rating: 2 }, + { name: 'I112', rating: 2 }, + { name: 'I113', rating: 2 }, + { name: 'I114', rating: 2 }, + { name: 'I115', rating: 2 }, + { name: 'I116', rating: 2 }, + { name: 'I117', rating: 2 }, + { name: 'I118', rating: 2 }, + { name: 'I119', rating: 2 }, + { name: 'I120', rating: 2 }, + { name: 'I121', rating: 2 }, + { name: 'I122', rating: 2 }, + { name: 'I123', rating: 2 }, + { name: 'I124', rating: 2 }, + { name: 'I125', rating: 2 }, + { name: 'I126', rating: 2 }, + { name: 'I127', rating: 2 }, + { name: 'I128', rating: 2 }, + { name: 'I129', rating: 2 }, + { name: 'I130', rating: 2 }, + { name: 'I131', rating: 2 }, + { name: 'I132', rating: 2 }, + { name: 'I133', rating: 2 }, + { name: 'I134', rating: 2 }, + { name: 'I135', rating: 2 }, + { name: 'I136', rating: 2 }, + { name: 'I137', rating: 2 }, + { name: 'I138', rating: 2 }, + { name: 'I139', rating: 2 }, + { name: 'I140', rating: 2 }, + { name: 'I141', rating: 2 }, + { name: 'I142', rating: 2 }, + { name: 'I143', rating: 2 }, + { name: 'I144', rating: 2 }, + { name: 'I145', rating: 2 }, + { name: 'I146', rating: 2 }, + { name: 'I147', rating: 2 }, + { name: 'I148', rating: 2 }, + { name: 'I149', rating: 2 }, + { name: 'I150', rating: 2 }, + { name: 'I151', rating: 2 }, + { name: 'I152', rating: 2 }, + { name: 'I153', rating: 2 }, + { name: 'I154', rating: 2 }, + { name: 'I155', rating: 2 }, + { name: 'I156', rating: 2 }, + { name: 'I157', rating: 2 }, + { name: 'I158', rating: 2 }, + { name: 'I159', rating: 2 }, + { name: 'I160', rating: 2 }, + { name: 'I161', rating: 2 }, + { name: 'I162', rating: 2 }, + { name: 'I163', rating: 2 }, + { name: 'I164', rating: 2 }, + { name: 'I165', rating: 2 }, + { name: 'I166', rating: 2 }, + { name: 'I167', rating: 2 }, + { name: 'I168', rating: 2 }, + { name: 'I169', rating: 2 }, + { name: 'I170', rating: 2 }, + { name: 'I171', rating: 2 }, + { name: 'I172', rating: 2 }, + { name: 'I173', rating: 2 }, + { name: 'I174', rating: 2 }, + { name: 'I175', rating: 2 }, + { name: 'I176', rating: 2 }, + { name: 'I177', rating: 2 }, + { name: 'I178', rating: 2 }, + { name: 'I179', rating: 2 }, + { name: 'I180', rating: 2 }, + { name: 'I181', rating: 2 }, + { name: 'I182', rating: 2 }, + { name: 'I183', rating: 2 }, + { name: 'I184', rating: 2 }, + { name: 'I185', rating: 2 }, + { name: 'I186', rating: 2 }, + { name: 'J000', rating: 2 }, + { name: 'J001', rating: 2 }, + { name: 'J002', rating: 2 }, + { name: 'J003', rating: 2 }, + { name: 'J004', rating: 2 }, + { name: 'J005', rating: 2 }, + { name: 'J006', rating: 2 }, + { name: 'J007', rating: 2 }, + { name: 'J008', rating: 2 }, + { name: 'J009', rating: 2 }, + { name: 'J010', rating: 2 }, + { name: 'J011', rating: 2 }, + { name: 'J012', rating: 2 }, + { name: 'J013', rating: 2 }, + { name: 'J014', rating: 2 }, + { name: 'J015', rating: 2 }, + { name: 'J016', rating: 2 }, + { name: 'J017', rating: 2 }, + { name: 'J018', rating: 2 }, + { name: 'J019', rating: 2 }, + { name: 'J020', rating: 2 }, + { name: 'J021', rating: 2 }, + { name: 'J022', rating: 2 }, + { name: 'J023', rating: 2 }, + { name: 'J024', rating: 2 }, + { name: 'J025', rating: 2 }, + { name: 'J026', rating: 2 }, + { name: 'J027', rating: 2 }, + { name: 'J028', rating: 2 }, + { name: 'J029', rating: 2 }, + { name: 'J030', rating: 2 }, + { name: 'J031', rating: 2 }, + { name: 'J032', rating: 2 }, + { name: 'J033', rating: 2 }, + { name: 'J034', rating: 2 }, + { name: 'J035', rating: 2 }, + { name: 'J036', rating: 2 }, + { name: 'J037', rating: 2 }, + { name: 'J038', rating: 2 }, + { name: 'J039', rating: 2 }, + { name: 'J040', rating: 2 }, + { name: 'J041', rating: 2 }, + { name: 'J042', rating: 2 }, + { name: 'J043', rating: 2 }, + { name: 'J044', rating: 2 }, + { name: 'J045', rating: 2 }, + { name: 'J046', rating: 2 }, + { name: 'J047', rating: 2 }, + { name: 'J048', rating: 2 }, + { name: 'J049', rating: 2 }, + { name: 'J050', rating: 2 }, + { name: 'J051', rating: 2 }, + { name: 'J052', rating: 2 }, + { name: 'J053', rating: 2 }, + { name: 'J054', rating: 2 }, + { name: 'J055', rating: 2 }, + { name: 'J056', rating: 2 }, + { name: 'J057', rating: 2 }, + { name: 'J058', rating: 2 }, + { name: 'J059', rating: 2 }, + { name: 'J060', rating: 2 }, + { name: 'J061', rating: 2 }, + { name: 'J062', rating: 2 }, + { name: 'J063', rating: 2 }, + { name: 'J064', rating: 2 }, + { name: 'J065', rating: 2 }, + { name: 'J066', rating: 2 }, + { name: 'J067', rating: 2 }, + { name: 'J068', rating: 2 }, + { name: 'J069', rating: 2 }, + { name: 'J070', rating: 2 }, + { name: 'J071', rating: 2 }, + { name: 'J072', rating: 2 }, + { name: 'J073', rating: 2 }, + { name: 'J074', rating: 2 }, + { name: 'J075', rating: 2 }, + { name: 'J076', rating: 2 }, + { name: 'J077', rating: 2 }, + { name: 'J078', rating: 2 }, + { name: 'J079', rating: 2 }, + { name: 'J080', rating: 2 }, + { name: 'J081', rating: 2 }, + { name: 'J082', rating: 2 }, + { name: 'J083', rating: 2 }, + { name: 'J084', rating: 2 }, + { name: 'J085', rating: 2 }, + { name: 'J086', rating: 2 }, + { name: 'J087', rating: 2 }, + { name: 'J088', rating: 2 }, + { name: 'J089', rating: 2 }, + { name: 'J090', rating: 2 }, + { name: 'J091', rating: 2 }, + { name: 'J092', rating: 2 }, + { name: 'J093', rating: 2 }, + { name: 'J094', rating: 2 }, + { name: 'J095', rating: 2 }, + { name: 'J096', rating: 2 }, + { name: 'J097', rating: 2 }, + { name: 'J098', rating: 2 }, + { name: 'J099', rating: 2 }, + { name: 'J100', rating: 2 }, + { name: 'J101', rating: 2 }, + { name: 'J102', rating: 2 }, + { name: 'J103', rating: 2 }, + { name: 'J104', rating: 2 }, + { name: 'J105', rating: 2 }, + { name: 'J106', rating: 2 }, + { name: 'J107', rating: 2 }, + { name: 'J108', rating: 2 }, + { name: 'J109', rating: 2 }, + { name: 'J110', rating: 2 }, + { name: 'J111', rating: 2 }, + { name: 'J112', rating: 2 }, + { name: 'J113', rating: 2 }, + { name: 'J114', rating: 2 }, + { name: 'J115', rating: 2 }, + { name: 'J116', rating: 2 }, + { name: 'J117', rating: 2 }, + { name: 'J118', rating: 2 }, + { name: 'J119', rating: 2 }, + { name: 'J120', rating: 2 }, + { name: 'J121', rating: 2 }, + { name: 'J122', rating: 2 }, + { name: 'J123', rating: 2 }, + { name: 'J124', rating: 2 }, + { name: 'J125', rating: 2 }, + { name: 'J126', rating: 2 }, + { name: 'J127', rating: 2 }, + { name: 'J128', rating: 2 }, + { name: 'J129', rating: 2 }, + { name: 'J130', rating: 2 }, + { name: 'J131', rating: 2 }, + { name: 'J132', rating: 2 }, + { name: 'J133', rating: 2 }, + { name: 'J134', rating: 2 }, + { name: 'J135', rating: 2 }, + { name: 'J136', rating: 2 }, + { name: 'J137', rating: 2 }, + { name: 'J138', rating: 2 }, + { name: 'J139', rating: 2 }, + { name: 'J140', rating: 2 }, + { name: 'J141', rating: 2 }, + { name: 'J142', rating: 2 }, + { name: 'J143', rating: 2 }, + { name: 'J144', rating: 2 }, + { name: 'J145', rating: 2 }, + { name: 'J146', rating: 2 }, + { name: 'J147', rating: 2 }, + { name: 'J148', rating: 2 }, + { name: 'J149', rating: 2 }, + { name: 'J150', rating: 2 }, + { name: 'J151', rating: 2 }, + { name: 'J152', rating: 2 }, + { name: 'J153', rating: 2 }, + { name: 'J154', rating: 2 }, + { name: 'J155', rating: 2 }, + { name: 'J156', rating: 2 }, + { name: 'J157', rating: 2 }, + { name: 'J158', rating: 2 }, + { name: 'J159', rating: 2 }, + { name: 'J160', rating: 2 }, + { name: 'J161', rating: 2 }, + { name: 'J162', rating: 2 }, + { name: 'J163', rating: 2 }, + { name: 'J164', rating: 2 }, + { name: 'J165', rating: 2 }, + { name: 'J166', rating: 2 }, + { name: 'J167', rating: 2 }, + { name: 'J168', rating: 2 }, + { name: 'J169', rating: 2 }, + { name: 'J170', rating: 2 }, + { name: 'J171', rating: 2 }, + { name: 'J172', rating: 2 }, + { name: 'J173', rating: 2 }, + { name: 'J174', rating: 2 }, + { name: 'J175', rating: 2 }, + { name: 'J176', rating: 2 }, + { name: 'J177', rating: 2 }, + { name: 'J178', rating: 2 }, + { name: 'J179', rating: 2 }, + { name: 'J180', rating: 2 }, + { name: 'J181', rating: 2 }, + { name: 'J182', rating: 2 }, + { name: 'J183', rating: 2 }, + { name: 'J184', rating: 2 }, + { name: 'J185', rating: 2 }, + { name: 'J186', rating: 2 }, + { name: 'K000', rating: 2 }, + { name: 'K001', rating: 2 }, + { name: 'K002', rating: 2 }, + { name: 'K003', rating: 2 }, + { name: 'K004', rating: 2 }, + { name: 'K005', rating: 2 }, + { name: 'K006', rating: 2 }, + { name: 'K007', rating: 2 }, + { name: 'K008', rating: 2 }, + { name: 'K009', rating: 2 }, + { name: 'K010', rating: 2 }, + { name: 'K011', rating: 2 }, + { name: 'K012', rating: 2 }, + { name: 'K013', rating: 2 }, + { name: 'K014', rating: 2 }, + { name: 'K015', rating: 2 }, + { name: 'K016', rating: 2 }, + { name: 'K017', rating: 2 }, + { name: 'K018', rating: 2 }, + { name: 'K019', rating: 2 }, + { name: 'K020', rating: 2 }, + { name: 'K021', rating: 2 }, + { name: 'K022', rating: 2 }, + { name: 'K023', rating: 2 }, + { name: 'K024', rating: 2 }, + { name: 'K025', rating: 2 }, + { name: 'K026', rating: 2 }, + { name: 'K027', rating: 2 }, + { name: 'K028', rating: 2 }, + { name: 'K029', rating: 2 }, + { name: 'K030', rating: 2 }, + { name: 'K031', rating: 2 }, + { name: 'K032', rating: 2 }, + { name: 'K033', rating: 2 }, + { name: 'K034', rating: 2 }, + { name: 'K035', rating: 2 }, + { name: 'K036', rating: 2 }, + { name: 'K037', rating: 2 }, + { name: 'K038', rating: 2 }, + { name: 'K039', rating: 2 }, + { name: 'K040', rating: 2 }, + { name: 'K041', rating: 2 }, + { name: 'K042', rating: 2 }, + { name: 'K043', rating: 2 }, + { name: 'K044', rating: 2 }, + { name: 'K045', rating: 2 }, + { name: 'K046', rating: 2 }, + { name: 'K047', rating: 2 }, + { name: 'K048', rating: 2 }, + { name: 'K049', rating: 2 }, + { name: 'K050', rating: 2 }, + { name: 'K051', rating: 2 }, + { name: 'K052', rating: 2 }, + { name: 'K053', rating: 2 }, + { name: 'K054', rating: 2 }, + { name: 'K055', rating: 2 }, + { name: 'K056', rating: 2 }, + { name: 'K057', rating: 2 }, + { name: 'K058', rating: 2 }, + { name: 'K059', rating: 2 }, + { name: 'K060', rating: 2 }, + { name: 'K061', rating: 2 }, + { name: 'K062', rating: 2 }, + { name: 'K063', rating: 2 }, + { name: 'K064', rating: 2 }, + { name: 'K065', rating: 2 }, + { name: 'K066', rating: 2 }, + { name: 'K067', rating: 2 }, + { name: 'K068', rating: 2 }, + { name: 'K069', rating: 2 }, + { name: 'K070', rating: 2 }, + { name: 'K071', rating: 2 }, + { name: 'K072', rating: 2 }, + { name: 'K073', rating: 2 }, + { name: 'K074', rating: 2 }, + { name: 'K075', rating: 2 }, + { name: 'K076', rating: 2 }, + { name: 'K077', rating: 2 }, + { name: 'K078', rating: 2 }, + { name: 'K079', rating: 2 }, + { name: 'K080', rating: 2 }, + { name: 'K081', rating: 2 }, + { name: 'K082', rating: 2 }, + { name: 'K083', rating: 2 }, + { name: 'K084', rating: 2 }, + { name: 'K085', rating: 2 }, + { name: 'K086', rating: 2 }, + { name: 'K087', rating: 2 }, + { name: 'K088', rating: 2 }, + { name: 'K089', rating: 2 }, + { name: 'K090', rating: 2 }, + { name: 'K091', rating: 2 }, + { name: 'K092', rating: 2 }, + { name: 'K093', rating: 2 }, + { name: 'K094', rating: 2 }, + { name: 'K095', rating: 2 }, + { name: 'K096', rating: 2 }, + { name: 'K097', rating: 2 }, + { name: 'K098', rating: 2 }, + { name: 'K099', rating: 2 }, + { name: 'K100', rating: 2 }, + { name: 'K101', rating: 2 }, + { name: 'K102', rating: 2 }, + { name: 'K103', rating: 2 }, + { name: 'K104', rating: 2 }, + { name: 'K105', rating: 2 }, + { name: 'K106', rating: 2 }, + { name: 'K107', rating: 2 }, + { name: 'K108', rating: 2 }, + { name: 'K109', rating: 2 }, + { name: 'K110', rating: 2 }, + { name: 'K111', rating: 2 }, + { name: 'K112', rating: 2 }, + { name: 'K113', rating: 2 }, + { name: 'K114', rating: 2 }, + { name: 'K115', rating: 2 }, + { name: 'K116', rating: 2 }, + { name: 'K117', rating: 2 }, + { name: 'K118', rating: 2 }, + { name: 'K119', rating: 2 }, + { name: 'K120', rating: 2 }, + { name: 'K121', rating: 2 }, + { name: 'K122', rating: 2 }, + { name: 'K123', rating: 2 }, + { name: 'K124', rating: 2 }, + { name: 'K125', rating: 2 }, + { name: 'K126', rating: 2 }, + { name: 'K127', rating: 2 }, + { name: 'K128', rating: 2 }, + { name: 'K129', rating: 2 }, + { name: 'K130', rating: 2 }, + { name: 'K131', rating: 2 }, + { name: 'K132', rating: 2 }, + { name: 'K133', rating: 2 }, + { name: 'K134', rating: 2 }, + { name: 'K135', rating: 2 }, + { name: 'K136', rating: 2 }, + { name: 'K137', rating: 2 }, + { name: 'K138', rating: 2 }, + { name: 'K139', rating: 2 }, + { name: 'K140', rating: 2 }, + { name: 'K141', rating: 2 }, + { name: 'K142', rating: 2 }, + { name: 'K143', rating: 2 }, + { name: 'K144', rating: 2 }, + { name: 'K145', rating: 2 }, + { name: 'K146', rating: 2 }, + { name: 'K147', rating: 2 }, + { name: 'K148', rating: 2 }, + { name: 'K149', rating: 2 }, + { name: 'K150', rating: 2 }, + { name: 'K151', rating: 2 }, + { name: 'K152', rating: 2 }, + { name: 'K153', rating: 2 }, + { name: 'K154', rating: 2 }, + { name: 'K155', rating: 2 }, + { name: 'K156', rating: 2 }, + { name: 'K157', rating: 2 }, + { name: 'K158', rating: 2 }, + { name: 'K159', rating: 2 }, + { name: 'K160', rating: 2 }, + { name: 'K161', rating: 2 }, + { name: 'K162', rating: 2 }, + { name: 'K163', rating: 2 }, + { name: 'K164', rating: 2 }, + { name: 'K165', rating: 2 }, + { name: 'K166', rating: 2 }, + { name: 'K167', rating: 2 }, + { name: 'K168', rating: 2 }, + { name: 'K169', rating: 2 }, + { name: 'K170', rating: 2 }, + { name: 'K171', rating: 2 }, + { name: 'K172', rating: 2 }, + { name: 'K173', rating: 2 }, + { name: 'K174', rating: 2 }, + { name: 'K175', rating: 2 }, + { name: 'K176', rating: 2 }, + { name: 'K177', rating: 2 }, +]; +assert.sameValue(array.length, 2048); + +// Sort the elements by `rating` in descending order. +// (This updates `array` in place.) +array.sort((a, b) => b.rating - a.rating); + +const reduced = array.reduce((acc, element) => { + const letter = element.name.slice(0, 1); + const previousLetter = acc.slice(-1); + if (previousLetter === letter) { + return acc; + } + return acc + letter; +}, ''); +assert.sameValue(reduced, 'DGBEFHACIJK'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/stability-5-elements.js b/js/src/tests/test262/built-ins/Array/prototype/sort/stability-5-elements.js new file mode 100644 index 0000000000..76285695db --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/stability-5-elements.js @@ -0,0 +1,29 @@ +// Copyright (C) 2018 Mathias Bynens. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Stability of Array.prototype.sort for an array with 5 elements. +info: | + The sort is required to be stable (that is, elements that compare equal + remain in their original order). +---*/ + +const array = [ + { name: 'A', rating: 2 }, + { name: 'B', rating: 3 }, + { name: 'C', rating: 2 }, + { name: 'D', rating: 3 }, + { name: 'E', rating: 3 }, +]; +assert.sameValue(array.length, 5); + +// Sort the elements by `rating` in descending order. +// (This updates `array` in place.) +array.sort((a, b) => b.rating - a.rating); + +const reduced = array.reduce((acc, element) => acc + element.name, ''); +assert.sameValue(reduced, 'BDEAC'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/stability-513-elements.js b/js/src/tests/test262/built-ins/Array/prototype/sort/stability-513-elements.js new file mode 100644 index 0000000000..8662a6d264 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/stability-513-elements.js @@ -0,0 +1,548 @@ +// Copyright (C) 2018 Mathias Bynens. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.sort +description: > + Stability of Array.prototype.sort for an array with 513 elements. +info: | + The sort is required to be stable (that is, elements that compare equal + remain in their original order). + The array length of 513 was chosen because until late 2018, Chakra + used to apply an unstable QuickSort for arrays with more than 512 + elements, although it used a stable insertion sort for anything else. + https://github.com/Microsoft/ChakraCore/pull/5724 +---*/ + +const array = [ + { name: 'A00', rating: 2 }, + { name: 'A01', rating: 2 }, + { name: 'A02', rating: 2 }, + { name: 'A03', rating: 2 }, + { name: 'A04', rating: 2 }, + { name: 'A05', rating: 2 }, + { name: 'A06', rating: 2 }, + { name: 'A07', rating: 2 }, + { name: 'A08', rating: 2 }, + { name: 'A09', rating: 2 }, + { name: 'A10', rating: 2 }, + { name: 'A11', rating: 2 }, + { name: 'A12', rating: 2 }, + { name: 'A13', rating: 2 }, + { name: 'A14', rating: 2 }, + { name: 'A15', rating: 2 }, + { name: 'A16', rating: 2 }, + { name: 'A17', rating: 2 }, + { name: 'A18', rating: 2 }, + { name: 'A19', rating: 2 }, + { name: 'A20', rating: 2 }, + { name: 'A21', rating: 2 }, + { name: 'A22', rating: 2 }, + { name: 'A23', rating: 2 }, + { name: 'A24', rating: 2 }, + { name: 'A25', rating: 2 }, + { name: 'A26', rating: 2 }, + { name: 'A27', rating: 2 }, + { name: 'A28', rating: 2 }, + { name: 'A29', rating: 2 }, + { name: 'A30', rating: 2 }, + { name: 'A31', rating: 2 }, + { name: 'A32', rating: 2 }, + { name: 'A33', rating: 2 }, + { name: 'A34', rating: 2 }, + { name: 'A35', rating: 2 }, + { name: 'A36', rating: 2 }, + { name: 'A37', rating: 2 }, + { name: 'A38', rating: 2 }, + { name: 'A39', rating: 2 }, + { name: 'A40', rating: 2 }, + { name: 'A41', rating: 2 }, + { name: 'A42', rating: 2 }, + { name: 'A43', rating: 2 }, + { name: 'A44', rating: 2 }, + { name: 'A45', rating: 2 }, + { name: 'A46', rating: 2 }, + { name: 'B00', rating: 3 }, + { name: 'B01', rating: 3 }, + { name: 'B02', rating: 3 }, + { name: 'B03', rating: 3 }, + { name: 'B04', rating: 3 }, + { name: 'B05', rating: 3 }, + { name: 'B06', rating: 3 }, + { name: 'B07', rating: 3 }, + { name: 'B08', rating: 3 }, + { name: 'B09', rating: 3 }, + { name: 'B10', rating: 3 }, + { name: 'B11', rating: 3 }, + { name: 'B12', rating: 3 }, + { name: 'B13', rating: 3 }, + { name: 'B14', rating: 3 }, + { name: 'B15', rating: 3 }, + { name: 'B16', rating: 3 }, + { name: 'B17', rating: 3 }, + { name: 'B18', rating: 3 }, + { name: 'B19', rating: 3 }, + { name: 'B20', rating: 3 }, + { name: 'B21', rating: 3 }, + { name: 'B22', rating: 3 }, + { name: 'B23', rating: 3 }, + { name: 'B24', rating: 3 }, + { name: 'B25', rating: 3 }, + { name: 'B26', rating: 3 }, + { name: 'B27', rating: 3 }, + { name: 'B28', rating: 3 }, + { name: 'B29', rating: 3 }, + { name: 'B30', rating: 3 }, + { name: 'B31', rating: 3 }, + { name: 'B32', rating: 3 }, + { name: 'B33', rating: 3 }, + { name: 'B34', rating: 3 }, + { name: 'B35', rating: 3 }, + { name: 'B36', rating: 3 }, + { name: 'B37', rating: 3 }, + { name: 'B38', rating: 3 }, + { name: 'B39', rating: 3 }, + { name: 'B40', rating: 3 }, + { name: 'B41', rating: 3 }, + { name: 'B42', rating: 3 }, + { name: 'B43', rating: 3 }, + { name: 'B44', rating: 3 }, + { name: 'B45', rating: 3 }, + { name: 'B46', rating: 3 }, + { name: 'C00', rating: 2 }, + { name: 'C01', rating: 2 }, + { name: 'C02', rating: 2 }, + { name: 'C03', rating: 2 }, + { name: 'C04', rating: 2 }, + { name: 'C05', rating: 2 }, + { name: 'C06', rating: 2 }, + { name: 'C07', rating: 2 }, + { name: 'C08', rating: 2 }, + { name: 'C09', rating: 2 }, + { name: 'C10', rating: 2 }, + { name: 'C11', rating: 2 }, + { name: 'C12', rating: 2 }, + { name: 'C13', rating: 2 }, + { name: 'C14', rating: 2 }, + { name: 'C15', rating: 2 }, + { name: 'C16', rating: 2 }, + { name: 'C17', rating: 2 }, + { name: 'C18', rating: 2 }, + { name: 'C19', rating: 2 }, + { name: 'C20', rating: 2 }, + { name: 'C21', rating: 2 }, + { name: 'C22', rating: 2 }, + { name: 'C23', rating: 2 }, + { name: 'C24', rating: 2 }, + { name: 'C25', rating: 2 }, + { name: 'C26', rating: 2 }, + { name: 'C27', rating: 2 }, + { name: 'C28', rating: 2 }, + { name: 'C29', rating: 2 }, + { name: 'C30', rating: 2 }, + { name: 'C31', rating: 2 }, + { name: 'C32', rating: 2 }, + { name: 'C33', rating: 2 }, + { name: 'C34', rating: 2 }, + { name: 'C35', rating: 2 }, + { name: 'C36', rating: 2 }, + { name: 'C37', rating: 2 }, + { name: 'C38', rating: 2 }, + { name: 'C39', rating: 2 }, + { name: 'C40', rating: 2 }, + { name: 'C41', rating: 2 }, + { name: 'C42', rating: 2 }, + { name: 'C43', rating: 2 }, + { name: 'C44', rating: 2 }, + { name: 'C45', rating: 2 }, + { name: 'C46', rating: 2 }, + { name: 'D00', rating: 4 }, + { name: 'D01', rating: 4 }, + { name: 'D02', rating: 4 }, + { name: 'D03', rating: 4 }, + { name: 'D04', rating: 4 }, + { name: 'D05', rating: 4 }, + { name: 'D06', rating: 4 }, + { name: 'D07', rating: 4 }, + { name: 'D08', rating: 4 }, + { name: 'D09', rating: 4 }, + { name: 'D10', rating: 4 }, + { name: 'D11', rating: 4 }, + { name: 'D12', rating: 4 }, + { name: 'D13', rating: 4 }, + { name: 'D14', rating: 4 }, + { name: 'D15', rating: 4 }, + { name: 'D16', rating: 4 }, + { name: 'D17', rating: 4 }, + { name: 'D18', rating: 4 }, + { name: 'D19', rating: 4 }, + { name: 'D20', rating: 4 }, + { name: 'D21', rating: 4 }, + { name: 'D22', rating: 4 }, + { name: 'D23', rating: 4 }, + { name: 'D24', rating: 4 }, + { name: 'D25', rating: 4 }, + { name: 'D26', rating: 4 }, + { name: 'D27', rating: 4 }, + { name: 'D28', rating: 4 }, + { name: 'D29', rating: 4 }, + { name: 'D30', rating: 4 }, + { name: 'D31', rating: 4 }, + { name: 'D32', rating: 4 }, + { name: 'D33', rating: 4 }, + { name: 'D34', rating: 4 }, + { name: 'D35', rating: 4 }, + { name: 'D36', rating: 4 }, + { name: 'D37', rating: 4 }, + { name: 'D38', rating: 4 }, + { name: 'D39', rating: 4 }, + { name: 'D40', rating: 4 }, + { name: 'D41', rating: 4 }, + { name: 'D42', rating: 4 }, + { name: 'D43', rating: 4 }, + { name: 'D44', rating: 4 }, + { name: 'D45', rating: 4 }, + { name: 'D46', rating: 4 }, + { name: 'E00', rating: 3 }, + { name: 'E01', rating: 3 }, + { name: 'E02', rating: 3 }, + { name: 'E03', rating: 3 }, + { name: 'E04', rating: 3 }, + { name: 'E05', rating: 3 }, + { name: 'E06', rating: 3 }, + { name: 'E07', rating: 3 }, + { name: 'E08', rating: 3 }, + { name: 'E09', rating: 3 }, + { name: 'E10', rating: 3 }, + { name: 'E11', rating: 3 }, + { name: 'E12', rating: 3 }, + { name: 'E13', rating: 3 }, + { name: 'E14', rating: 3 }, + { name: 'E15', rating: 3 }, + { name: 'E16', rating: 3 }, + { name: 'E17', rating: 3 }, + { name: 'E18', rating: 3 }, + { name: 'E19', rating: 3 }, + { name: 'E20', rating: 3 }, + { name: 'E21', rating: 3 }, + { name: 'E22', rating: 3 }, + { name: 'E23', rating: 3 }, + { name: 'E24', rating: 3 }, + { name: 'E25', rating: 3 }, + { name: 'E26', rating: 3 }, + { name: 'E27', rating: 3 }, + { name: 'E28', rating: 3 }, + { name: 'E29', rating: 3 }, + { name: 'E30', rating: 3 }, + { name: 'E31', rating: 3 }, + { name: 'E32', rating: 3 }, + { name: 'E33', rating: 3 }, + { name: 'E34', rating: 3 }, + { name: 'E35', rating: 3 }, + { name: 'E36', rating: 3 }, + { name: 'E37', rating: 3 }, + { name: 'E38', rating: 3 }, + { name: 'E39', rating: 3 }, + { name: 'E40', rating: 3 }, + { name: 'E41', rating: 3 }, + { name: 'E42', rating: 3 }, + { name: 'E43', rating: 3 }, + { name: 'E44', rating: 3 }, + { name: 'E45', rating: 3 }, + { name: 'E46', rating: 3 }, + { name: 'F00', rating: 3 }, + { name: 'F01', rating: 3 }, + { name: 'F02', rating: 3 }, + { name: 'F03', rating: 3 }, + { name: 'F04', rating: 3 }, + { name: 'F05', rating: 3 }, + { name: 'F06', rating: 3 }, + { name: 'F07', rating: 3 }, + { name: 'F08', rating: 3 }, + { name: 'F09', rating: 3 }, + { name: 'F10', rating: 3 }, + { name: 'F11', rating: 3 }, + { name: 'F12', rating: 3 }, + { name: 'F13', rating: 3 }, + { name: 'F14', rating: 3 }, + { name: 'F15', rating: 3 }, + { name: 'F16', rating: 3 }, + { name: 'F17', rating: 3 }, + { name: 'F18', rating: 3 }, + { name: 'F19', rating: 3 }, + { name: 'F20', rating: 3 }, + { name: 'F21', rating: 3 }, + { name: 'F22', rating: 3 }, + { name: 'F23', rating: 3 }, + { name: 'F24', rating: 3 }, + { name: 'F25', rating: 3 }, + { name: 'F26', rating: 3 }, + { name: 'F27', rating: 3 }, + { name: 'F28', rating: 3 }, + { name: 'F29', rating: 3 }, + { name: 'F30', rating: 3 }, + { name: 'F31', rating: 3 }, + { name: 'F32', rating: 3 }, + { name: 'F33', rating: 3 }, + { name: 'F34', rating: 3 }, + { name: 'F35', rating: 3 }, + { name: 'F36', rating: 3 }, + { name: 'F37', rating: 3 }, + { name: 'F38', rating: 3 }, + { name: 'F39', rating: 3 }, + { name: 'F40', rating: 3 }, + { name: 'F41', rating: 3 }, + { name: 'F42', rating: 3 }, + { name: 'F43', rating: 3 }, + { name: 'F44', rating: 3 }, + { name: 'F45', rating: 3 }, + { name: 'F46', rating: 3 }, + { name: 'G00', rating: 4 }, + { name: 'G01', rating: 4 }, + { name: 'G02', rating: 4 }, + { name: 'G03', rating: 4 }, + { name: 'G04', rating: 4 }, + { name: 'G05', rating: 4 }, + { name: 'G06', rating: 4 }, + { name: 'G07', rating: 4 }, + { name: 'G08', rating: 4 }, + { name: 'G09', rating: 4 }, + { name: 'G10', rating: 4 }, + { name: 'G11', rating: 4 }, + { name: 'G12', rating: 4 }, + { name: 'G13', rating: 4 }, + { name: 'G14', rating: 4 }, + { name: 'G15', rating: 4 }, + { name: 'G16', rating: 4 }, + { name: 'G17', rating: 4 }, + { name: 'G18', rating: 4 }, + { name: 'G19', rating: 4 }, + { name: 'G20', rating: 4 }, + { name: 'G21', rating: 4 }, + { name: 'G22', rating: 4 }, + { name: 'G23', rating: 4 }, + { name: 'G24', rating: 4 }, + { name: 'G25', rating: 4 }, + { name: 'G26', rating: 4 }, + { name: 'G27', rating: 4 }, + { name: 'G28', rating: 4 }, + { name: 'G29', rating: 4 }, + { name: 'G30', rating: 4 }, + { name: 'G31', rating: 4 }, + { name: 'G32', rating: 4 }, + { name: 'G33', rating: 4 }, + { name: 'G34', rating: 4 }, + { name: 'G35', rating: 4 }, + { name: 'G36', rating: 4 }, + { name: 'G37', rating: 4 }, + { name: 'G38', rating: 4 }, + { name: 'G39', rating: 4 }, + { name: 'G40', rating: 4 }, + { name: 'G41', rating: 4 }, + { name: 'G42', rating: 4 }, + { name: 'G43', rating: 4 }, + { name: 'G44', rating: 4 }, + { name: 'G45', rating: 4 }, + { name: 'G46', rating: 4 }, + { name: 'H00', rating: 3 }, + { name: 'H01', rating: 3 }, + { name: 'H02', rating: 3 }, + { name: 'H03', rating: 3 }, + { name: 'H04', rating: 3 }, + { name: 'H05', rating: 3 }, + { name: 'H06', rating: 3 }, + { name: 'H07', rating: 3 }, + { name: 'H08', rating: 3 }, + { name: 'H09', rating: 3 }, + { name: 'H10', rating: 3 }, + { name: 'H11', rating: 3 }, + { name: 'H12', rating: 3 }, + { name: 'H13', rating: 3 }, + { name: 'H14', rating: 3 }, + { name: 'H15', rating: 3 }, + { name: 'H16', rating: 3 }, + { name: 'H17', rating: 3 }, + { name: 'H18', rating: 3 }, + { name: 'H19', rating: 3 }, + { name: 'H20', rating: 3 }, + { name: 'H21', rating: 3 }, + { name: 'H22', rating: 3 }, + { name: 'H23', rating: 3 }, + { name: 'H24', rating: 3 }, + { name: 'H25', rating: 3 }, + { name: 'H26', rating: 3 }, + { name: 'H27', rating: 3 }, + { name: 'H28', rating: 3 }, + { name: 'H29', rating: 3 }, + { name: 'H30', rating: 3 }, + { name: 'H31', rating: 3 }, + { name: 'H32', rating: 3 }, + { name: 'H33', rating: 3 }, + { name: 'H34', rating: 3 }, + { name: 'H35', rating: 3 }, + { name: 'H36', rating: 3 }, + { name: 'H37', rating: 3 }, + { name: 'H38', rating: 3 }, + { name: 'H39', rating: 3 }, + { name: 'H40', rating: 3 }, + { name: 'H41', rating: 3 }, + { name: 'H42', rating: 3 }, + { name: 'H43', rating: 3 }, + { name: 'H44', rating: 3 }, + { name: 'H45', rating: 3 }, + { name: 'H46', rating: 3 }, + { name: 'I00', rating: 2 }, + { name: 'I01', rating: 2 }, + { name: 'I02', rating: 2 }, + { name: 'I03', rating: 2 }, + { name: 'I04', rating: 2 }, + { name: 'I05', rating: 2 }, + { name: 'I06', rating: 2 }, + { name: 'I07', rating: 2 }, + { name: 'I08', rating: 2 }, + { name: 'I09', rating: 2 }, + { name: 'I10', rating: 2 }, + { name: 'I11', rating: 2 }, + { name: 'I12', rating: 2 }, + { name: 'I13', rating: 2 }, + { name: 'I14', rating: 2 }, + { name: 'I15', rating: 2 }, + { name: 'I16', rating: 2 }, + { name: 'I17', rating: 2 }, + { name: 'I18', rating: 2 }, + { name: 'I19', rating: 2 }, + { name: 'I20', rating: 2 }, + { name: 'I21', rating: 2 }, + { name: 'I22', rating: 2 }, + { name: 'I23', rating: 2 }, + { name: 'I24', rating: 2 }, + { name: 'I25', rating: 2 }, + { name: 'I26', rating: 2 }, + { name: 'I27', rating: 2 }, + { name: 'I28', rating: 2 }, + { name: 'I29', rating: 2 }, + { name: 'I30', rating: 2 }, + { name: 'I31', rating: 2 }, + { name: 'I32', rating: 2 }, + { name: 'I33', rating: 2 }, + { name: 'I34', rating: 2 }, + { name: 'I35', rating: 2 }, + { name: 'I36', rating: 2 }, + { name: 'I37', rating: 2 }, + { name: 'I38', rating: 2 }, + { name: 'I39', rating: 2 }, + { name: 'I40', rating: 2 }, + { name: 'I41', rating: 2 }, + { name: 'I42', rating: 2 }, + { name: 'I43', rating: 2 }, + { name: 'I44', rating: 2 }, + { name: 'I45', rating: 2 }, + { name: 'I46', rating: 2 }, + { name: 'J00', rating: 2 }, + { name: 'J01', rating: 2 }, + { name: 'J02', rating: 2 }, + { name: 'J03', rating: 2 }, + { name: 'J04', rating: 2 }, + { name: 'J05', rating: 2 }, + { name: 'J06', rating: 2 }, + { name: 'J07', rating: 2 }, + { name: 'J08', rating: 2 }, + { name: 'J09', rating: 2 }, + { name: 'J10', rating: 2 }, + { name: 'J11', rating: 2 }, + { name: 'J12', rating: 2 }, + { name: 'J13', rating: 2 }, + { name: 'J14', rating: 2 }, + { name: 'J15', rating: 2 }, + { name: 'J16', rating: 2 }, + { name: 'J17', rating: 2 }, + { name: 'J18', rating: 2 }, + { name: 'J19', rating: 2 }, + { name: 'J20', rating: 2 }, + { name: 'J21', rating: 2 }, + { name: 'J22', rating: 2 }, + { name: 'J23', rating: 2 }, + { name: 'J24', rating: 2 }, + { name: 'J25', rating: 2 }, + { name: 'J26', rating: 2 }, + { name: 'J27', rating: 2 }, + { name: 'J28', rating: 2 }, + { name: 'J29', rating: 2 }, + { name: 'J30', rating: 2 }, + { name: 'J31', rating: 2 }, + { name: 'J32', rating: 2 }, + { name: 'J33', rating: 2 }, + { name: 'J34', rating: 2 }, + { name: 'J35', rating: 2 }, + { name: 'J36', rating: 2 }, + { name: 'J37', rating: 2 }, + { name: 'J38', rating: 2 }, + { name: 'J39', rating: 2 }, + { name: 'J40', rating: 2 }, + { name: 'J41', rating: 2 }, + { name: 'J42', rating: 2 }, + { name: 'J43', rating: 2 }, + { name: 'J44', rating: 2 }, + { name: 'J45', rating: 2 }, + { name: 'J46', rating: 2 }, + { name: 'K00', rating: 2 }, + { name: 'K01', rating: 2 }, + { name: 'K02', rating: 2 }, + { name: 'K03', rating: 2 }, + { name: 'K04', rating: 2 }, + { name: 'K05', rating: 2 }, + { name: 'K06', rating: 2 }, + { name: 'K07', rating: 2 }, + { name: 'K08', rating: 2 }, + { name: 'K09', rating: 2 }, + { name: 'K10', rating: 2 }, + { name: 'K11', rating: 2 }, + { name: 'K12', rating: 2 }, + { name: 'K13', rating: 2 }, + { name: 'K14', rating: 2 }, + { name: 'K15', rating: 2 }, + { name: 'K16', rating: 2 }, + { name: 'K17', rating: 2 }, + { name: 'K18', rating: 2 }, + { name: 'K19', rating: 2 }, + { name: 'K20', rating: 2 }, + { name: 'K21', rating: 2 }, + { name: 'K22', rating: 2 }, + { name: 'K23', rating: 2 }, + { name: 'K24', rating: 2 }, + { name: 'K25', rating: 2 }, + { name: 'K26', rating: 2 }, + { name: 'K27', rating: 2 }, + { name: 'K28', rating: 2 }, + { name: 'K29', rating: 2 }, + { name: 'K30', rating: 2 }, + { name: 'K31', rating: 2 }, + { name: 'K32', rating: 2 }, + { name: 'K33', rating: 2 }, + { name: 'K34', rating: 2 }, + { name: 'K35', rating: 2 }, + { name: 'K36', rating: 2 }, + { name: 'K37', rating: 2 }, + { name: 'K38', rating: 2 }, + { name: 'K39', rating: 2 }, + { name: 'K40', rating: 2 }, + { name: 'K41', rating: 2 }, + { name: 'K42', rating: 2 }, +]; +assert.sameValue(array.length, 513); + +// Sort the elements by `rating` in descending order. +// (This updates `array` in place.) +array.sort((a, b) => b.rating - a.rating); + +const reduced = array.reduce((acc, element) => { + const letter = element.name.slice(0, 1); + const previousLetter = acc.slice(-1); + if (previousLetter === letter) { + return acc; + } + return acc + letter; +}, ''); +assert.sameValue(reduced, 'DGBEFHACIJK'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/15.4.4.12-9-a-1.js b/js/src/tests/test262/built-ins/Array/prototype/splice/15.4.4.12-9-a-1.js new file mode 100644 index 0000000000..665fd57771 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/15.4.4.12-9-a-1.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + Array.prototype.splice - 'from' is the result of + ToString(actualStart+k) in an Array +---*/ + +var arrObj = [1, 2, 3]; +var newArrObj = arrObj.splice(-2, 1); + +assert.sameValue(newArrObj.length, 1, 'newArrObj.length'); +assert.sameValue(newArrObj[0], 2, 'newArrObj[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/15.4.4.12-9-c-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/splice/15.4.4.12-9-c-ii-1.js new file mode 100644 index 0000000000..5323c13cfc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/15.4.4.12-9-c-ii-1.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + Array.prototype.splice will splice an array even when + Array.prototype has index '0' set to read-only and 'fromPresent' + less than 'actualDeleteCount (Step 9.c.ii) +---*/ + +var arr = ["a", "b", "c"]; +Array.prototype[0] = "test"; +var newArr = arr.splice(2, 1, "d"); + +var verifyValue = false; +verifyValue = arr.length === 3 && arr[0] === "a" && arr[1] === "b" && arr[2] === "d" && + newArr[0] === "c" && newArr.length === 1; + +var verifyEnumerable = false; +for (var p in newArr) { + if (newArr.hasOwnProperty("0") && p === "0") { + verifyEnumerable = true; + } +} + +var verifyWritable = false; +newArr[0] = 12; +verifyWritable = newArr[0] === 12; + +var verifyConfigurable = false; +delete newArr[0]; +verifyConfigurable = newArr.hasOwnProperty("0"); + +assert(verifyValue, 'verifyValue !== true'); +assert.sameValue(verifyConfigurable, false, 'verifyConfigurable'); +assert(verifyEnumerable, 'verifyEnumerable !== true'); +assert(verifyWritable, 'verifyWritable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T1.js new file mode 100644 index 0000000000..fc6c0a0eb0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T1.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length > deleteCount > start = 0, itemCount = 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(0, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(0,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(0,3); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(0,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(0,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(0,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(0,3); x.length === 1. Actual: ' + (x.length)); +} + +if (x[0] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(0,3); x[0] === 3. Actual: ' + (x[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T2.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T2.js new file mode 100644 index 0000000000..acab980a90 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T2.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length > deleteCount > start = 0, itemCount > 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(0, 3, 4, 5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (x.length !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); x.length === 3. Actual: ' + (x.length)); +} + +if (x[0] !== 4) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); x[0] === 4. Actual: ' + (x[0])); +} + +if (x[1] !== 5) { + throw new Test262Error('#8: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); x[1] === 5. Actual: ' + (x[1])); +} + +if (x[2] !== 3) { + throw new Test262Error('#9: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); x[2] === 3. Actual: ' + (x[2])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T3.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T3.js new file mode 100644 index 0000000000..a69ab334f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T3.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length = deleteCount > start = 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(0, 4); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(0,4); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 4) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(0,4); arr.length === 4. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(0,4); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(0,4); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(0,4); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(0,4); arr[3] === 3. Actual: ' + (arr[3])); +} + +if (x.length !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(0,4); x.length === 0. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T4.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T4.js new file mode 100644 index 0000000000..760b4cb0d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T4.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length > deleteCount > start > 0, itemCount > 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(1, 3, 4, 5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 1) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr[0] === 1. Actual: ' + (arr[0])); +} + +if (arr[1] !== 2) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr[1] === 2. Actual: ' + (arr[1])); +} + +if (arr[2] !== 3) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr[2] === 3. Actual: ' + (arr[2])); +} + +if (x.length !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); x.length === 3. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 4) { + throw new Test262Error('#8: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); x[1] === 4. Actual: ' + (x[1])); +} + +if (x[2] !== 5) { + throw new Test262Error('#9: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); x[2] === 5. Actual: ' + (x[2])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T5.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T5.js new file mode 100644 index 0000000000..0d21453024 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T5.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: deleteCount > length > start = 0, itemCount = 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(0, 5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(0,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 4) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(0,5); arr.length === 4. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(0,5); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(0,5); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(0,5); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(0,5); arr[3] === 3. Actual: ' + (arr[3])); +} + +if (x.length !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(0,5); x.length === 0. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T6.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T6.js new file mode 100644 index 0000000000..3daeb79c61 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T6.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length = deleteCount > start > 0, itemCount > 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(1, 4, 4, 5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 1) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr[0] === 1. Actual: ' + (arr[0])); +} + +if (arr[1] !== 2) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr[1] === 2. Actual: ' + (arr[1])); +} + +if (arr[2] !== 3) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr[2] === 3. Actual: ' + (arr[2])); +} + +if (x.length !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); x.length === 3. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 4) { + throw new Test262Error('#8: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); x[1] === 4. Actual: ' + (x[1])); +} + +if (x[2] !== 5) { + throw new Test262Error('#9: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); x[2] === 5. Actual: ' + (x[2])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T1.js new file mode 100644 index 0000000000..fae73a4f34 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T1.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length = start < deleteCount < 0, itemCount = 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(-2, -1); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(-2,-1); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(-2,-1); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x.length !== 2) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(-2,-1); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(-2,-1); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(-2,-1); x[1] === 1. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T2.js new file mode 100644 index 0000000000..a9f5127015 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T2.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length < start = deleteCount < 0, itemCount = 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(-1, -1); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(-1,-1); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(-1,-1); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x.length !== 2) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(-1,-1); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(-1,-1); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(-1,-1); x[1] === 1. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T3.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T3.js new file mode 100644 index 0000000000..6b8d6f5bfd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T3.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length = start < deleteCount < 0, itemCount > 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(-2, -1, 2, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(-2,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(-2,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x.length !== 4) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(-2,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} + +if (x[0] !== 2) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(-2,-1,2,3); x[0] === 2. Actual: ' + (x[0])); +} + +if (x[1] !== 3) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(-2,-1,2,3); x[1] === 3. Actual: ' + (x[1])); +} + +if (x[2] !== 0) { + throw new Test262Error('#5: var x = [0,1]; var arr = x.splice(-2,-1,2,3); x[2] === 0. Actual: ' + (x[2])); +} + +if (x[3] !== 1) { + throw new Test262Error('#6: var x = [0,1]; var arr = x.splice(-2,-1,2,3); x[3] === 1. Actual: ' + (x[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T4.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T4.js new file mode 100644 index 0000000000..e3be864ac8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T4.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length < start = deleteCount < 0, itemCount > 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(-1, -1, 2, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(-1,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(-1,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x.length !== 4) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(-1,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(-1,-1,2,3); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 2) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(-1,-1,2,3); x[1] === 2. Actual: ' + (x[1])); +} + +if (x[2] !== 3) { + throw new Test262Error('#5: var x = [0,1]; var arr = x.splice(-1,-1,2,3); x[2] === 3. Actual: ' + (x[2])); +} + +if (x[3] !== 1) { + throw new Test262Error('#6: var x = [0,1]; var arr = x.splice(-1,-1,2,3); x[3] === 1. Actual: ' + (x[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T5.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T5.js new file mode 100644 index 0000000000..e1e0b56e32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T5.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: start < -length < deleteCount < 0, itemCount > 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(-3, -1, 2, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(-3,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(-3,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x.length !== 4) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(-3,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} + +if (x[0] !== 2) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(-3,-1,2,3); x[0] === 2. Actual: ' + (x[0])); +} + +if (x[1] !== 3) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(-3,-1,2,3); x[1] === 3. Actual: ' + (x[1])); +} + +if (x[2] !== 0) { + throw new Test262Error('#5: var x = [0,1]; var arr = x.splice(-3,-1,2,3); x[2] === 0. Actual: ' + (x[2])); +} + +if (x[3] !== 1) { + throw new Test262Error('#6: var x = [0,1]; var arr = x.splice(-3,-1,2,3); x[3] === 1. Actual: ' + (x[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T1.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T1.js new file mode 100644 index 0000000000..5183980022 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T1.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length < deleteCount < start = 0, itemCount = 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(0, -1); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(0,-1); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(0,-1); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x.length !== 2) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(0,-1); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(0,-1); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(0,-1); x[1] === 1. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T2.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T2.js new file mode 100644 index 0000000000..4d85c4b251 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T2.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length = -start < deleteCount < 0, itemCount = 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(2, -1); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(2,-1); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(2,-1); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x.length !== 2) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(2,-1); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(2,-1); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(2,-1); x[1] === 1. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T3.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T3.js new file mode 100644 index 0000000000..627753cd24 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T3.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length < deleteCount < start = 0, itemCount > 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(0, -1, 2, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(0,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(0,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x.length !== 4) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(0,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} + +if (x[0] !== 2) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(0,-1,2,3); x[0] === 2. Actual: ' + (x[0])); +} + +if (x[1] !== 3) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(0,-1,2,3); x[1] === 3. Actual: ' + (x[1])); +} + +if (x[2] !== 0) { + throw new Test262Error('#5: var x = [0,1]; var arr = x.splice(0,-1,2,3); x[2] === 0. Actual: ' + (x[2])); +} + +if (x[3] !== 1) { + throw new Test262Error('#6: var x = [0,1]; var arr = x.splice(0,-1,2,3); x[3] === 1. Actual: ' + (x[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T4.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T4.js new file mode 100644 index 0000000000..83e32eabad --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T4.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length = -start < deleteCount < 0, itemCount > 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(2, -1, 2, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(2,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(2,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x.length !== 4) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(2,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(2,-1,2,3); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(2,-1,2,3); x[1] === 1. Actual: ' + (x[1])); +} + +if (x[2] !== 2) { + throw new Test262Error('#5: var x = [0,1]; var arr = x.splice(2,-1,2,3); x[2] === 2. Actual: ' + (x[2])); +} + +if (x[3] !== 3) { + throw new Test262Error('#6: var x = [0,1]; var arr = x.splice(2,-1,2,3); x[3] === 3. Actual: ' + (x[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T5.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T5.js new file mode 100644 index 0000000000..8e9c337f19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T5.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -start < -length < deleteCount < 0, itemCount > 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(3, -1, 2, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(3,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(3,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x.length !== 4) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(3,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(3,-1,2,3); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(3,-1,2,3); x[1] === 1. Actual: ' + (x[1])); +} + +if (x[2] !== 2) { + throw new Test262Error('#5: var x = [0,1]; var arr = x.splice(3,-1,2,3); x[2] === 2. Actual: ' + (x[2])); +} + +if (x[3] !== 3) { + throw new Test262Error('#6: var x = [0,1]; var arr = x.splice(3,-1,2,3); x[3] === 3. Actual: ' + (x[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T1.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T1.js new file mode 100644 index 0000000000..192c5d3d42 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T1.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length = -start > deleteCount > 0, itemCount = 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(-4, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(-4,3); x.length === 1. Actual: ' + (x.length)); +} + +if (x[0] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(-4,3); x[0] === 3. Actual: ' + (x[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T2.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T2.js new file mode 100644 index 0000000000..2b9c02509d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T2.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length = -start > deleteCount > 0, itemCount > 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(-4, 3, 4, 5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (x.length !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); x.length === 3. Actual: ' + (x.length)); +} + +if (x[0] !== 4) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); x[0] === 4. Actual: ' + (x[0])); +} + +if (x[1] !== 5) { + throw new Test262Error('#8: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); x[1] === 5. Actual: ' + (x[1])); +} + +if (x[2] !== 3) { + throw new Test262Error('#9: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); x[2] === 3. Actual: ' + (x[2])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T3.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T3.js new file mode 100644 index 0000000000..61d50324c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T3.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: -start > length = deleteCount > 0, itemCount = 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(-5, 4); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 4) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr.length === 4. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr[3] === 3. Actual: ' + (arr[3])); +} + +if (x.length !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(-5,4); x.length === 0. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T4.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T4.js new file mode 100644 index 0000000000..14927ad334 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T4.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length > -start = deleteCount > 0, itemCount > 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(-3, 3, 4, 5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 1) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr[0] === 1. Actual: ' + (arr[0])); +} + +if (arr[1] !== 2) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr[1] === 2. Actual: ' + (arr[1])); +} + +if (arr[2] !== 3) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr[2] === 3. Actual: ' + (arr[2])); +} + +if (x.length !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); x.length === 3. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 4) { + throw new Test262Error('#8: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); x[1] === 4. Actual: ' + (x[1])); +} + +if (x[2] !== 5) { + throw new Test262Error('#9: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); x[2] === 5. Actual: ' + (x[2])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T5.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T5.js new file mode 100644 index 0000000000..1ed94192ce --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T5.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: -start > deleteCount > length > 0, itemCount = 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(-9, 5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 4) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr.length === 4. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr[3] === 3. Actual: ' + (arr[3])); +} + +if (x.length !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(-9,5); x.length === 0. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T6.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T6.js new file mode 100644 index 0000000000..afae2a1210 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T6.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length = deleteCount > -start > 0, itemCount > 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(-3, 4, 4, 5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 1) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr[0] === 1. Actual: ' + (arr[0])); +} + +if (arr[1] !== 2) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr[1] === 2. Actual: ' + (arr[1])); +} + +if (arr[2] !== 3) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr[2] === 3. Actual: ' + (arr[2])); +} + +if (x.length !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); x.length === 3. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 4) { + throw new Test262Error('#8: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); x[1] === 4. Actual: ' + (x[1])); +} + +if (x[2] !== 5) { + throw new Test262Error('#9: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); x[2] === 5. Actual: ' + (x[2])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.5_T1.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.5_T1.js new file mode 100644 index 0000000000..7819ebeb2f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.5_T1.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Splice with undefined arguments +esid: sec-array.prototype.splice +description: start === undefined, end === undefined +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(undefined, undefined); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x.length !== 4) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); x.length === 4. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); x[1] === 1. Actual: ' + (x[1])); +} + +if (x[2] !== 2) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); x[2] === 2. Actual: ' + (x[2])); +} + +if (x[3] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); x[3] === 3. Actual: ' + (x[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.5_T2.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.5_T2.js new file mode 100644 index 0000000000..f53fab64b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.5_T2.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Splice with undefined arguments +esid: sec-array.prototype.splice +description: end === undefined +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(1, undefined); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(1,undefined); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(1,undefined); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x.length !== 4) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(1,undefined); x.length === 4. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(1,undefined); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(1,undefined); x[1] === 1. Actual: ' + (x[1])); +} + +if (x[2] !== 2) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(1,undefined); x[2] === 2. Actual: ' + (x[2])); +} + +if (x[3] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(1,undefined); x[3] === 3. Actual: ' + (x[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T1.js new file mode 100644 index 0000000000..eaab7b5b11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T1.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.splice +description: start is not integer +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(1.5, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 1) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr[0] === 1. Actual: ' + (arr[0])); +} + +if (arr[1] !== 2) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr[1] === 2. Actual: ' + (arr[1])); +} + +if (arr[2] !== 3) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr[2] === 3. Actual: ' + (arr[2])); +} + +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(1.5,3); x.length === 1. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(1.5,3); x[0] === 0. Actual: ' + (x[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T2.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T2.js new file mode 100644 index 0000000000..ad657a6c37 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T2.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.splice +description: start = NaN +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(NaN, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(NaN,3); x.length === 1. Actual: ' + (x.length)); +} + +if (x[0] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(NaN,3); x[0] === 3. Actual: ' + (x[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T3.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T3.js new file mode 100644 index 0000000000..0940f78ef5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T3.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.splice +description: start = Infinity +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(Number.POSITIVE_INFINITY, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(Number.POSITIVE_INFINITY,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(Number.POSITIVE_INFINITY,3); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var x = x.splice(Number.POSITIVE_INFINITY,3); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var x = x.splice(Number.POSITIVE_INFINITY,3); x[1] === 1. Actual: ' + (x[1])); +} + +if (x[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var x = x.splice(Number.POSITIVE_INFINITY,3); x[2] === 2. Actual: ' + (x[2])); +} + +if (x[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var x = x.splice(Number.POSITIVE_INFINITY,3); x[3] === 3. Actual: ' + (x[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T4.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T4.js new file mode 100644 index 0000000000..50ce7b402a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T4.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.splice +description: start = -Infinity +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(Number.NEGATIVE_INFINITY, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); x.length === 1. Actual: ' + (x.length)); +} + +if (x[0] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); x[0] === 3. Actual: ' + (x[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T5.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T5.js new file mode 100644 index 0000000000..c4d40fc370 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T5.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.splice +description: ToInteger use ToNumber +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice({ + valueOf: function() { + return 0 + }, + toString: function() { + return 3 + } +}, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice({valueOf: function() {return 0}, toString: function() {return 3}},3); x.length === 1. Actual: ' + (x.length)); +} + +if (x[0] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice({valueOf: function() {return 0}, toString: function() {return 3}},3); x[0] === 3. Actual: ' + (x[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T1.js new file mode 100644 index 0000000000..81ab211c69 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T1.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from deleteCount +esid: sec-array.prototype.splice +description: deleteCount is not integer +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(1, 3.5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 1) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr[0] === 1. Actual: ' + (arr[0])); +} + +if (arr[1] !== 2) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr[1] === 2. Actual: ' + (arr[1])); +} + +if (arr[2] !== 3) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr[2] === 3. Actual: ' + (arr[2])); +} + +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(1,3.5); x.length === 1. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(1,3.5); x[0] === 0. Actual: ' + (x[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T2.js new file mode 100644 index 0000000000..735374b032 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T2.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from deleteCount +esid: sec-array.prototype.splice +description: deleteCount = NaN +---*/ + +var x = [0, 1]; +var arr = x.splice(0, NaN); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(0,NaN); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(0,NaN); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x.length !== 2) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(0,NaN); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(0,NaN); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(0,NaN); x[1] === 1. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T3.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T3.js new file mode 100644 index 0000000000..26b991deda --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T3.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from deleteCount +esid: sec-array.prototype.splice +description: deleteCount = Infinity +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(0, Number.POSITIVE_INFINITY); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 4) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr.length === 4. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr[3] === 3. Actual: ' + (arr[3])); +} + +if (x.length !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); x.length === 0. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T4.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T4.js new file mode 100644 index 0000000000..a644625c90 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T4.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from deleteCount +esid: sec-array.prototype.splice +description: deleteCount = -Infinity +---*/ + +var x = [0, 1]; +var arr = x.splice(0, Number.NEGATIVE_INFINITY); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(0,Number.NEGATIVE_INFINITY); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(0,Number.NEGATIVE_INFINITY); arr.length === 0. Actual: ' + (arr.length)); +} + +if (x.length !== 2) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(0,Number.NEGATIVE_INFINITY); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(0,Number.NEGATIVE_INFINITY); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(0,Number.NEGATIVE_INFINITY); x[1] === 1. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T5.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T5.js new file mode 100644 index 0000000000..94c5ddcb73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T5.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToInteger from deleteCount +esid: sec-array.prototype.splice +description: ToInteger use ToNumber +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(0, { + valueOf: function() { + return 3 + }, + toString: function() { + return 0 + } +}); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); x.length === 1. Actual: ' + (x.length)); +} + +if (x[0] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); x[0] === 3. Actual: ' + (x[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T1.js new file mode 100644 index 0000000000..dfaffa9409 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T1.js @@ -0,0 +1,65 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The splice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.splice +description: > + If start is positive, use min(start, length). If deleteCount is + positive, use min(deleteCount, length - start) +---*/ + +var obj = { + 0: 0, + 1: 1, + 2: 2, + 3: 3 +}; +obj.length = 4; +obj.splice = Array.prototype.splice; +var arr = obj.splice(0, 3, 4, 5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(0,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(0,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(0,3,4,5); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(0,3,4,5); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(0,3,4,5); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (obj.length !== 3) { + throw new Test262Error('#6: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(0,3,4,5); obj.length === 3. Actual: ' + (obj.length)); +} + +if (obj[0] !== 4) { + throw new Test262Error('#7: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(0,3,4,5); obj[0] === 4. Actual: ' + (obj[0])); +} + +if (obj[1] !== 5) { + throw new Test262Error('#8: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(0,3,4,5); obj[1] === 5. Actual: ' + (obj[1])); +} + +if (obj[2] !== 3) { + throw new Test262Error('#9: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(0,3,4,5); obj[2] === 3. Actual: ' + (obj[2])); +} + +if (obj[3] !== undefined) { + throw new Test262Error('#10: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(0,3,4,5); obj[3] === undefined. Actual: ' + (obj[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T2.js new file mode 100644 index 0000000000..1bb4505470 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T2.js @@ -0,0 +1,55 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The splice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.splice +description: > + If start is negative, use max(start + length, 0). If deleteCount + is negative, use 0 +---*/ + +var obj = { + 0: 0, + 1: 1 +}; +obj.length = 2; +obj.splice = Array.prototype.splice; +var arr = obj.splice(-2, -1, 2, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(-2,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#1: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(-2,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} + +if (obj.length !== 4) { + throw new Test262Error('#2: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(-2,-1,2,3); obj.length === 4. Actual: ' + (obj.length)); +} + +if (obj[0] !== 2) { + throw new Test262Error('#3: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(-2,-1,2,3); obj[0] === 2. Actual: ' + (obj[0])); +} + +if (obj[1] !== 3) { + throw new Test262Error('#4: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(-2,-1,2,3); obj[1] === 3. Actual: ' + (obj[1])); +} + +if (obj[2] !== 0) { + throw new Test262Error('#5: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(-2,-1,2,3); obj[2] === 0. Actual: ' + (obj[2])); +} + +if (obj[3] !== 1) { + throw new Test262Error('#6: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(-2,-1,2,3); obj[3] === 1. Actual: ' + (obj[3])); +} + +if (obj[4] !== undefined) { + throw new Test262Error('#7: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(-2,-1,2,3); obj[4] === undefined. Actual: ' + (obj[4])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T3.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T3.js new file mode 100644 index 0000000000..b884daa1e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T3.js @@ -0,0 +1,55 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The splice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.splice +description: > + If start is positive, use min(start, length). If deleteCount is + negative, use 0 +---*/ + +var obj = { + 0: 0, + 1: 1 +}; +obj.length = 2; +obj.splice = Array.prototype.splice; +var arr = obj.splice(0, -1, 2, 3); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(0,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 0) { + throw new Test262Error('#1: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(0,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} + +if (obj.length !== 4) { + throw new Test262Error('#2: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(0,-1,2,3); obj.length === 4. Actual: ' + (obj.length)); +} + +if (obj[0] !== 2) { + throw new Test262Error('#3: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(0,-1,2,3); obj[0] === 2. Actual: ' + (obj[0])); +} + +if (obj[1] !== 3) { + throw new Test262Error('#4: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(0,-1,2,3); obj[1] === 3. Actual: ' + (obj[1])); +} + +if (obj[2] !== 0) { + throw new Test262Error('#5: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(0,-1,2,3); obj[2] === 0. Actual: ' + (obj[2])); +} + +if (obj[3] !== 1) { + throw new Test262Error('#6: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(0,-1,2,3); obj[3] === 1. Actual: ' + (obj[3])); +} + +if (obj[4] !== undefined) { + throw new Test262Error('#7: var obj = {0:0,1:1}; obj.length = 2; obj.splice = Array.prototype.splice; var arr = obj.splice(0,-1,2,3); obj[4] === undefined. Actual: ' + (obj[4])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T4.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T4.js new file mode 100644 index 0000000000..b1c9b0a171 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T4.js @@ -0,0 +1,65 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The splice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.splice +description: > + If start is negative, use max(start + length, 0). If deleteCount + is positive, use min(deleteCount, length - start) +---*/ + +var obj = { + 0: 0, + 1: 1, + 2: 2, + 3: 3 +}; +obj.length = 4; +obj.splice = Array.prototype.splice; +var arr = obj.splice(-4, 3, 4, 5); + +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(-4,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(-4,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} + +if (arr[0] !== 0) { + throw new Test262Error('#3: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(-4,3,4,5); arr[0] === 0. Actual: ' + (arr[0])); +} + +if (arr[1] !== 1) { + throw new Test262Error('#4: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(-4,3,4,5); arr[1] === 1. Actual: ' + (arr[1])); +} + +if (arr[2] !== 2) { + throw new Test262Error('#5: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(-4,3,4,5); arr[2] === 2. Actual: ' + (arr[2])); +} + +if (obj.length !== 3) { + throw new Test262Error('#6: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(-4,3,4,5); obj.length === 3. Actual: ' + (obj.length)); +} + +if (obj[0] !== 4) { + throw new Test262Error('#7: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(-4,3,4,5); obj[0] === 4. Actual: ' + (obj[0])); +} + +if (obj[1] !== 5) { + throw new Test262Error('#8: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(-4,3,4,5); obj[1] === 5. Actual: ' + (obj[1])); +} + +if (obj[2] !== 3) { + throw new Test262Error('#9: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(-4,3,4,5); obj[2] === 3. Actual: ' + (obj[2])); +} + +if (obj[3] !== undefined) { + throw new Test262Error('#10: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = Array.prototype.splice; var arr = obj.splice(-4,3,4,5); obj[3] === undefined. Actual: ' + (obj[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A3_T1.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A3_T1.js new file mode 100644 index 0000000000..50ae36021e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A3_T1.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.splice +description: length is arbitrarily +---*/ + +var obj = {}; +obj.splice = Array.prototype.splice; +obj[0] = "x"; +obj[4294967295] = "y"; +obj.length = 4294967296; +var arr = obj.splice(4294967295, 1); + +if (arr.length !== 1) { + throw new Test262Error('#1: var obj = {}; obj.splice = Array.prototype.splice; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; var arr = obj.splice(4294967295,1); arr.length === 1. Actual: ' + (arr.length)); +} + +if (obj.length !== 4294967295) { + throw new Test262Error('#2: var obj = {}; obj.splice = Array.prototype.splice; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; var arr = obj.splice(4294967295,1); obj.length === 4294967295. Actual: ' + (obj.length)); +} + +if (obj[0] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.splice = Array.prototype.splice; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; var arr = obj.splice(4294967295,1); obj[0] === "x". Actual: ' + (obj[0])); +} + +if (obj[4294967295] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.splice = Array.prototype.splice; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; var arr = obj.splice(4294967295,1); obj[4294967295] === undefined. Actual: ' + (obj[4294967295])); +} + +if (arr[0] !== "y") { + throw new Test262Error('#5: var obj = {}; obj.splice = Array.prototype.splice; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; var arr = obj.splice(4294967295,1); arr[0] === "y". Actual: ' + (arr[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A3_T3.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A3_T3.js new file mode 100644 index 0000000000..89591be5df --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A3_T3.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.splice +description: length is arbitrarily +---*/ + +var obj = {}; +obj.splice = Array.prototype.splice; +obj[4294967294] = "x"; +obj.length = -1; +var arr = obj.splice(4294967294, 1); + +if (arr.length !== 0) { + throw new Test262Error('#1: var obj = {}; obj.splice = Array.prototype.splice; obj[4294967294] = "x"; obj.length = -1; var arr = obj.splice(4294967294,1); arr.length === 0. Actual: ' + (arr.length)); +} + +if (arr[0] !== undefined) { + throw new Test262Error('#2: var obj = {}; obj.splice = Array.prototype.splice; obj[4294967294] = "x"; obj.length = 1; var arr = obj.splice(4294967294,1); arr[0] === undefined. Actual: ' + (arr[0])); +} + +if (obj.length !== 0) { + throw new Test262Error('#3: var obj = {}; obj.splice = Array.prototype.splice; obj[4294967294] = "x"; obj.length = 1; var arr = obj.splice(4294967294,1); obj.length === 0. Actual: ' + (obj.length)); +} + +if (obj[4294967294] !== "x") { + throw new Test262Error('#4: var obj = {}; obj.splice = Array.prototype.splice; obj[4294967294] = "x"; obj.length = 1; var arr = obj.splice(4294967294,1); obj[4294967294] === "x". Actual: ' + (obj[4294967294])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T1.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T1.js new file mode 100644 index 0000000000..212c097720 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T1.js @@ -0,0 +1,74 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]] from not an inherited property" +esid: sec-array.prototype.splice +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Array.prototype[1] = -1; +var x = [0, 1]; +var arr = x.splice(1, 1); + +if (arr.length !== 1) { + throw new Test262Error('#1: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); arr.length === 1. Actual: ' + (arr.length)); +} + +if (arr[0] !== 1) { + throw new Test262Error('#2: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); arr[0] === 1. Actual: ' + (arr[0])); +} + +if (arr[1] !== -1) { + throw new Test262Error('#3: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); arr[1] === -1. Actual: ' + (arr[1])); +} + +if (x.length !== 1) { + throw new Test262Error('#4: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); x.length === 1. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#5: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== -1) { + throw new Test262Error('#6: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); x[1] === -1. Actual: ' + (x[1])); +} + + +Object.prototype[1] = -1; +Object.prototype.length = 2; +Object.prototype.splice = Array.prototype.splice; +x = { + 0: 0, + 1: 1 +}; +var arr = x.splice(1, 1); + +if (arr.length !== 1) { + throw new Test262Error('#7: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = Array.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1); arr.length === 1. Actual: ' + (arr.length)); +} + +if (arr[0] !== 1) { + throw new Test262Error('#8: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = Array.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1); arr[0] === 1. Actual: ' + (arr[0])); +} + +if (arr[1] !== -1) { + throw new Test262Error('#9: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = Array.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1); arr[1] === -1. Actual: ' + (arr[1])); +} + +if (x.length !== 1) { + throw new Test262Error('#10: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = Array.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1); x.length === 1. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#11: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = Array.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== -1) { + throw new Test262Error('#12: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = Array.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1); x[1] === -1. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T2.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T2.js new file mode 100644 index 0000000000..e086d7f42e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T2.js @@ -0,0 +1,74 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]] from not an inherited property" +esid: sec-array.prototype.splice +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Array.prototype[1] = -1; +var x = [0, 1]; +var arr = x.splice(1, 1, 2); + +if (arr.length !== 1) { + throw new Test262Error('#1: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); arr.length === 1. Actual: ' + (arr.length)); +} + +if (arr[0] !== 1) { + throw new Test262Error('#2: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); arr[0] === 1. Actual: ' + (arr[0])); +} + +if (arr[1] !== -1) { + throw new Test262Error('#3: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); arr[1] === -1. Actual: ' + (arr[1])); +} + +if (x.length !== 2) { + throw new Test262Error('#4: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#5: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 2) { + throw new Test262Error('#6: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); x[1] === 2. Actual: ' + (x[1])); +} + + +Object.prototype[1] = -1; +Object.prototype.length = 2; +Object.prototype.splice = Array.prototype.splice; +x = { + 0: 0, + 1: 1 +}; +var arr = x.splice(1, 1, 2); + +if (arr.length !== 1) { + throw new Test262Error('#7: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = Array.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1,2); arr.length === 1. Actual: ' + (arr.length)); +} + +if (arr[0] !== 1) { + throw new Test262Error('#8: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = Array.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1,2); arr[0] === 1. Actual: ' + (arr[0])); +} + +if (arr[1] !== -1) { + throw new Test262Error('#9: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = Array.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1,2); arr[1] === -1. Actual: ' + (arr[1])); +} + +if (x.length !== 2) { + throw new Test262Error('#10: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = Array.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1,2); x.length === 2. Actual: ' + (x.length)); +} + +if (x[0] !== 0) { + throw new Test262Error('#11: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = Array.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1,2); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 2) { + throw new Test262Error('#12: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = Array.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1,2); x[1] === 2. Actual: ' + (x[1])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T3.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T3.js new file mode 100644 index 0000000000..e4ea0ce904 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T3.js @@ -0,0 +1,67 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]] from not an inherited property" +esid: sec-array.prototype.splice +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Array.prototype[0] = -1; +var x = []; +x.length = 1; +var arr = x.splice(0, 1); + +if (arr.length !== 1) { + throw new Test262Error('#1: Array.prototype[0] = -1; x = []; x.length = 1; var arr = x.splice(0,1); arr.length === 1. Actual: ' + (arr.length)); +} + +if (arr[0] !== -1) { + throw new Test262Error('#2: Array.prototype[0] = -1; x = []; x.length = 1; var arr = x.splice(0,1); arr[0] === -1. Actual: ' + (arr[0])); +} + +delete arr[0]; + +if (arr[0] !== -1) { + throw new Test262Error('#3: Array.prototype[0] = -1; x = []; x.length = 1; var arr = x.splice(0,1); delete arr[0]; arr[0] === -1. Actual: ' + (arr[0])); +} + +if (x.length !== 0) { + throw new Test262Error('#4: Array.prototype[0] = -1; x = []; x.length = 1; var arr = x.splice(0,1); x.length === 0. Actual: ' + (x.length)); +} + +if (x[0] !== -1) { + throw new Test262Error('#5: Array.prototype[0] = -1; x = []; x.length = 1; var arr = x.splice(0,1); x[0] === -1. Actual: ' + (x[0])); +} + +Object.prototype[0] = -1; +Object.prototype.length = 1; +Object.prototype.splice = Array.prototype.splice; +x = {}; +var arr = x.splice(0, 1); + +if (arr.length !== 1) { + throw new Test262Error('#6: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.splice = Array.prototype.splice; x = {}; var arr = x.splice(0,1); arr.length === 1. Actual: ' + (arr.length)); +} + +if (arr[0] !== -1) { + throw new Test262Error('#7: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.splice = Array.prototype.splice; x = {}; var arr = x.splice(0,1); arr[0] === -1. Actual: ' + (arr[0])); +} + +delete arr[0]; + +if (arr[0] !== -1) { + throw new Test262Error('#8: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.splice = Array.prototype.splice; x = {}; var arr = x.splice(0,1); delete arr[0]; arr[0] === -1. Actual: ' + (arr[0])); +} + +if (x.length !== 0) { + throw new Test262Error('#9: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.splice = Array.prototype.splice; x = {}; var arr = x.splice(0,1); x.length === 0. Actual: ' + (x.length)); +} + +if (x[0] !== -1) { + throw new Test262Error('#10: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.splice = Array.prototype.splice; x = {}; var arr = x.splice(0,1); x[0] === -1. Actual: ' + (x[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T1.js new file mode 100644 index 0000000000..55215f44f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T1.js @@ -0,0 +1,26 @@ +// Copyright 2014 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Array.prototype.splice sets `length` on `this` +esid: sec-array.prototype.splice +description: Array.prototype.splice sets `length` on Array +---*/ + +var a = [0, 1, 2]; + +a.splice(1, 2, 4); + +if (a.length !== 2) { + throw new Test262Error("Expected a.length === 2, actually " + a.length); +} + +if (a[0] !== 0) { + throw new Test262Error("Expected a[0] === 0, actually " + a[0]); +} + +if (a[1] !== 4) { + throw new Test262Error("Expected a[1] === 4, actually " + a[1]); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T2.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T2.js new file mode 100644 index 0000000000..a865a7bc78 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T2.js @@ -0,0 +1,20 @@ +// Copyright 2014 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Array.prototype.splice sets `length` on `this` +esid: sec-array.prototype.splice +description: Array.prototype.splice throws if `length` is read-only +---*/ + +var a = [0, 1, 2]; + +Object.defineProperty(a, 'length', { + writable: false +}); + +assert.throws(TypeError, function() { + a.splice(1, 2, 4); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T3.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T3.js new file mode 100644 index 0000000000..9a6823e058 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T3.js @@ -0,0 +1,26 @@ +// Copyright 2014 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Array.prototype.splice sets `length` on `this` +esid: sec-array.prototype.splice +description: Array.prototype.splice throws if `length` is read-only +---*/ + +var a = { + get length() { + return 0; + }, + splice: Array.prototype.splice +}; + +try { + a.splice(1, 2, 4); + throw new Test262Error("Expected a TypeError"); +} catch (e) { + if (!(e instanceof TypeError)) { + throw e; + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/browser.js b/js/src/tests/test262/built-ins/Array/prototype/splice/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/splice/call-with-boolean.js new file mode 100644 index 0000000000..c12f3ff2fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/call-with-boolean.js @@ -0,0 +1,13 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: Array.prototype.splice applied to boolean primitive +includes: [compareArray.js] +---*/ + +assert.compareArray(Array.prototype.splice.call(true), [], 'Array.prototype.splice.call(true) must return []'); +assert.compareArray(Array.prototype.splice.call(false), [], 'Array.prototype.splice.call(false) must return []'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/called_with_one_argument.js b/js/src/tests/test262/built-ins/Array/prototype/splice/called_with_one_argument.js new file mode 100644 index 0000000000..0aa1280c22 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/called_with_one_argument.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Array.prototype.splice deletes length-start elements when called with one argument +info: | + 22.1.3.25 Array.prototype.splice (start, deleteCount , ...items ) + + ... + 9. Else if the number of actual arguments is 1, then + a. Let insertCount be 0. + b. Let actualDeleteCount be len – actualStart. +esid: sec-array.prototype.splice +---*/ + +var array = ["first", "second", "third"]; + +var result = array.splice(1); + +assert.sameValue(array.length, 1, "array length updated"); +assert.sameValue(array[0], "first", "array[0] unchanged"); + +assert.sameValue(result.length, 2, "result array length correct"); +assert.sameValue(result[0], "second", "result[0] correct"); +assert.sameValue(result[1], "third", "result[1] correct"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/clamps-length-to-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/splice/clamps-length-to-integer-limit.js new file mode 100644 index 0000000000..e6c7b1d5ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/clamps-length-to-integer-limit.js @@ -0,0 +1,39 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + Length values exceeding 2^53-1 are clamped to 2^53-1. +info: | + 1. ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... + 5. If the number of actual arguments is 0, then + a. Let insertCount be 0. + b. Let actualDeleteCount be 0. + ... + 19. Perform ? Set(O, "length", len - actualDeleteCount + itemCount, true). + ... +features: [exponentiation] +---*/ + +var arrayLike = {}; + +arrayLike.length = 2 ** 53 - 1; +Array.prototype.splice.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53 - 1"); + +arrayLike.length = 2 ** 53; +Array.prototype.splice.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53"); + +arrayLike.length = 2 ** 53 + 2; +Array.prototype.splice.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53 + 2"); + +arrayLike.length = Infinity; +Array.prototype.splice.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-ctor-non-object.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-ctor-non-object.js new file mode 100644 index 0000000000..6b1532fd96 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-ctor-non-object.js @@ -0,0 +1,45 @@ +// 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-array.prototype.splice +description: > + Behavior when `constructor` property is neither an Object nor undefined +info: | + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 9. If IsConstructor(C) is false, throw a TypeError exception. +---*/ + +var a = []; + +a.constructor = null; +assert.throws(TypeError, function() { + a.splice(); +}, 'null value'); + +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.splice(); +}, 'number value'); + +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.splice(); +}, 'string value'); + +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.splice(); +}, 'boolean value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-ctor-poisoned.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-ctor-poisoned.js new file mode 100644 index 0000000000..4ce1a38809 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-ctor-poisoned.js @@ -0,0 +1,29 @@ +// 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-array.prototype.splice +description: Abrupt completion from `constructor` property access +info: | + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). +---*/ + +var a = []; + +Object.defineProperty(a, 'constructor', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + a.splice(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-non-array-invalid-len.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-non-array-invalid-len.js new file mode 100644 index 0000000000..012abb566a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-non-array-invalid-len.js @@ -0,0 +1,44 @@ +// 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-array.prototype.splice +description: Abrupt completion from creating a new array +info: | + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). + + 9.4.2.2 ArrayCreate + + [...] + 3. If length>232-1, throw a RangeError exception. +---*/ + +var callCount = 0; +var maxLength = Math.pow(2, 32); +var obj = Object.defineProperty({}, 'length', { + get: function() { + return maxLength; + }, + set: function() { + callCount += 1; + } +}); + +assert.throws(RangeError, function() { + Array.prototype.splice.call(obj, 0); +}); + +assert.sameValue( + callCount, + 0, + 'RangeError thrown during array creation, not property modification' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-non-array.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-non-array.js new file mode 100644 index 0000000000..aaee6cf7f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-non-array.js @@ -0,0 +1,36 @@ +// 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-array.prototype.splice +description: Constructor is ignored for non-Array values +info: | + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). +---*/ + +var obj = { + length: 0 +}; +var callCount = 0; +var result; +Object.defineProperty(obj, 'constructor', { + get: function() { + callCount += 1; + } +}); + +result = Array.prototype.splice.call(obj); + +assert.sameValue(callCount, 0, '`constructor` property not accessed'); +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert(Array.isArray(result), 'result is an Array exotic object'); +assert.sameValue(result.length, 0, 'array created with appropriate length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-proto-from-ctor-realm-array.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-proto-from-ctor-realm-array.js new file mode 100644 index 0000000000..839397f8b0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-proto-from-ctor-realm-array.js @@ -0,0 +1,45 @@ +// 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-array.prototype.splice +description: Prefer Array constructor of current realm record +info: | + 1. Let O be ? ToObject(this value). + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C + be undefined. + [...] +features: [cross-realm, Symbol.species] +---*/ + +var array = []; +var callCount = 0; +var OArray = $262.createRealm().global.Array; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OArray; + +Object.defineProperty(Array, Symbol.species, speciesDesc); +Object.defineProperty(OArray, Symbol.species, speciesDesc); + +result = array.splice(); + +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert.sameValue(callCount, 0, 'Species constructor is not referenced'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-proto-from-ctor-realm-non-array.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-proto-from-ctor-realm-non-array.js new file mode 100644 index 0000000000..bebe39d151 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-proto-from-ctor-realm-non-array.js @@ -0,0 +1,46 @@ +// 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-array.prototype.splice +description: Accept non-Array constructors from other realms +info: | + 1. Let O be ? ToObject(this value). + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C + be undefined. + [...] +features: [cross-realm, Symbol.species] +---*/ + +var array = []; +var callCount = 0; +var CustomCtor = function() {}; +var OObject = $262.createRealm().global.Object; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OObject; +OObject[Symbol.species] = CustomCtor; + +Object.defineProperty(Array, Symbol.species, speciesDesc); + +result = array.splice(); + +assert.sameValue(Object.getPrototypeOf(result), CustomCtor.prototype); +assert.sameValue(callCount, 0, 'Array species constructor is not referenced'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-proxy.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-proxy.js new file mode 100644 index 0000000000..f22f821633 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-proxy.js @@ -0,0 +1,41 @@ +// 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-array.prototype.splice +description: Species constructor of a Proxy object whose target is an array +info: | + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + 20. Return A. + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + + 7.2.2 IsArray + + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is + null, throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy, Symbol.species] +---*/ + +var array = []; +var proxy = new Proxy(new Proxy(array, {}), {}); +var Ctor = function() {}; +var result; + +array.constructor = function() {}; +array.constructor[Symbol.species] = Ctor; + +result = Array.prototype.splice.call(proxy); + +assert.sameValue(Object.getPrototypeOf(result), Ctor.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-revoked-proxy.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-revoked-proxy.js new file mode 100644 index 0000000000..aa4e45413c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-revoked-proxy.js @@ -0,0 +1,41 @@ +// 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-array.prototype.splice +description: Abrupt completion from constructor that is a revoked Proxy object +info: | + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 3. Let isArray be ? IsArray(originalArray). + + 7.2.2 IsArray + + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is + null, throw a TypeError exception. +features: [Proxy] +---*/ + +var o = Proxy.revocable([], {}); +var callCount = 0; + +Object.defineProperty(o.proxy, 'constructor', { + get: function() { + callCount += 1; + } +}); +o.revoke(); + +assert.throws(TypeError, function() { + Array.prototype.splice.call(o.proxy); +}); + +assert.sameValue(callCount, 0, '`constructor` property not accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-abrupt.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-abrupt.js new file mode 100644 index 0000000000..175da23d56 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-abrupt.js @@ -0,0 +1,35 @@ +// 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-array.prototype.splice +description: Species constructor returns an abrupt completion +info: | + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var Ctor = function() { + throw new Test262Error(); +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; + +assert.throws(Test262Error, function() { + a.splice(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-length-exceeding-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-length-exceeding-integer-limit.js new file mode 100644 index 0000000000..7342344462 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-length-exceeding-integer-limit.js @@ -0,0 +1,91 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + Create species constructor with length exceeding integer limit and ensure MOP + operations are called in correct order. +info: | + ... + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + 10. Let k be 0. + 11. Repeat, while k < actualDeleteCount + a. Let from be ! ToString(actualStart+k). + b. Let fromPresent be ? HasProperty(O, from). + c. If fromPresent is true, then + i. Let fromValue be ? Get(O, from). + ii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(k), fromValue). + d. Increment k by 1. + 12. Perform ? Set(A, "length", actualDeleteCount, true). + ... +includes: [compareArray.js, proxyTrapsHelper.js] +features: [Symbol.species, exponentiation] +---*/ + +function StopSplice() {} + +var traps = []; +var targetLength; + +var array = ["no-hole", /* hole */ , "stop"]; +array.constructor = { + [Symbol.species]: function(n) { + targetLength = n; + return target; + } +}; + +var source = new Proxy(array, allowProxyTraps({ + get(t, pk, r) { + traps.push(`source.[[Get]]:${String(pk)}`); + + // length property exceeding 2^53-1. + if (pk === "length") + return 2 ** 53 + 2; + + return Reflect.get(t, pk, r); + }, + has(t, pk, r) { + traps.push(`source.[[Has]]:${String(pk)}`); + + return Reflect.get(t, pk, r); + }, +})); + +var target = new Proxy([], allowProxyTraps({ + defineProperty(t, pk, desc) { + traps.push(`target.[[DefineProperty]]:${String(pk)}`); + + if (pk === "0" || pk === "1") + return Reflect.defineProperty(t, pk, desc); + + throw new StopSplice(); + } +})); + +assert.throws(StopSplice, function() { + // deleteCount argument exceeding 2^53-1. + Array.prototype.splice.call(source, 0, 2 ** 53 + 4); +}, '// deleteCount argument exceeding 2^53-1. Array.prototype.splice.call(source, 0, 2 ** 53 + 4) throws a StopSplice exception'); + +assert.sameValue(targetLength, 2 ** 53 - 1, + 'The value of targetLength is expected to be 2 ** 53 - 1'); + +assert.compareArray(traps, [ + "source.[[Get]]:length", + + "source.[[Get]]:constructor", + + "source.[[Has]]:0", + "source.[[Get]]:0", + "target.[[DefineProperty]]:0", + + "source.[[Has]]:1", + + "source.[[Has]]:2", + "source.[[Get]]:2", + "target.[[DefineProperty]]:2", +], 'The value of traps is expected to be [\n "source.[[Get]]:length",\n\n "source.[[Get]]:constructor",\n\n "source.[[Has]]:0",\n "source.[[Get]]:0",\n "target.[[DefineProperty]]:0",\n\n "source.[[Has]]:1",\n\n "source.[[Has]]:2",\n "source.[[Get]]:2",\n "target.[[DefineProperty]]:2",\n]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-neg-zero.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-neg-zero.js new file mode 100644 index 0000000000..9974cc03ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-neg-zero.js @@ -0,0 +1,51 @@ +// 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-array.prototype.splice +description: The value `-0` is converted to `0` +info: | + [...] + 3. Let relativeStart be ? ToInteger(start). + 4. If relativeStart < 0, let actualStart be max((len + relativeStart), 0); + else let actualStart be min(relativeStart, len). + 5. If the number of actual arguments is 0, then + [...] + 6. Else if the number of actual arguments is 1, then + [...] + 7. Else, + a. Let insertCount be the number of actual arguments minus 2. + b. Let dc be ? ToInteger(deleteCount). + c. Let actualDeleteCount be min(max(dc, 0), len - actualStart). + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 2. If length is -0, let length be +0. + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var args; +var Ctor = function() { + args = arguments; +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; + +a.splice(0, -0); + +assert.sameValue(args.length, 1); +assert.sameValue(args[0], 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-non-ctor.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-non-ctor.js new file mode 100644 index 0000000000..826fe92b14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-non-ctor.js @@ -0,0 +1,41 @@ +// 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-array.prototype.splice +description: > + Behavior when the @@species attribute is a non-constructor object +info: | + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 9. If IsConstructor(C) is false, throw a TypeError exception. +includes: [isConstructor.js] +features: [Symbol.species, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(parseInt), + false, + 'precondition: isConstructor(parseInt) must return false' +); + +var a = []; + +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; + +assert.throws(TypeError, function() { + a.splice(); +}, 'a.splice() throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-null.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-null.js new file mode 100644 index 0000000000..e734720df4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-null.js @@ -0,0 +1,35 @@ +// 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-array.prototype.splice +description: > + A null value for the @@species constructor is interpreted as `undefined` +info: | + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). +features: [Symbol.species] +---*/ + +var a = []; +var result; + +a.constructor = {}; +a.constructor[Symbol.species] = null; + +result = a.splice(); + +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert(Array.isArray(result), 'result is an Array exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-poisoned.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-poisoned.js new file mode 100644 index 0000000000..5cbeabce3a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-poisoned.js @@ -0,0 +1,34 @@ +// 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-array.prototype.splice +description: Abrupt completion from `@@species` property access +info: | + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). +features: [Symbol.species] +---*/ + +var a = []; +a.constructor = {}; + +Object.defineProperty(a.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + a.splice(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-undef-invalid-len.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-undef-invalid-len.js new file mode 100644 index 0000000000..6175d7be6b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-undef-invalid-len.js @@ -0,0 +1,56 @@ +// 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-array.prototype.splice +description: > + An undefined value for the @@species constructor triggers the creation of + an Array exotic object +info: | + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). + + 9.4.2.2 ArrayCreate + + [...] + 3. If length>232-1, throw a RangeError exception. +features: [Proxy] +---*/ + +var array = []; +var maxLength = Math.pow(2, 32); +var callCount = 0; +var proxy = new Proxy(array, { + get: function(_, name) { + if (name === 'length') { + return maxLength; + } + return array[name]; + }, + set: function() { + callCount += 1; + return true; + } +}); + +assert.throws(RangeError, function() { + Array.prototype.splice.call(proxy, 0); +}); + +assert.sameValue( + callCount, + 0, + 'RangeError thrown during array creation, not property modification' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-undef.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-undef.js new file mode 100644 index 0000000000..d96d50decf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-undef.js @@ -0,0 +1,36 @@ +// 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-array.prototype.splice +description: > + An undefined value for the @@species constructor triggers the creation of + an Array exotic object +info: | + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). +features: [Symbol.species] +---*/ + +var a = []; +var result; + +a.constructor = {}; +a.constructor[Symbol.species] = undefined; + +result = a.splice(); + +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert(Array.isArray(result), 'result is an Array exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/create-species.js b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species.js new file mode 100644 index 0000000000..c6ea6483a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species.js @@ -0,0 +1,45 @@ +// 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-array.prototype.splice +description: Species constructor is used to create a new instance +info: | + [...] + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var thisValue, args, result; +var callCount = 0; +var instance = []; +var Ctor = function() { + callCount += 1; + thisValue = this; + args = arguments; + return instance; +}; +var a = [1, 2, 3, 4, 5]; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; + +result = a.splice(2); + +assert.sameValue(callCount, 1, 'Constructor invoked exactly once'); +assert.sameValue(Object.getPrototypeOf(thisValue), Ctor.prototype); +assert.sameValue(args.length, 1, 'Constructor invoked with a single argument'); +assert.sameValue(args[0], 3); +assert.sameValue(result, instance); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/length-and-deleteCount-exceeding-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/splice/length-and-deleteCount-exceeding-integer-limit.js new file mode 100644 index 0000000000..1436e7f162 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/length-and-deleteCount-exceeding-integer-limit.js @@ -0,0 +1,57 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + Length and deleteCount are both clamped to 2^53-1 when they exceed the integer limit. +info: | + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... + 7. Else, + a. Let insertCount be the number of actual arguments minus 2. + b. Let dc be ? ToInteger(deleteCount). + c. Let actualDeleteCount be min(max(dc, 0), len - actualStart). + ... + 11. Repeat, while k < actualDeleteCount + a. Let from be ! ToString(actualStart+k). + b. Let fromPresent be ? HasProperty(O, from). + c. If fromPresent is true, then + i. Let fromValue be ? Get(O, from). + ii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(k), fromValue). + d. Increment k by 1. + ... +includes: [compareArray.js] +features: [exponentiation] +---*/ + +var arrayLike = { + "9007199254740988": "9007199254740988", + "9007199254740989": "9007199254740989", + "9007199254740990": "9007199254740990", + "9007199254740991": "9007199254740991", + length: 2 ** 53 + 2, +}; + +var result = Array.prototype.splice.call(arrayLike, 9007199254740989, 2 ** 53 + 4); + +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + 'The value of result is expected to be ["9007199254740989", "9007199254740990"]'); + +assert.sameValue(arrayLike.length, 2 ** 53 - 3, + 'The value of arrayLike.length is expected to be 2 ** 53 - 3'); + +assert.sameValue(arrayLike["9007199254740988"], "9007199254740988", + 'The value of arrayLike["9007199254740988"] is expected to be "9007199254740988"'); + +assert.sameValue("9007199254740989" in arrayLike, false, + 'The result of evaluating ("9007199254740989" in arrayLike) is expected to be false'); + +assert.sameValue("9007199254740990" in arrayLike, false, + 'The result of evaluating ("9007199254740990" in arrayLike) is expected to be false'); + +assert.sameValue(arrayLike["9007199254740991"], "9007199254740991", + 'The value of arrayLike["9007199254740991"] is expected to be "9007199254740991"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/length-exceeding-integer-limit-shrink-array.js b/js/src/tests/test262/built-ins/Array/prototype/splice/length-exceeding-integer-limit-shrink-array.js new file mode 100644 index 0000000000..cd3420ae11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/length-exceeding-integer-limit-shrink-array.js @@ -0,0 +1,67 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + An element is removed from an array-like object whose length exceeds the integer limit. +info: | + ... + 15. If itemCount < actualDeleteCount, then + a. Let k be actualStart. + b. Repeat, while k < (len - actualDeleteCount) + i. Let from be ! ToString(k+actualDeleteCount). + ii. Let to be ! ToString(k+itemCount). + iii. Let fromPresent be ? HasProperty(O, from). + iv. If fromPresent is true, then + 1. Let fromValue be ? Get(O, from). + 2. Perform ? Set(O, to, fromValue, true). + v. Else fromPresent is false, + 1. Perform ? DeletePropertyOrThrow(O, to). + vi. Increase k by 1. + c. Let k be len. + d. Repeat, while k > (len - actualDeleteCount + itemCount) + i. Perform ? DeletePropertyOrThrow(O, ! ToString(k-1)). + ii. Decrease k by 1. + ... +includes: [compareArray.js] +features: [exponentiation] +---*/ + +var arrayLike = { + "9007199254740986": "9007199254740986", + "9007199254740987": "9007199254740987", + "9007199254740988": "9007199254740988", + /* "9007199254740989": hole */ + "9007199254740990": "9007199254740990", + "9007199254740991": "9007199254740991", + length: 2 ** 53 + 2, +}; + +var result = Array.prototype.splice.call(arrayLike, 9007199254740987, 1); + +assert.compareArray(result, ["9007199254740987"], + 'The value of result is expected to be ["9007199254740987"]'); + +assert.sameValue(arrayLike.length, 2 ** 53 - 2, + 'The value of arrayLike.length is expected to be 2 ** 53 - 2'); + +assert.sameValue(arrayLike["9007199254740986"], "9007199254740986", + 'The value of arrayLike["9007199254740986"] is expected to be "9007199254740986"'); + +assert.sameValue(arrayLike["9007199254740987"], "9007199254740988", + 'The value of arrayLike["9007199254740987"] is expected to be "9007199254740988"'); + +assert.sameValue("9007199254740988" in arrayLike, false, + 'The result of evaluating ("9007199254740988" in arrayLike) is expected to be false'); + +assert.sameValue(arrayLike["9007199254740989"], "9007199254740990", + 'The value of arrayLike["9007199254740989"] is expected to be "9007199254740990"'); + +assert.sameValue("9007199254740990" in arrayLike, false, + 'The result of evaluating ("9007199254740990" in arrayLike) is expected to be false'); + +assert.sameValue(arrayLike["9007199254740991"], "9007199254740991", + 'The value of arrayLike["9007199254740991"] is expected to be "9007199254740991"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/length-near-integer-limit-grow-array.js b/js/src/tests/test262/built-ins/Array/prototype/splice/length-near-integer-limit-grow-array.js new file mode 100644 index 0000000000..1f731912e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/length-near-integer-limit-grow-array.js @@ -0,0 +1,65 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + A value is inserted in an array-like object whose length property is near the integer limit. +info: | + ... + 16. Else if itemCount > actualDeleteCount, then + a. Let k be (len - actualDeleteCount). + b. Repeat, while k > actualStart + i. Let from be ! ToString(k + actualDeleteCount - 1). + ii. Let to be ! ToString(k + itemCount - 1). + iii. Let fromPresent be ? HasProperty(O, from). + iv. If fromPresent is true, then + 1. Let fromValue be ? Get(O, from). + 2. Perform ? Set(O, to, fromValue, true). + v. Else fromPresent is false, + 1. Perform ? DeletePropertyOrThrow(O, to). + vi. Decrease k by 1. + ... +includes: [compareArray.js] +features: [exponentiation] +---*/ + +var arrayLike = { + "9007199254740985": "9007199254740985", + "9007199254740986": "9007199254740986", + "9007199254740987": "9007199254740987", + /* "9007199254740988": hole */ + "9007199254740989": "9007199254740989", + /* "9007199254740990": empty */ + "9007199254740991": "9007199254740991", + length: 2 ** 53 - 2, +}; + +var result = Array.prototype.splice.call(arrayLike, 9007199254740986, 0, "new-value"); + +assert.compareArray(result, [], 'The value of result is expected to be []'); + +assert.sameValue(arrayLike.length, 2 ** 53 - 1, 'The value of arrayLike.length is expected to be 2 ** 53 - 1'); + +assert.sameValue(arrayLike["9007199254740985"], "9007199254740985", + 'The value of arrayLike["9007199254740985"] is expected to be "9007199254740985"'); + +assert.sameValue(arrayLike["9007199254740986"], "new-value", + 'The value of arrayLike["9007199254740986"] is expected to be "new-value"'); + +assert.sameValue(arrayLike["9007199254740987"], "9007199254740986", + 'The value of arrayLike["9007199254740987"] is expected to be "9007199254740986"'); + +assert.sameValue(arrayLike["9007199254740988"], "9007199254740987", + 'The value of arrayLike["9007199254740988"] is expected to be "9007199254740987"'); + +assert.sameValue("9007199254740989" in arrayLike, false, + 'The result of evaluating ("9007199254740989" in arrayLike) is expected to be false'); + +assert.sameValue(arrayLike["9007199254740990"], "9007199254740989", + 'The value of arrayLike["9007199254740990"] is expected to be "9007199254740989"'); + +assert.sameValue(arrayLike["9007199254740991"], "9007199254740991", + 'The value of arrayLike["9007199254740991"] is expected to be "9007199254740991"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/length.js b/js/src/tests/test262/built-ins/Array/prototype/splice/length.js new file mode 100644 index 0000000000..d701b42ae5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + The "length" property of Array.prototype.splice +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.splice.length, 2); + +verifyNotEnumerable(Array.prototype.splice, 'length'); +verifyNotWritable(Array.prototype.splice, 'length'); +verifyConfigurable(Array.prototype.splice, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/name.js b/js/src/tests/test262/built-ins/Array/prototype/splice/name.js new file mode 100644 index 0000000000..a0107f69c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + Array.prototype.splice.name is "splice". +info: | + Array.prototype.splice (start, deleteCount , ...items ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.splice.name, "splice"); + +verifyNotEnumerable(Array.prototype.splice, "name"); +verifyNotWritable(Array.prototype.splice, "name"); +verifyConfigurable(Array.prototype.splice, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/splice/not-a-constructor.js new file mode 100644 index 0000000000..674f869d3a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/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: > + Array.prototype.splice 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.splice), + false, + 'isConstructor(Array.prototype.splice) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.splice(); +}, '`new Array.prototype.splice()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/splice/prop-desc.js new file mode 100644 index 0000000000..f6608b1f85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + "splice" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.splice, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "splice"); +verifyWritable(Array.prototype, "splice"); +verifyConfigurable(Array.prototype, "splice"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/property-traps-order-with-species.js b/js/src/tests/test262/built-ins/Array/prototype/splice/property-traps-order-with-species.js new file mode 100644 index 0000000000..03436e9dca --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/property-traps-order-with-species.js @@ -0,0 +1,40 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + Ensure the correct property traps are called on the new array. +features: [Proxy, Symbol.species] +includes: [compareArray.js] +---*/ + +var log = []; + +var a = [0, 1]; +a.constructor = {}; + +a.constructor[Symbol.species] = function(len) { + return new Proxy(new Array(len), new Proxy({}, { + get(t, pk, r) { + log.push(pk); + } + })); +}; + +var r = a.splice(0); + +assert.compareArray([ + // Step 11.c.ii: CreateDataPropertyOrThrow(A, ! ToString(k), fromValue). + "defineProperty", + + // Step 11.c.ii: CreateDataPropertyOrThrow(A, ! ToString(k), fromValue). + "defineProperty", + + // Step 12: Perform ? Set(A, "length", actualDeleteCount, true). + "set", + "getOwnPropertyDescriptor", + "defineProperty", +], log); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/set_length_no_args.js b/js/src/tests/test262/built-ins/Array/prototype/splice/set_length_no_args.js new file mode 100644 index 0000000000..ee2153fde0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/set_length_no_args.js @@ -0,0 +1,36 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Array.prototype.splice sets length when called with no arguments +info: | + 22.1.3.25 Array.prototype.splice (start, deleteCount , ...items ) + + ... + 24. Let setStatus be Set(O, "length", len – actualDeleteCount + itemCount, true). + 25. ReturnIfAbrupt(setStatus). +esid: sec-array.prototype.splice +---*/ + +var getCallCount = 0, + setCallCount = 0; +var lengthValue; + +var obj = { + get length() { + getCallCount += 1; + return "0"; + }, + set length(v) { + setCallCount += 1; + lengthValue = v; + } +}; + +Array.prototype.splice.call(obj); + +assert.sameValue(getCallCount, 1, "Get('length') called exactly once"); +assert.sameValue(setCallCount, 1, "Set('length') called exactly once"); +assert.sameValue(lengthValue, 0, "Set('length') called with ToLength('0')"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/shell.js b/js/src/tests/test262/built-ins/Array/prototype/splice/shell.js new file mode 100644 index 0000000000..bc72493f03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/shell.js @@ -0,0 +1,33 @@ +// GENERATED, DO NOT EDIT +// file: proxyTrapsHelper.js +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Used to assert the correctness of object behavior in the presence + and context of Proxy objects. +defines: [allowProxyTraps] +---*/ + +function allowProxyTraps(overrides) { + function throwTest262Error(msg) { + return function () { throw new Test262Error(msg); }; + } + if (!overrides) { overrides = {}; } + return { + getPrototypeOf: overrides.getPrototypeOf || throwTest262Error('[[GetPrototypeOf]] trap called'), + setPrototypeOf: overrides.setPrototypeOf || throwTest262Error('[[SetPrototypeOf]] trap called'), + isExtensible: overrides.isExtensible || throwTest262Error('[[IsExtensible]] trap called'), + preventExtensions: overrides.preventExtensions || throwTest262Error('[[PreventExtensions]] trap called'), + getOwnPropertyDescriptor: overrides.getOwnPropertyDescriptor || throwTest262Error('[[GetOwnProperty]] trap called'), + has: overrides.has || throwTest262Error('[[HasProperty]] trap called'), + get: overrides.get || throwTest262Error('[[Get]] trap called'), + set: overrides.set || throwTest262Error('[[Set]] trap called'), + deleteProperty: overrides.deleteProperty || throwTest262Error('[[Delete]] trap called'), + defineProperty: overrides.defineProperty || throwTest262Error('[[DefineOwnProperty]] trap called'), + enumerate: throwTest262Error('[[Enumerate]] trap called: this trap has been removed'), + ownKeys: overrides.ownKeys || throwTest262Error('[[OwnPropertyKeys]] trap called'), + apply: overrides.apply || throwTest262Error('[[Call]] trap called'), + construct: overrides.construct || throwTest262Error('[[Construct]] trap called') + }; +} diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/target-array-non-extensible.js b/js/src/tests/test262/built-ins/Array/prototype/splice/target-array-non-extensible.js new file mode 100644 index 0000000000..d7184b2af6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/target-array-non-extensible.js @@ -0,0 +1,41 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible) +info: | + Array.prototype.splice ( start, deleteCount, ...items ) + + [...] + 11. Repeat, while k < actualDeleteCount + [...] + c. If fromPresent is true, then + [...] + ii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(k), fromValue). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; + +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.splice(0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/target-array-with-non-configurable-property.js b/js/src/tests/test262/built-ins/Array/prototype/splice/target-array-with-non-configurable-property.js new file mode 100644 index 0000000000..93727a9a1c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/target-array-with-non-configurable-property.js @@ -0,0 +1,43 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable) +info: | + Array.prototype.splice ( start, deleteCount, ...items ) + + [...] + 11. Repeat, while k < actualDeleteCount + [...] + c. If fromPresent is true, then + [...] + ii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(k), fromValue). + [...] + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + writable: true, + configurable: false, + }); +}; + +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; + +assert.throws(TypeError, function() { + arr.splice(0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/target-array-with-non-writable-property.js b/js/src/tests/test262/built-ins/Array/prototype/splice/target-array-with-non-writable-property.js new file mode 100644 index 0000000000..fe3a478fa3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/target-array-with-non-writable-property.js @@ -0,0 +1,38 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + Non-writable properties are overwritten by CreateDataPropertyOrThrow. +info: | + 22.1.3.26 Array.prototype.splice ( start, deleteCount, ...items ) + + ... + 11. Repeat, while k < actualDeleteCount + ... + c. If fromPresent is true, then + ... + ii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(k), fromValue). + ... +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var a = [1]; +a.constructor = {}; +a.constructor[Symbol.species] = function(len) { + var q = new Array(0); + Object.defineProperty(q, 0, { + value: 0, writable: false, configurable: true, enumerable: false, + }); + return q; +}; + +var r = a.splice(0); + +verifyProperty(r, 0, { + value: 1, writable: true, configurable: true, enumerable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/throws-if-integer-limit-exceeded.js b/js/src/tests/test262/built-ins/Array/prototype/splice/throws-if-integer-limit-exceeded.js new file mode 100644 index 0000000000..8e67a021b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/throws-if-integer-limit-exceeded.js @@ -0,0 +1,43 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + A TypeError is thrown if the new length exceeds 2^53-1. +info: | + 1. ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... + 7. Else, + a. Let insertCount be the number of actual arguments minus 2. + b. Let dc be ? ToInteger(deleteCount). + c. Let actualDeleteCount be min(max(dc, 0), len - actualStart). + 8. If len+insertCount-actualDeleteCount > 2^53-1, throw a TypeError exception. + ... +features: [exponentiation] +---*/ + +var arrayLike = {}; + +arrayLike.length = 2 ** 53 - 1; +assert.throws(TypeError, function() { + Array.prototype.splice.call(arrayLike, 0, 0, null); +}, "Length is 2**53 - 1"); + +arrayLike.length = 2 ** 53; +assert.throws(TypeError, function() { + Array.prototype.splice.call(arrayLike, 0, 0, null); +}, "Length is 2**53"); + +arrayLike.length = 2 ** 53 + 2; +assert.throws(TypeError, function() { + Array.prototype.splice.call(arrayLike, 0, 0, null); +}, "Length is 2**53 + 2"); + +arrayLike.length = Infinity; +assert.throws(TypeError, function() { + Array.prototype.splice.call(arrayLike, 0, 0, null); +}, "Length is Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/S15.4.4.3_A1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/S15.4.4.3_A1_T1.js new file mode 100644 index 0000000000..1a068ed5ac --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/S15.4.4.3_A1_T1.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tolocalestring +info: | + The elements of the array are converted to strings using their + toLocaleString methods, and these strings are then concatenated, separated + by occurrences of a separator string that has been derived in an + implementation-defined locale-specific way +es5id: 15.4.4.3_A1_T1 +description: it is the function that should be invoked +---*/ + +var n = 0; +var obj = { + toLocaleString: function() { + n++ + } +}; +var arr = [undefined, obj, null, obj, obj]; +arr.toLocaleString(); + +if (n !== 3) { + throw new Test262Error('#1: var n = 0; var obj = {toLocaleString: function() {n++}}; var arr = [undefined, obj, null, obj, obj]; arr.toLocaleString(); n === 3. Actual: ' + (n)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/S15.4.4.3_A3_T1.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/S15.4.4.3_A3_T1.js new file mode 100644 index 0000000000..a7f0796792 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/S15.4.4.3_A3_T1.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tolocalestring +info: "[[Get]] from not an inherited property" +es5id: 15.4.4.3_A3_T1 +description: "[[Prototype]] of Array instance is Array.prototype" +---*/ + +var n = 0; +var obj = { + toLocaleString: function() { + n++ + } +}; +Array.prototype[1] = obj; +var x = [obj]; +x.length = 2; +x.toLocaleString(); +if (n !== 2) { + throw new Test262Error('#1: var n = 0; var obj = {toLocaleString: function() {n++}}; Array.prototype[1] = obj; x = [obj]; x.length = 2; x.toLocaleString(); n === 2. Actual: ' + (n)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/browser.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/invoke-element-tolocalestring.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/invoke-element-tolocalestring.js new file mode 100644 index 0000000000..2ccde4cca4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/invoke-element-tolocalestring.js @@ -0,0 +1,65 @@ +// Copyright (C) 2022 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tolocalestring +description: > + The toLocaleString method of each non-undefined non-null element + must be called with no arguments. +info: | + Array.prototype.toLocaleString ( [ _reserved1_ [ , _reserved2_ ] ] ) + + 4. Let _R_ be the empty String. + 5. Let _k_ be 0. + 6. Repeat, while _k_ < _len_, + a. If _k_ > 0, then + i. Set _R_ to the string-concatenation of _R_ and _separator_. + b. Let _nextElement_ be ? Get(_array_, ! ToString(_k_)). + c. If _nextElement_ is not *undefined* or *null*, then + i. Let _S_ be ? ToString(? Invoke(_nextElement_, *"toLocaleString"*)). + ii. Set _R_ to the string-concatenation of _R_ and _S_. + d. Increase _k_ by 1. + 7. Return _R_. +includes: [compareArray.js] +---*/ + +const unique = { + toString() { + return ""; + } +}; + +const testCases = [ + { label: "no arguments", args: [] }, + { label: "undefined locale", args: [undefined] }, + { label: "string locale", args: ["ar"] }, + { label: "object locale", args: [unique] }, + { label: "undefined locale and options", args: [undefined, unique] }, + { label: "string locale and options", args: ["zh", unique] }, + { label: "object locale and options", args: [unique, unique] }, + { label: "extra arguments", args: [unique, unique, unique] }, +]; + +for (const { label, args } of testCases) { + assert.sameValue([undefined].toLocaleString(...args), "", + `must skip undefined elements when provided ${label}`); +} +for (const { label, args, expectedArgs } of testCases) { + assert.sameValue([null].toLocaleString(...args), "", + `must skip null elements when provided ${label}`); +} + +if (typeof Intl !== "object") { + for (const { label, args } of testCases) { + const spy = { + toLocaleString(...receivedArgs) { + assert.compareArray(receivedArgs, [], + `must invoke element toLocaleString with no arguments when provided ${label}`); + return "ok"; + } + }; + assert.sameValue([spy].toLocaleString(...args), "ok"); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/length.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/length.js new file mode 100644 index 0000000000..bc24898e1e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tolocalestring +description: > + The "length" property of Array.prototype.toLocaleString +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.toLocaleString.length, 0); + +verifyNotEnumerable(Array.prototype.toLocaleString, 'length'); +verifyNotWritable(Array.prototype.toLocaleString, 'length'); +verifyConfigurable(Array.prototype.toLocaleString, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/name.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/name.js new file mode 100644 index 0000000000..54f2c57bcb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tolocalestring +description: > + Array.prototype.toLocaleString.name is "toLocaleString". +info: | + Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.toLocaleString.name, "toLocaleString"); + +verifyNotEnumerable(Array.prototype.toLocaleString, "name"); +verifyNotWritable(Array.prototype.toLocaleString, "name"); +verifyConfigurable(Array.prototype.toLocaleString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/not-a-constructor.js new file mode 100644 index 0000000000..def6d25864 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/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: > + Array.prototype.toLocaleString 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.toLocaleString), + false, + 'isConstructor(Array.prototype.toLocaleString) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.toLocaleString(); +}, '`new Array.prototype.toLocaleString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/primitive_this_value-strict.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/primitive_this_value-strict.js new file mode 100644 index 0000000000..4107ea1fcc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/primitive_this_value-strict.js @@ -0,0 +1,33 @@ +'use strict'; +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tolocalestring +description: Array.prototype.toLocaleString called with primitive element +info: | + 22.1.3.26 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 10. Else + a. Let R be ToString(Invoke(firstElement, "toLocaleString")). + b. ReturnIfAbrupt(R). + ... + 12. + ... + e. Else + i. Let R be ToString(Invoke(nextElement, "toLocaleString")). + ii. ReturnIfAbrupt(R). +es6id: 22.1.3.26 +flags: [onlyStrict] +---*/ + +var listSeparator = ["", ""].toLocaleString(); + +Boolean.prototype.toString = function() { + return typeof this; +}; + +assert.sameValue([true, false].toLocaleString(), ("boolean" + listSeparator + "boolean")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/primitive_this_value_getter-strict.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/primitive_this_value_getter-strict.js new file mode 100644 index 0000000000..1dd5009ef5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/primitive_this_value_getter-strict.js @@ -0,0 +1,38 @@ +'use strict'; +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tolocalestring +description: Array.prototype.toLocaleString called with primitive element in getter +info: | + 22.1.3.26 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 10. Else + a. Let R be ToString(Invoke(firstElement, "toLocaleString")). + b. ReturnIfAbrupt(R). + ... + 12. + ... + e. Else + i. Let R be ToString(Invoke(nextElement, "toLocaleString")). + ii. ReturnIfAbrupt(R). +es6id: 22.1.3.26 +flags: [onlyStrict] +---*/ + +var listSeparator = ["", ""].toLocaleString(); + +Object.defineProperty(Boolean.prototype, "toString", { + get: function() { + var v = typeof this; + return function() { + return v; + }; + } +}); + +assert.sameValue([true, false].toLocaleString(), ("boolean" + listSeparator + "boolean")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/prop-desc.js new file mode 100644 index 0000000000..3cde82c748 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tolocalestring +description: > + "toLocaleString" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.toLocaleString, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "toLocaleString"); +verifyWritable(Array.prototype, "toLocaleString"); +verifyConfigurable(Array.prototype, "toLocaleString"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/shell.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/browser.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/frozen-this-value.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/frozen-this-value.js new file mode 100644 index 0000000000..e5c9bb380e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/frozen-this-value.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed works on frozen objects +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = Object.freeze([0, 1, 2]); +var result = arr.toReversed(); +assert.compareArray(result, [2, 1, 0]); + +var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); +result = Array.prototype.toReversed.call(arrayLike); +assert.compareArray(result, [2, 1, 0]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/get-descending-order.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/get-descending-order.js new file mode 100644 index 0000000000..81c46bf65a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/get-descending-order.js @@ -0,0 +1,51 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed gets the array elements from the last one to the first one. +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 5. Repeat, while k < len + a. Let from be ! ToString(𝔽(len - k - 1)). + ... + c. Let fromValue be ? Get(O, from). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var order = []; +var arrayLike = { + length: 3, + get 0() { + order.push(0); + }, + get 1() { + order.push(1); + }, + get 2() { + order.push(2); + }, +}; + +Array.prototype.toReversed.call(arrayLike); + +assert.compareArray(order, [2, 1, 0]); + +order = []; +var arr = [0, 1, 2]; +Object.defineProperty(arr, 0, { get: function() { order.push(0); } }); +Object.defineProperty(arr, 1, { get: function() { order.push(1); } }); +Object.defineProperty(arr, 2, { get: function() { order.push(2); } }); + +Array.prototype.toReversed.call(arr); + +assert.compareArray(order, [2, 1, 0]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/holes-not-preserved.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/holes-not-preserved.js new file mode 100644 index 0000000000..9e884f98c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/holes-not-preserved.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed does not preserve holes in the array +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 5. Repeat, while k < len + a. Let from be ! ToString(𝔽(len - k - 1)). + ... + c. Let fromValue be ? Get(O, from). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, /* hole */, 2, /* hole */, 4]; +Array.prototype[3] = 3; + +var reversed = arr.toReversed(); +assert.compareArray(reversed, [4, 3, 2, undefined, 0]); +assert(reversed.hasOwnProperty(3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/ignores-species.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/ignores-species.js new file mode 100644 index 0000000000..f4eab08eee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/ignores-species.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed ignores @@species +info: | + Array.prototype.toReversed ( ) + + ... + 3. Let A be ? ArrayCreate(𝔽(len)). + ... +features: [change-array-by-copy] +---*/ + +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = function () {} + +assert.sameValue(Object.getPrototypeOf(a.toReversed()), Array.prototype); + +var b = []; + +Object.defineProperty(b, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } +}); + +b.toReversed(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/immutable.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/immutable.js new file mode 100644 index 0000000000..ddc1fe1d48 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/immutable.js @@ -0,0 +1,18 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed does not mutate its this value +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2]; +arr.toReversed(); + +assert.compareArray(arr, [0, 1, 2]); +assert.notSameValue(arr.toReversed(), arr); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-casted-to-zero.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-casted-to-zero.js new file mode 100644 index 0000000000..292c9ea810 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-casted-to-zero.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed creates an empty array if the this value .length is not a positive integer. +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(Array.prototype.toReversed.call({ length: -2 }), []); +assert.compareArray(Array.prototype.toReversed.call({ length: "dog" }), []); +assert.compareArray(Array.prototype.toReversed.call({ length: NaN }), []); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js new file mode 100644 index 0000000000..9d0e7f301c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js @@ -0,0 +1,34 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed caches the length getting the array elements. +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 5. Repeat, while k < len + ... + c. Let fromValue be ? Get(O, from). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2, 3, 4]; +Array.prototype[1] = 5; + +Object.defineProperty(arr, "3", { + get() { + arr.length = 1; + return 3; + } +}); + +assert.compareArray(arr.toReversed(), [4, 3, undefined, 5, 0]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js new file mode 100644 index 0000000000..ec74266b19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js @@ -0,0 +1,40 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed limits the length to 2 ** 32 - 1 +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let A be ? ArrayCreate(𝔽(len)). + ... + + ArrayCreate ( length [, proto ] ) + + 1. If length > 2 ** 32 - 1, throw a RangeError exception. +features: [change-array-by-copy, exponentiation] +---*/ + +// Object with large "length" property +var arrayLike = { + get "0"() { + throw new Test262Error("Get 0"); + }, + get "4294967295" () { // 2 ** 32 - 1 + throw new Test262Error("Get 2147483648"); + }, + get "4294967296" () { // 2 ** 32 + throw new Test262Error("Get 2147483648"); + }, + length: 2 ** 32 +}; + +assert.throws(RangeError, function() { + Array.prototype.toReversed.call(arrayLike); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js new file mode 100644 index 0000000000..90c87de7d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed caches the length getting the array elements. +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 5. Repeat, while k < len + ... + c. Let fromValue be ? Get(O, from). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2]; +Object.defineProperty(arr, "0", { + get() { + arr.push(4); + return 0; + } +}); + +assert.compareArray(arr.toReversed(), [2, 1, 0]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-tolength.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-tolength.js new file mode 100644 index 0000000000..ab49445ce8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/length-tolength.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed converts the this value length to a number. +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(Array.prototype.toReversed.call({ length: "2", 0: 1, 1: 2, 2: 3 }), [2, 1]); + +var arrayLike = { + length: { + valueOf: () => 2 + }, + 0: 1, + 1: 2, + 2: 3, +}; + +assert.compareArray(Array.prototype.toReversed.call(arrayLike), [2, 1]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/browser.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/length.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/length.js new file mode 100644 index 0000000000..c86c003c02 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + The "length" property of Array.prototype.toReversed +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.toReversed, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/name.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/name.js new file mode 100644 index 0000000000..e882061d66 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/name.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed.name is "toReversed". +info: | + Array.prototype.toReversed ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.toReversed, "name", { + value: "toReversed", + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/property-descriptor.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/property-descriptor.js new file mode 100644 index 0000000000..63f38569c7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/property-descriptor.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + "toReversed" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +assert.sameValue(typeof Array.prototype.toReversed, "function", "typeof"); + +verifyProperty(Array.prototype, "toReversed", { + value: Array.prototype.toReversed, + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/shell.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/metadata/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/not-a-constructor.js new file mode 100644 index 0000000000..6e848442c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.toReversed 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: [change-array-by-copy, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.toReversed), + false, + 'isConstructor(Array.prototype.toReversed) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.toReversed(); +}, '`new Array.prototype.toReversed()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/shell.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/this-value-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/this-value-boolean.js new file mode 100644 index 0000000000..b91cffbec9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/this-value-boolean.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed converts booleans to objects +info: | + Array.prototype.toReversed ( ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(Array.prototype.toReversed.call(true), []); +assert.compareArray(Array.prototype.toReversed.call(false), []); + +/* Add length and indexed properties to `Boolean.prototype` */ +Boolean.prototype.length = 3; +assert.compareArray(Array.prototype.toReversed.call(true), [undefined, undefined, undefined]); +assert.compareArray(Array.prototype.toReversed.call(false), [undefined, undefined, undefined]); +delete Boolean.prototype.length; +Boolean.prototype[0] = "monkeys"; +Boolean.prototype[2] = "bogus"; +assert.compareArray(Array.prototype.toReversed.call(true), []); +assert.compareArray(Array.prototype.toReversed.call(false), []); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/this-value-nullish.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/this-value-nullish.js new file mode 100644 index 0000000000..682b28addf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/this-value-nullish.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed throws if the receiver is null or undefined +info: | + Array.prototype.toReversed ( ) + + 1. Let O be ? ToObject(this value). + ... +features: [change-array-by-copy] +---*/ + +assert.throws(TypeError, () => { + Array.prototype.toReversed.call(null); +}, '`Array.prototype.toReversed.call(null)` throws TypeError'); + +assert.throws(TypeError, () => { + Array.prototype.toReversed.call(undefined); +}, '`Array.prototype.toReversed.call(undefined)` throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/zero-or-one-element.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/zero-or-one-element.js new file mode 100644 index 0000000000..863dffa761 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/zero-or-one-element.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed returns a new array even if it has zero or one elements +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var zero = []; +var zeroReversed = zero.toReversed(); +assert.notSameValue(zero, zeroReversed); +assert.compareArray(zero, zeroReversed); + +var one = [1]; +var oneReversed = one.toReversed(); +assert.notSameValue(one, oneReversed); +assert.compareArray(one, oneReversed); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/browser.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js new file mode 100644 index 0000000000..41f7db3663 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js @@ -0,0 +1,45 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted reads all the array elements before calling compareFn +info: | + SortIndexedProperties ( obj, len, SortCompare, skipHoles ) + + ... + 3. Repeat, while k < len, + a. Let Pk be ! ToString(𝔽(k)). + ... + i. Let kValue be ? Get(O, Pk). + ... + 4. Sort items using an implementation-defined sequence of + calls to SortCompare. If any such call returns an abrupt + completion, stop before performing any further calls to + SortCompare or steps in this algorithm and return that + Completion Record. + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var getCalls = []; + +var arrayLike = { + length: 3, + get 0() { getCalls.push(0); return 2; }, + get 1() { getCalls.push(1); return 1; }, + get 2() { getCalls.push(2); return 3; }, + +} + +assert.throws(Test262Error, function() { + Array.prototype.toSorted.call(arrayLike, () => { + throw new Test262Error(); + }); +}); + +assert.compareArray(getCalls, [0, 1, 2]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js new file mode 100644 index 0000000000..3a3e64627e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted verifies that the comparator is callable before reading the length. +info: | + Array.prototype.toSorted ( compareFn ) + + 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. + 2. ... + 3. Let len be ? LengthOfArrayLike(O). +features: [change-array-by-copy] +---*/ + +var getLengthThrow = { + get length() { + throw new Test262Error("IsCallable(comparefn) should be observed before this.length"); + } +}; + +var invalidComparators = [null, true, false, "", /a/g, 42, 42n, [], {}, Symbol()]; + +for (var i = 0; i < invalidComparators.length; i++) { + assert.throws(TypeError, function() { + [1].toSorted(invalidComparators[i]); + }, String(invalidComparators[i]) + " on an array"); + + assert.throws(TypeError, function() { + Array.prototype.toSorted.call(getLengthThrow, invalidComparators[i]); + }, String(invalidComparators[i]) + " on an object whose 'length' throws"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js new file mode 100644 index 0000000000..6b36b3dccf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js @@ -0,0 +1,44 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted doesn't call compareFn if there is an error +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 7. Sort items using an implementation-defined sequence of + calls to SortCompare. If any such call returns an abrupt + completion, stop before performing any further calls to + SortCompare or steps in this algorithm and return that completion. + ... +features: [change-array-by-copy] +---*/ + +var arrayLike = { + length: 1, + get 0() { throw new Test262Error(); }, +}; + +var called = false; +assert.throws(Test262Error, function() { + Array.prototype.toSorted.call(arrayLike, () => { + called = true; + }); +}); +assert.sameValue(called, false); + +called = 0; +assert.throws(Test262Error, function() { + [1, 2, 3].toSorted(() => { + ++called; + if (called === 1) { + throw new Test262Error(); + } + }); +}); +assert.sameValue(called, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/frozen-this-value.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/frozen-this-value.js new file mode 100644 index 0000000000..0e4767e598 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/frozen-this-value.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted works on frozen objects +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = Object.freeze([2, 0, 1]); +var result = arr.toSorted(); +assert.compareArray(result, [0, 1, 2]); + +var arrayLike = Object.freeze({ length: 3, 0: 2, 1: 0, 2: 1 }); +result = Array.prototype.toSorted.call(arrayLike); +assert.compareArray(result, [0, 1, 2]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/holes-not-preserved.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/holes-not-preserved.js new file mode 100644 index 0000000000..1a88422f0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/holes-not-preserved.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted does not preserve holes in the array +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 8. Repeat, while j < len, + a. Perform ! CreateDataPropertyOrThrow(A, ! ToString(𝔽(j)), sortedList[j]). + b. Set j to j + 1. + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [3, /* hole */, 4, /* hole */, 1]; +Array.prototype[3] = 2; + +var sorted = arr.toSorted(); +assert.compareArray(sorted, [1, 2, 3, 4, undefined]); +assert(sorted.hasOwnProperty(4)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/ignores-species.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/ignores-species.js new file mode 100644 index 0000000000..78c9656550 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/ignores-species.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted ignores @@species +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 8. Let A be ? ArrayCreate(𝔽(len)). + ... +features: [change-array-by-copy] +---*/ + +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = function () {} + +assert.sameValue(Object.getPrototypeOf(a.toSorted()), Array.prototype); + +var b = []; +Object.defineProperty(b, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } +}); + +b.toSorted(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/immutable.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/immutable.js new file mode 100644 index 0000000000..2fb611d109 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/immutable.js @@ -0,0 +1,18 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted does not mutate its this value +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [2, 0, 1]; +arr.toSorted(); + +assert.compareArray(arr, [2, 0, 1]); +assert.notSameValue(arr.toSorted(), arr); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-casted-to-zero.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-casted-to-zero.js new file mode 100644 index 0000000000..c058ba8d8c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-casted-to-zero.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted creates an empty array if the this value .length is not a positive integer. +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 3. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(Array.prototype.toSorted.call({ length: -2 }), []); +assert.compareArray(Array.prototype.toSorted.call({ length: "dog" }), []); +assert.compareArray(Array.prototype.toSorted.call({ length: NaN }), []); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js new file mode 100644 index 0000000000..ce48724aa9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted caches the length getting the array elements. +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 3. Let len be ? LengthOfArrayLike(O). + ... + 6. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, false). + ... + +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [5, 1, 4, 6, 3]; +Array.prototype[3] = 2; + +Object.defineProperty(arr, "2", { + get() { + arr.length = 1; + return 4; + } +}); + +assert.compareArray(arr.toSorted(), [1, 2, 4, 5, undefined]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js new file mode 100644 index 0000000000..a6619963f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js @@ -0,0 +1,41 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted limits the length to 2 ** 32 - 1 +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 3. Let len be ? LengthOfArrayLike(O). + ... + 8. Let A be ? ArrayCreate(𝔽(len)). + ... + + ArrayCreate ( length [, proto ] ) + + 1. If length > 2 ** 32 - 1, throw a RangeError exception. +features: [change-array-by-copy, exponentiation] +---*/ + +// Object with large "length" property +var arrayLike = { + get "0"() { + throw new Test262Error("Get 0"); + }, + get "4294967295" () { // 2 ** 32 - 1 + throw new Test262Error("Get 2147483648"); + }, + get "4294967296" () { // 2 ** 32 + throw new Test262Error("Get 2147483648"); + }, + length: 2 ** 32 +}; + +assert.throws(RangeError, function() { + Array.prototype.toSorted.call(arrayLike); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js new file mode 100644 index 0000000000..2843d92f54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted caches the length getting the array elements. +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 3. Let len be ? LengthOfArrayLike(O). + ... + 6. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, false). + ... + +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [5, 0, 3]; +Object.defineProperty(arr, "0", { + get() { + arr.push(1); + return 5; + } +}); + +assert.compareArray(arr.toSorted(), [0, 3, 5]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-tolength.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-tolength.js new file mode 100644 index 0000000000..4e6344428d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/length-tolength.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted converts the this value length to a number. +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 3. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(Array.prototype.toSorted.call({ length: "2", 0: 4, 1: 0, 2: 1 }), [0, 4]); + +var arrayLike = { + length: { + valueOf: () => 2 + }, + 0: 4, + 1: 0, + 2: 1, +}; + +assert.compareArray(Array.prototype.toSorted.call(arrayLike), [0, 4]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/browser.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/length.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/length.js new file mode 100644 index 0000000000..196bf5b3b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + The "length" property of Array.prototype.toSorted +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.toSorted, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/name.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/name.js new file mode 100644 index 0000000000..f2d7a8bf68 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/name.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted.name is "toSorted". +info: | + Array.prototype.toSorted ( compareFn ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.toSorted, "name", { + value: "toSorted", + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/property-descriptor.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/property-descriptor.js new file mode 100644 index 0000000000..cc58c83d0f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/property-descriptor.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + "toSorted" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +assert.sameValue(typeof Array.prototype.toSorted, "function", "typeof"); + +verifyProperty(Array.prototype, "toSorted", { + value: Array.prototype.toSorted, + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/shell.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/metadata/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/not-a-constructor.js new file mode 100644 index 0000000000..dda671c3ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.toSorted 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: [change-array-by-copy, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.toSorted), + false, + 'isConstructor(Array.prototype.toSorted) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.toSorted(); +}, '`new Array.prototype.toSorted()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/shell.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-boolean.js new file mode 100644 index 0000000000..323b8df9f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-boolean.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted converts booleans to objects +info: | + Array.prototype.toSorted ( compareFn ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(Array.prototype.toSorted.call(true), []); +assert.compareArray(Array.prototype.toSorted.call(false), []); + + +/* Add length and indexed properties to `Boolean.prototype` */ +Boolean.prototype.length = 3; +assert.compareArray(Array.prototype.toSorted.call(true), [undefined, undefined, undefined]); +assert.compareArray(Array.prototype.toSorted.call(false), [undefined, undefined, undefined]); +delete Boolean.prototype.length; +Boolean.prototype[0] = "monkeys"; +Boolean.prototype[2] = "bogus"; +assert.compareArray(Array.prototype.toSorted.call(true), []); +assert.compareArray(Array.prototype.toSorted.call(false), []); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-nullish.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-nullish.js new file mode 100644 index 0000000000..65690075df --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-nullish.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted throws if the receiver is null or undefined +info: | + Array.prototype.toSorted ( compareFn ) + + 1. Let O be ? ToObject(this value). + ... +features: [change-array-by-copy] +---*/ + +assert.throws(TypeError, () => { + Array.prototype.toSorted.call(null); +}, '`Array.prototype.toSorted.call(null)` throws TypeError'); + +assert.throws(TypeError, () => { + Array.prototype.toSorted.call(undefined); +}, '`Array.prototype.toSorted.call(undefined)` throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/zero-or-one-element.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/zero-or-one-element.js new file mode 100644 index 0000000000..42026d538f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/zero-or-one-element.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted returns a new array even if it has zero or one elements +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var zero = []; +var zeroReversed = zero.toSorted(); +assert.notSameValue(zero, zeroReversed); +assert.compareArray(zero, zeroReversed); + +var one = [1]; +var oneReversed = one.toSorted(); +assert.notSameValue(one, oneReversed); +assert.compareArray(one, oneReversed); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/browser.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js new file mode 100644 index 0000000000..7cc84733e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js @@ -0,0 +1,39 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: deleteCount is clamped between zero and len - actualStart +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 10. Else, + a. Let dc be ? ToIntegerOrInfinity(deleteCount). + b. Let actualDeleteCount be the result of clamping dc between 0 and len - actualStart. + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3, 4, 5].toSpliced(2, -1), + [0, 1, 2, 3, 4, 5] +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].toSpliced(-4, -1), + [0, 1, 2, 3, 4, 5] +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].toSpliced(2, 6), + [0, 1] +); + +assert.compareArray( + [0, 1, 2, 3, 4, 5].toSpliced(-4, 6), + [0, 1] +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/deleteCount-missing.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/deleteCount-missing.js new file mode 100644 index 0000000000..6e0903c21d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/deleteCount-missing.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced deletes the elements after start when called with one argument +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 9. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var result = ["first", "second", "third"].toSpliced(1); + +assert.compareArray(result, ["first"]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js new file mode 100644 index 0000000000..ed1b4dffb7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced(number, undefined) returns a copy of the original array +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 6. Else, let actualStart be min(relativeStart, len). + ... + 8. If start is not present, then + a. Let actualDeleteCount be 0. + 9. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. + 10. Else, + a. Let dc be ? ToIntegerOrInfinity(deleteCount). + b. Let actualDeleteCount be the result of clamping dc between 0 and len - actualStart. + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var result = ["first", "second", "third"].toSpliced(1, undefined); + +assert.compareArray(result, ["first", "second", "third"]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js new file mode 100644 index 0000000000..1544086f47 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js @@ -0,0 +1,54 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced does not Get the discarded elements in the original array +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 6. Else, let actualStart be min(relativeStart, len). + ... + 8. If start is not present, then + a. Let actualDeleteCount be 0. + 9. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. + 10. Else, + a. Let dc be ? ToIntegerOrInfinity(deleteCount). + b. Let actualDeleteCount be the result of clamping dc between 0 and len - actualStart. + 11. Let newLen be len + insertCount - actualDeleteCount. + ... + 15. Let r be actualStart + actualDeleteCount. + ... + 18. Repeat, while i < newLen, + a. Let Pi be ! ToString(𝔽(i)). + b. Let from be ! ToString(𝔽(r)). + c. Let fromValue be ? Get(O, from). + d. Perform ! CreateDataPropertyOrThrow(A, Pi, fromValue). + e. Set i to i + 1. + f. Set r to r + 1. + +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arrayLike = { + 0: "a", + 1: "b", + get 2() { throw new Test262Error(); }, + 3: "c", + length: 4, +}; + +/* + * In this example, just before step 18, i == 2 and r == 3. + * So A[2] is set to arrayLike[3] and arrayLike[2] is never read + * (since i and r both increase monotonically). + */ +var result = Array.prototype.toSpliced.call(arrayLike, 2, 1); +assert.compareArray(result, ["a", "b", "c"]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/elements-read-in-order.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/elements-read-in-order.js new file mode 100644 index 0000000000..da1b7fc905 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/elements-read-in-order.js @@ -0,0 +1,61 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced reads the items of the original array in order +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 14. Let i be 0. + 15. Let r be actualStart + actualDeleteCount. + 16. Repeat, while i < actualStart, + a. Let Pi be ! ToString(𝔽(i)). + b. Let iValue be ? Get(O, Pi). + c. Perform ! CreateDataPropertyOrThrow(A, Pi, iValue). + d. Set i to i + 1. + 17. For each element E of items, do + a. Let Pi be ! ToString(𝔽(i)). + b. Perform ! CreateDataPropertyOrThrow(A, Pi, E). + c. Set i to i + 1. + 18. Repeat, while i < newLen, + a. Let Pi be ! ToString(𝔽(i)). + b. Let from be ! ToString(𝔽(r)). + c. Let fromValue be ? Get(O, from). + d. Perform ! CreateDataPropertyOrThrow(A, Pi, fromValue). + e. Set i to i + 1. + f. Set r to r + 1. + ... + +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var order = []; + +var arrayLike = { + get 0() { order.push(0); return "a" }, + get 1() { order.push(1); return "b" }, + 2: "none", + get 3() { order.push(3); return "c" }, + length: 4, +}; + +var result = Array.prototype.toSpliced.call(arrayLike, 2, 1); +assert.compareArray(result, ["a", "b", "c"]); + +assert.compareArray(order, [0, 1, 3]); + +order = []; +var arr = [0, 1, "none", 3]; +Object.defineProperty(arr, 0, { get: function() { order.push(0); return "a" } }); +Object.defineProperty(arr, 1, { get: function() { order.push(1); return "b" } }); +Object.defineProperty(arr, 3, { get: function() { order.push(3); return "c" } }); + +result = Array.prototype.toSpliced.call(arr, 2, 1); +assert.compareArray(result, ["a", "b", "c"]); + +assert.compareArray(order, [0, 1, 3]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/frozen-this-value.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/frozen-this-value.js new file mode 100644 index 0000000000..3013dee9f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/frozen-this-value.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced works on frozen objects +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = Object.freeze([2, 0, 1]); +var result = arr.toSpliced(); +assert.compareArray(result, [2, 0, 1]); + +var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); + +assert.compareArray(Array.prototype.toSpliced.call(arrayLike, 1, 1, 4, 5), [0, 4, 5, 2]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/holes-not-preserved.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/holes-not-preserved.js new file mode 100644 index 0000000000..3fb2e312a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/holes-not-preserved.js @@ -0,0 +1,43 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced does not preserve holes in the array +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 13. Let k be 0. + 14. Repeat, while k < actualStart, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue). + d. Set k to k + 1. + ... + 16. Repeat, while k < newLen, + a. Let Pk be ! ToString(𝔽(k)). + b. Let from be ! ToString(𝔽(k + actualDeleteCount - insertCount)). + c. Let fromValue be ? Get(O, from). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. + ... +includes: [compareArray.js] +features: [change-array-by-copy] +---*/ + +var arr = [0, /* hole */, 2, /* hole */, 4]; +Array.prototype[3] = 3; + +var spliced = arr.toSpliced(0, 0); +assert.compareArray(spliced, [0, undefined, 2, 3, 4]); +assert(spliced.hasOwnProperty(1)); +assert(spliced.hasOwnProperty(3)); + +spliced = arr.toSpliced(0, 0, -1); +assert.compareArray(spliced, [-1, 0, undefined, 2, 3, 4]); +assert(spliced.hasOwnProperty(1)); +assert(spliced.hasOwnProperty(3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/ignores-species.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/ignores-species.js new file mode 100644 index 0000000000..fd55356656 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/ignores-species.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced ignores @@species +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 12. Let A be ? ArrayCreate(𝔽(newLen)). + ... +features: [change-array-by-copy] +---*/ + +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = function () {} + +assert.sameValue(Object.getPrototypeOf(a.toSpliced(0, 0)), Array.prototype); + +var b = []; +Object.defineProperty(b, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } +}); + +b.toSpliced(0, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/immutable.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/immutable.js new file mode 100644 index 0000000000..710da9916c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/immutable.js @@ -0,0 +1,19 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced does not mutate its this value +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [2, 0, 1]; +arr.toSpliced(0, 0, -1); + +assert.compareArray(arr, [2, 0, 1]); +assert.notSameValue(arr.toSpliced(0, 0, -1), arr); +assert.notSameValue(arr.toSpliced(0, 1, -1), arr); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js new file mode 100644 index 0000000000..de36d2c41a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced treats its `this` value's `length` property as zero if the + property's value is not a positive integer. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(Array.prototype.toSpliced.call({ length: -2 }, 0, 0, 2, 3), [2, 3]); +assert.compareArray(Array.prototype.toSpliced.call({ length: "dog" }, 0, 0, 2, 3), [2, 3]); +assert.compareArray(Array.prototype.toSpliced.call({ length: NaN }, 0, 0, 2, 3), [2, 3]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js new file mode 100644 index 0000000000..0ce88ef200 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js @@ -0,0 +1,36 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Length is clamped to 2^53-1 when they exceed the integer limit. +info: | + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + + ToLength ( argument ) + + 1. Let len be ? ToIntegerOrInfinity(argument). + 2. If len ≤ 0, return +0𝔽. + 3. Return 𝔽(min(len, 2^53 - 1)) +features: [change-array-by-copy, exponentiation] +includes: [compareArray.js] +---*/ + +var arrayLike = { + "9007199254740989": 2 ** 53 - 3, + "9007199254740990": 2 ** 53 - 2, + "9007199254740991": 2 ** 53 - 1, + "9007199254740992": 2 ** 53, + "9007199254740994": 2 ** 53 + 2, // NOTE: 2 ** 53 + 1 is 2 ** 53 + length: 2 ** 53 + 20, +}; + +var result = Array.prototype.toSpliced.call(arrayLike, 0, 2 ** 53 - 3); + +assert.sameValue(result.length, 2); +assert.compareArray(result, [2 ** 53 - 3, 2 ** 53 - 2]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js new file mode 100644 index 0000000000..35d4767b8f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js @@ -0,0 +1,46 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced caches the length getting the array elements. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 11. Let newLen be len + insertCount - actualDeleteCount. + ... + 13. Let k be 0. + 14. Repeat, while k < actualStart, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue). + d. Set k to k + 1. + ... + 16. Repeat, while k < newLen, + a. Let Pk be ! ToString(𝔽(k)). + b. Let from be ! ToString(𝔽(k + actualDeleteCount - insertCount)). + c. Let fromValue be ? Get(O, from). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +Array.prototype[3] = 6; + +Object.defineProperty(arr, "2", { + get() { + arr.length = 1; + return 2; + } +}); + +assert.compareArray(arr.toSpliced(0, 0), [0, 1, 2, 6, undefined, undefined]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js new file mode 100644 index 0000000000..a8ad3e4624 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js @@ -0,0 +1,78 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced limits the length to 2 ** 32 - 1 +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 3. Let len be ? LengthOfArrayLike(O). + ... + 11. Let newLen be len + insertCount - actualDeleteCount. + 12. If _newLen_ > 2 ** 53< - 1, throw a *TypeError* exception. + 13. Let A be ? ArrayCreate(𝔽(newLen)). + ... + + ArrayCreate ( length [, proto ] ) + + 1. If length > 2 ** 32 - 1, throw a RangeError exception. +features: [change-array-by-copy, exponentiation] +---*/ + +// Object with large "length" property +var arrayLike = { + get "0"() { + throw new Test262Error("Get 0"); + }, + get "4294967295" () { // 2 ** 32 - 1 + throw new Test262Error("Get 4294967295"); + }, + get "4294967296" () { // 2 ** 32 + throw new Test262Error("Get 4294967296"); + }, + length: 2 ** 32 +}; + +assert.throws(RangeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0); +}); + +arrayLike.length = 2 ** 32 - 1; +assert.throws(RangeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); + +arrayLike.length = 2 ** 32; +assert.throws(RangeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); + +arrayLike.length = 2 ** 32 + 1; +assert.throws(RangeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); + +arrayLike.length = 2 ** 52 - 2; +assert.throws(RangeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); + +arrayLike.length = 2 ** 53 - 1; +assert.throws(TypeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); + +arrayLike.length = 2 ** 53; +assert.throws(TypeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); + +arrayLike.length = 2 ** 53 + 1; +assert.throws(TypeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js new file mode 100644 index 0000000000..f125316834 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js @@ -0,0 +1,39 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced caches the length getting the array elements. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 3. Let len be ? LengthOfArrayLike(O). + ... + 5. Let k be 0. + 6. Repeat, while k < len, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2]; +Object.defineProperty(arr, "0", { + get() { + arr.push(10); + return 0; + } +}); +Object.defineProperty(arr, "2", { + get() { + arr.push(11); + return 2; + } +}); + +assert.compareArray(arr.toSpliced(1, 0, 0.5), [0, 0.5, 1, 2]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-tolength.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-tolength.js new file mode 100644 index 0000000000..fc40bb8aa6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/length-tolength.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced converts the this value length to a number. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(Array.prototype.toSpliced.call({ length: "2", 0: 0, 1: 1, 2: 2 }, 0, 0), [0, 1]); + +var arrayLike = { + length: { + valueOf: () => 2 + }, + 0: 0, + 1: 1, + 2: 2, +}; + +assert.compareArray(Array.prototype.toSpliced.call(arrayLike, 0, 0), [0, 1]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/browser.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/length.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/length.js new file mode 100644 index 0000000000..63916778a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + The "length" property of Array.prototype.toSpliced +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.toSpliced, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/name.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/name.js new file mode 100644 index 0000000000..9025e4e34f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/name.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced.name is "toSpliced". +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.toSpliced, "name", { + value: "toSpliced", + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/property-descriptor.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/property-descriptor.js new file mode 100644 index 0000000000..9c9eadef59 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/property-descriptor.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + "toSpliced" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +assert.sameValue(typeof Array.prototype.toSpliced, "function", "typeof"); + +verifyProperty(Array.prototype, "toSpliced", { + value: Array.prototype.toSpliced, + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/shell.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/metadata/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/mutate-while-iterating.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/mutate-while-iterating.js new file mode 100644 index 0000000000..208976b7cb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/mutate-while-iterating.js @@ -0,0 +1,52 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced gets array elements one at a time. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 16. Repeat, while i < actualStart, + a. Let Pi be ! ToString(𝔽(i)). + b. Let iValue be ? Get(O, Pi). + c. Perform ! CreateDataPropertyOrThrow(A, Pi, iValue). + d. Set i to i + 1. + ... + 18. Repeat, while i < newLen, + a. Let Pi be ! ToString(𝔽(i)). + b. Let from be ! ToString(𝔽(r)). + c. Let fromValue be ? Get(O, from). + d. Perform ! CreateDataPropertyOrThrow(A, Pi, fromValue). + e. Set i to i + 1. + f. Set r to r + 1. + ... + +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2, 3]; +var zerothElementStorage = arr[0]; +Object.defineProperty(arr, "0", { + get() { + arr[1] = 42; + return zerothElementStorage; + }, + set(v) { + zerothElementStorage = v; + } +}); +Object.defineProperty(arr, "2", { + get() { + arr[0] = 17; + arr[3] = 37; + return 2; + } +}); + +assert.compareArray(arr.toSpliced(1, 0, 0.5), [0, 0.5, 42, 2, 37]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/not-a-constructor.js new file mode 100644 index 0000000000..533e8c9eaa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/not-a-constructor.js @@ -0,0 +1,34 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.toSpliced 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: [change-array-by-copy, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.toSpliced), + false, + 'isConstructor(Array.prototype.toSpliced) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.toSpliced(); +}, '`new Array.prototype.toSpliced()` throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/shell.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js new file mode 100644 index 0000000000..19688d17af --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced returns a copy of the array if called with zero arguments +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 6. Else, let actualStart be min(relativeStart, len). + ... + 8. If start is not present, then + a. Let actualDeleteCount be 0. + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +let arr = ["first", "second", "third"]; +let result = arr.toSpliced(); + +assert.compareArray(result, arr); +assert.notSameValue(result, arr); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js new file mode 100644 index 0000000000..a07388dca2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced(undefined, undefined) returns a copy of the original array +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 6. Else, let actualStart be min(relativeStart, len). + ... + 8. If start is not present, then + a. Let actualDeleteCount be 0. + 8. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +let arr = ["first", "second", "third"]; +let result = arr.toSpliced(undefined, undefined); + +assert.compareArray(result, arr); +assert.notSameValue(result, arr); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js new file mode 100644 index 0000000000..ca073db0e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced clamps the start argument to the this value length. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 4. If relativeStart is -∞, let actualStart be 0. + 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). + 6. Else, let actualStart be min(relativeStart, len). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var result = [0, 1, 2, 3, 4].toSpliced(10, 1, 5, 6); +assert.compareArray(result, [0, 1, 2, 3, 4, 5, 6]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js new file mode 100644 index 0000000000..cc025bd98e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced treats negative Infinity as zero for start. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 4. If relativeStart is -∞, let actualStart be 0. + 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var result = [0, 1, 2, 3, 4].toSpliced(-Infinity, 2); +assert.compareArray(result, [2, 3, 4]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js new file mode 100644 index 0000000000..79ccf7b51b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced treats a value smaller than -length as zero for start. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 4. If relativeStart is -∞, let actualStart be 0. + 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var result = [0, 1, 2, 3, 4].toSpliced(-20, 2); +assert.compareArray(result, [2, 3, 4]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js new file mode 100644 index 0000000000..4bbd45e665 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced treats a negative start as relative to the end. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 4. If relativeStart is -∞, let actualStart be 0. + 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var result = [0, 1, 2, 3, 4].toSpliced(-3, 2); +assert.compareArray(result, [0, 1, 4]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js new file mode 100644 index 0000000000..1cc6c57ad9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced(undefined) returns an empty array +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 6. Else, let actualStart be min(relativeStart, len). + ... + 8. If start is not present, then + a. Let actualDeleteCount be 0. + 8. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var result = ["first", "second", "third"].toSpliced(undefined); + +assert.compareArray(result, []); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/this-value-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/this-value-boolean.js new file mode 100644 index 0000000000..0f97abcd1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/this-value-boolean.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced converts booleans to objects +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(Array.prototype.toSpliced.call(true, 0, 0), []); +assert.compareArray(Array.prototype.toSpliced.call(false, 0, 0), []); + +/* Add length and indexed properties to `Boolean.prototype` */ +Boolean.prototype.length = 3; +assert.compareArray(Array.prototype.toSpliced.call(true, 0, 0), [undefined, undefined, undefined]); +assert.compareArray(Array.prototype.toSpliced.call(false, 0, 0), [undefined, undefined, undefined]); +delete Boolean.prototype.length; +Boolean.prototype[0] = "monkeys"; +Boolean.prototype[2] = "bogus"; +assert.compareArray(Array.prototype.toSpliced.call(true, 0, 0), []); +assert.compareArray(Array.prototype.toSpliced.call(false, 0, 0), []); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/this-value-nullish.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/this-value-nullish.js new file mode 100644 index 0000000000..1230d05f00 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/this-value-nullish.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced throws if the receiver is null or undefined +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + 1. Let O be ? ToObject(this value). + ... +features: [change-array-by-copy] +---*/ + +assert.throws(TypeError, () => { + Array.prototype.toSpliced.call(null, 0, 0); +}, '`Array.prototype.toSpliced.call(null)` throws TypeError'); + +assert.throws(TypeError, () => { + Array.prototype.toSpliced.call(undefined, 0, 0); +}, '`Array.prototype.toSpliced.call(undefined)` throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/unmodified.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/unmodified.js new file mode 100644 index 0000000000..d2983fd830 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/unmodified.js @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced returns a new array even if it the result is equal to the original array +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [1, 2, 3]; +var spliced = arr.toSpliced(1, 0); +assert.notSameValue(arr, spliced); +assert.compareArray(arr, spliced); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T1.js new file mode 100644 index 0000000000..37a3adeced --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T1.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tostring +info: | + The result of calling this function is the same as if + the built-in join method were invoked for this object with no argument +es5id: 15.4.4.2_A1_T1 +description: If Result(2) is zero, return the empty string +---*/ + +var x = new Array(); +if (x.toString() !== x.join()) { + throw new Test262Error('#1.1: x = new Array(); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "") { + throw new Test262Error('#1.2: x = new Array(); x.toString() === "". Actual: ' + (x.toString())); + } +} + +x = []; +x[0] = 1; +x.length = 0; +if (x.toString() !== x.join()) { + throw new Test262Error('#2.1: x = []; x[0] = 1; x.length = 0; x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "") { + throw new Test262Error('#2.2: x = []; x[0] = 1; x.length = 0; x.toString() === "". Actual: ' + (x.toString())); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T2.js b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T2.js new file mode 100644 index 0000000000..8a6b4f74ad --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T2.js @@ -0,0 +1,56 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tostring +info: | + The result of calling this function is the same as if + the built-in join method were invoked for this object with no argument +es5id: 15.4.4.2_A1_T2 +description: > + The elements of the array are converted to strings, and these + strings are then concatenated, separated by occurrences of the + separator. If no separator is provided, a single comma is used as + the separator +---*/ + +var x = new Array(0, 1, 2, 3); +if (x.toString() !== x.join()) { + throw new Test262Error('#1.1: x = new Array(0,1,2,3); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "0,1,2,3") { + throw new Test262Error('#1.2: x = new Array(0,1,2,3); x.toString() === "0,1,2,3". Actual: ' + (x.toString())); + } +} + +x = []; +x[0] = 0; +x[3] = 3; +if (x.toString() !== x.join()) { + throw new Test262Error('#2.1: x = []; x[0] = 0; x[3] = 3; x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "0,,,3") { + throw new Test262Error('#2.2: x = []; x[0] = 0; x[3] = 3; x.toString() === "0,,,3". Actual: ' + (x.toString())); + } +} + +x = Array(undefined, 1, null, 3); +if (x.toString() !== x.join()) { + throw new Test262Error('#3.1: x = Array(undefined,1,null,3); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== ",1,,3") { + throw new Test262Error('#3.2: x = Array(undefined,1,null,3); x.toString() === ",1,,3". Actual: ' + (x.toString())); + } +} + +x = []; +x[0] = 0; +if (x.toString() !== x.join()) { + throw new Test262Error('#4.1: x = []; x[0] = 0; x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "0") { + throw new Test262Error('#4.2: x = []; x[0] = 0; x.toString() === "0". Actual: ' + (x.toString())); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T3.js b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T3.js new file mode 100644 index 0000000000..2671bc767c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T3.js @@ -0,0 +1,85 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tostring +info: | + The result of calling this function is the same as if + the built-in join method were invoked for this object with no argument +es5id: 15.4.4.2_A1_T3 +description: Operator use ToString from array arguments +---*/ + +var x = new Array("", "", ""); +if (x.toString() !== x.join()) { + throw new Test262Error('#0.1: var x = new Array("","",""); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== ",,") { + throw new Test262Error('#0.2: var x = new Array("","",""); x.toString() === ",,". Actual: ' + (x.toString())); + } +} + +var x = new Array("\\", "\\", "\\"); +if (x.toString() !== x.join()) { + throw new Test262Error('#1.1: var x = new Array("\\","\\","\\"); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "\\,\\,\\") { + throw new Test262Error('#1.2: var x = new Array("\\","\\","\\"); x.toString() === "\\,\\,\\". Actual: ' + (x.toString())); + } +} + +var x = new Array("&", "&", "&"); +if (x.toString() !== x.join()) { + throw new Test262Error('#2.1: var x = new Array("&", "&", "&"); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "&,&,&") { + throw new Test262Error('#2.2: var x = new Array("&", "&", "&"); x.toString() === "&,&,&". Actual: ' + (x.toString())); + } +} + +var x = new Array(true, true, true); +if (x.toString() !== x.join()) { + throw new Test262Error('#3.1: var x = new Array(true,true,true); x.toString(true,true,true) === x.join(). Actual: ' + (x.toString(true, true, true))); +} else { + if (x.toString() !== "true,true,true") { + throw new Test262Error('#3.2: var x = new Array(true,true,true); x.toString(true,true,true) === "true,true,true". Actual: ' + (x.toString(true, true, true))); + } +} + +var x = new Array(null, null, null); +if (x.toString() !== x.join()) { + throw new Test262Error('#4.1: var x = new Array(null,null,null); x.toString(null,null,null) === x.join(). Actual: ' + (x.toString(null, null, null))); +} else { + if (x.toString() !== ",,") { + throw new Test262Error('#4.2: var x = new Array(null,null,null); x.toString(null,null,null) === ",,". Actual: ' + (x.toString(null, null, null))); + } +} + +var x = new Array(undefined, undefined, undefined); +if (x.toString() !== x.join()) { + throw new Test262Error('#5.1: var x = new Array(undefined,undefined,undefined); x.toString(undefined,undefined,undefined) === x.join(). Actual: ' + (x.toString(undefined, undefined, undefined))); +} else { + if (x.toString() !== ",,") { + throw new Test262Error('#5.2: var x = new Array(undefined,undefined,undefined); x.toString(undefined,undefined,undefined) === ",,". Actual: ' + (x.toString(undefined, undefined, undefined))); + } +} + +var x = new Array(Infinity, Infinity, Infinity); +if (x.toString() !== x.join()) { + throw new Test262Error('#6.1: var x = new Array(Infinity,Infinity,Infinity); x.toString(Infinity,Infinity,Infinity) === x.join(). Actual: ' + (x.toString(Infinity, Infinity, Infinity))); +} else { + if (x.toString() !== "Infinity,Infinity,Infinity") { + throw new Test262Error('#6.2: var x = new Array(Infinity,Infinity,Infinity); x.toString(Infinity,Infinity,Infinity) === "Infinity,Infinity,Infinity". Actual: ' + (x.toString(Infinity, Infinity, Infinity))); + } +} + +var x = new Array(NaN, NaN, NaN); +if (x.toString() !== x.join()) { + throw new Test262Error('#7.1: var x = new Array(NaN,NaN,NaN); x.toString(NaN,NaN,NaN) === x.join(). Actual: ' + (x.toString(NaN, NaN, NaN))); +} else { + if (x.toString() !== "NaN,NaN,NaN") { + throw new Test262Error('#7.2: var x = new Array(NaN,NaN,NaN); x.toString(NaN,NaN,NaN) === "NaN,NaN,NaN". Actual: ' + (x.toString(NaN, NaN, NaN))); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T4.js b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T4.js new file mode 100644 index 0000000000..edf9e63a9b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T4.js @@ -0,0 +1,100 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tostring +info: | + The result of calling this function is the same as if + the built-in join method were invoked for this object with no argument +es5id: 15.4.4.2_A1_T4 +description: If Type(value) is Object, evaluate ToPrimitive(value, String) +---*/ + +var object = { + valueOf() { + return "+" + } +}; +var x = new Array(object); +assert.sameValue(x.toString(), x.join(), 'x.toString() must return the same value returned by x.join()'); + +var object = { + valueOf() { + return "+" + }, + toString() { + return "*" + } +}; +var x = new Array(object); +assert.sameValue(x.toString(), x.join(), 'x.toString() must return the same value returned by x.join()'); + +var object = { + valueOf() { + return "+" + }, + toString() { + return {} + } +}; +var x = new Array(object); +assert.sameValue(x.toString(), x.join(), 'x.toString() must return the same value returned by x.join()'); + +var object = { + valueOf() { + throw "error" + }, + toString() { + return "*" + } +}; +var x = new Array(object); +assert.sameValue(x.toString(), x.join(), 'x.toString() must return the same value returned by x.join()'); + + +var object = { + toString() { + return "*" + } +}; +var x = new Array(object); +assert.sameValue(x.toString(), x.join(), 'x.toString() must return the same value returned by x.join()'); + +var object = { + valueOf() { + return {} + }, + toString() { + return "*" + } +} +var x = new Array(object); +assert.sameValue(x.toString(), x.join(), 'x.toString() must return the same value returned by x.join()'); + +assert.throws(Test262Error, () => { + var object = { + valueOf() { + return "+" + }, + toString() { + throw new Test262Error(); + } + }; + var x = new Array(object); + x.toString(); +}); + +assert.throws(TypeError, () => { + var object = { + valueOf() { + return {} + }, + toString() { + return {} + } + }; + var x = new Array(object); + x.toString(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A3_T1.js b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A3_T1.js new file mode 100644 index 0000000000..9c7b41558f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A3_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tostring +info: "[[Get]] from not an inherited property" +es5id: 15.4.4.2_A3_T1 +description: "[[Prototype]] of Array instance is Array.prototype" +---*/ + +Array.prototype[1] = 1; +var x = [0]; +x.length = 2; +if (x.toString() !== "0,1") { + throw new Test262Error('#1: Array.prototype[1] = 1; x = [0]; x.length = 2; x.toString() === "0,1". Actual: ' + (x.toString())); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/browser.js b/js/src/tests/test262/built-ins/Array/prototype/toString/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/toString/call-with-boolean.js new file mode 100644 index 0000000000..c3c1c20a01 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/call-with-boolean.js @@ -0,0 +1,20 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toString +description: Array.prototype.toString applied to boolean primitive +---*/ + +assert.sameValue( + Array.prototype.toString.call(true), + "[object Boolean]", + 'Array.prototype.toString.call(true) must return "[object Boolean]"' +); +assert.sameValue( + Array.prototype.toString.call(false), + "[object Boolean]", + 'Array.prototype.toString.call(false) must return "[object Boolean]"' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/length.js b/js/src/tests/test262/built-ins/Array/prototype/toString/length.js new file mode 100644 index 0000000000..d9f0df584e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/length.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-array.prototype.tostring +description: > + Array.prototype.toString.length is 0. +info: | + Array.prototype.toString ( ) + + 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] +---*/ + +assert.sameValue(Array.prototype.toString.length, 0); + +verifyNotEnumerable(Array.prototype.toString, "length"); +verifyNotWritable(Array.prototype.toString, "length"); +verifyConfigurable(Array.prototype.toString, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/name.js b/js/src/tests/test262/built-ins/Array/prototype/toString/name.js new file mode 100644 index 0000000000..d3fc9528d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tostring +description: > + Array.prototype.toString.name is "toString". +info: | + Array.prototype.toString ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.toString.name, "toString"); + +verifyNotEnumerable(Array.prototype.toString, "name"); +verifyNotWritable(Array.prototype.toString, "name"); +verifyConfigurable(Array.prototype.toString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/non-callable-join-string-tag.js b/js/src/tests/test262/built-ins/Array/prototype/toString/non-callable-join-string-tag.js new file mode 100644 index 0000000000..4b78762cd1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/non-callable-join-string-tag.js @@ -0,0 +1,69 @@ +// Copyright (C) 2021 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tostring +description: > + If "join" value is non-callable, Object.prototype.toString intrinsic is called. +info: | + Array.prototype.toString ( ) + + [...] + 2. Let func be ? Get(array, "join"). + 3. If IsCallable(func) is false, set func to the intrinsic function %Object.prototype.toString%. + 4. Return ? Call(func, array). +features: [Symbol.toStringTag, Proxy, Reflect, BigInt] +---*/ + +assert(delete Object.prototype.toString); + +assert.sameValue(Array.prototype.toString.call({ join: null }), "[object Object]"); +assert.sameValue(Array.prototype.toString.call({ join: true }), "[object Object]"); +assert.sameValue(Array.prototype.toString.call({ join: 0 }), "[object Object]"); +assert.sameValue(Array.prototype.toString.call({ join: "join" }), "[object Object]"); +assert.sameValue(Array.prototype.toString.call({ join: Symbol() }), "[object Object]"); +assert.sameValue(Array.prototype.toString.call({ join: 0n }), "[object Object]"); +assert.sameValue(Array.prototype.toString.call({ join: {} }), "[object Object]"); + +let revokeOnGet = false; +const proxyTarget = []; +const { proxy, revoke } = Proxy.revocable(proxyTarget, { + get: (target, key, receiver) => { + if (revokeOnGet) + revoke(); + return Reflect.get(target, key, receiver); + }, +}); + +proxyTarget.join = undefined; +assert.sameValue(Array.prototype.toString.call(proxy), "[object Array]"); +revokeOnGet = true; +assert.throws(TypeError, () => { Array.prototype.toString.call(proxy); }); + +assert.sameValue(Array.prototype.toString.call((function() { return arguments; })()), "[object Arguments]"); +assert.sameValue(Array.prototype.toString.call(new Error), "[object Error]"); +assert.sameValue(Array.prototype.toString.call(new Boolean), "[object Boolean]"); +assert.sameValue(Array.prototype.toString.call(new Number), "[object Number]"); +assert.sameValue(Array.prototype.toString.call(new String), "[object String]"); +assert.sameValue(Array.prototype.toString.call(new Date), "[object Date]"); +assert.sameValue(Array.prototype.toString.call(new RegExp), "[object RegExp]"); +assert.sameValue(Array.prototype.toString.call(new Proxy(() => {}, {})), "[object Function]"); +assert.sameValue(Array.prototype.toString.call(new Proxy(new Date, {})), "[object Object]"); +assert.sameValue(Array.prototype.toString.call({ [Symbol.toStringTag]: "Foo" }), "[object Foo]"); +assert.sameValue(Array.prototype.toString.call(new Map), "[object Map]"); + +RegExp.prototype[Symbol.toStringTag] = "Foo"; +assert.sameValue(Array.prototype.toString.call(new RegExp), "[object Foo]"); +Number.prototype[Symbol.toStringTag] = Object("Foo"); // ignored +assert.sameValue(Array.prototype.toString.call(new Number), "[object Number]"); + +Object.defineProperty(JSON, Symbol.toStringTag, { value: "Foo" }); +assert.sameValue(Array.prototype.toString.call(JSON), "[object Foo]"); + +assert(delete Set.prototype[Symbol.toStringTag]); +assert.sameValue(Array.prototype.toString.call(new Set), "[object Object]"); + +Object.defineProperty(Object.prototype, Symbol.toStringTag, { get: () => { throw new Test262Error(); } }); +assert.throws(Test262Error, () => { Array.prototype.toString.call({}); }); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/toString/not-a-constructor.js new file mode 100644 index 0000000000..a70534ffd1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/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: > + Array.prototype.toString 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.toString), + false, + 'isConstructor(Array.prototype.toString) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.toString(); +}, '`new Array.prototype.toString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/toString/prop-desc.js new file mode 100644 index 0000000000..d767d72252 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.tostring +description: > + "toString" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.toString, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "toString"); +verifyWritable(Array.prototype, "toString"); +verifyConfigurable(Array.prototype, "toString"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/shell.js b/js/src/tests/test262/built-ins/Array/prototype/toString/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A1_T1.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A1_T1.js new file mode 100644 index 0000000000..121386346c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A1_T1.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The arguments are prepended to the start of the array, such that + their order within the array is the same as the order in which they appear in + the argument list +esid: sec-array.prototype.unshift +description: Checking case when unsift is given no arguments or one argument +---*/ + +var x = new Array(); +var unshift = x.unshift(1); +if (unshift !== 1) { + throw new Test262Error('#1: x = new Array(); x.unshift(1) === 1. Actual: ' + (unshift)); +} + +if (x[0] !== 1) { + throw new Test262Error('#2: x = new Array(); x.unshift(1); x[0] === 1. Actual: ' + (x[0])); +} + +var unshift = x.unshift(); +if (unshift !== 1) { + throw new Test262Error('#3: x = new Array(); x.unshift(1); x.unshift() === 1. Actual: ' + (unshift)); +} + +if (x[1] !== undefined) { + throw new Test262Error('#4: x = new Array(); x.unshift(1); x.unshift(); x[1] === unedfined. Actual: ' + (x[1])); +} + +var unshift = x.unshift(-1); +if (unshift !== 2) { + throw new Test262Error('#5: x = new Array(); x.unshift(1); x.unshift(); x.unshift(-1) === 2. Actual: ' + (unshift)); +} + +if (x[0] !== -1) { + throw new Test262Error('#6: x = new Array(); x.unshift(1); x.unshift(-1); x[0] === -1. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#7: x = new Array(); x.unshift(1); x.unshift(-1); x[1] === 1. Actual: ' + (x[1])); +} + +if (x.length !== 2) { + throw new Test262Error('#8: x = new Array(); x.unshift(1); x.unshift(); x.unshift(-1); x.length === 2. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A1_T2.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A1_T2.js new file mode 100644 index 0000000000..be04543498 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A1_T2.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The arguments are prepended to the start of the array, such that + their order within the array is the same as the order in which they appear in + the argument list +esid: sec-array.prototype.unshift +description: Checking case when unsift is given many arguments +---*/ + +var x = []; +if (x.length !== 0) { + throw new Test262Error('#1: x = []; x.length === 0. Actual: ' + (x.length)); +} + +x[0] = 0; +var unshift = x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); +if (unshift !== 6) { + throw new Test262Error('#2: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1) === 6. Actual: ' + (unshift)); +} + +if (x[5] !== 0) { + throw new Test262Error('#3: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[5] === 0. Actual: ' + (x[5])); +} + +if (x[0] !== true) { + throw new Test262Error('#4: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[0] === true. Actual: ' + (x[0])); +} + +if (x[1] !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#5: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[1] === Number.POSITIVE_INFINITY. Actual: ' + (x[1])); +} + +if (x[2] !== "NaN") { + throw new Test262Error('#6: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[2] === "NaN". Actual: ' + (x[2])); +} + +if (x[3] !== "1") { + throw new Test262Error('#7: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[3] === "1". Actual: ' + (x[3])); +} + +if (x[4] !== -1) { + throw new Test262Error('#8: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[4] === -1. Actual: ' + (x[4])); +} + +if (x.length !== 6) { + throw new Test262Error('#9: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x.length === 6. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_T1.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_T1.js new file mode 100644 index 0000000000..272764f70d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_T1.js @@ -0,0 +1,61 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The unshift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.unshift +description: > + The arguments are prepended to the start of the array, such that + their order within the array is the same as the order in which + they appear in the argument list +---*/ + +var obj = {}; +obj.unshift = Array.prototype.unshift; + +if (obj.length !== undefined) { + throw new Test262Error('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + var unshift = obj.unshift(-1); + if (unshift !== 1) { + throw new Test262Error('#1: var obj = {}; obj.unshift = Array.prototype.unshift; obj.unshift(-1) === 1. Actual: ' + (unshift)); + } + if (obj.length !== 1) { + throw new Test262Error('#2: var obj = {}; obj.unshift = Array.prototype.unshift; obj.unshift(-1); obj.length === 1. Actual: ' + (obj.length)); + } + if (obj["0"] !== -1) { + throw new Test262Error('#3: var obj = {}; obj.unshift = Array.prototype.unshift; obj.unshift(-1); obj["0"] === -1. Actual: ' + (obj["0"])); + } +} + +obj.length = undefined; +var unshift = obj.unshift(-4); +if (unshift !== 1) { + throw new Test262Error('#4: var obj = {}; obj.length = undefined; obj.unshift = Array.prototype.unshift; obj.unshift(-4) === 1. Actual: ' + (unshift)); +} + +if (obj.length !== 1) { + throw new Test262Error('#5: var obj = {}; obj.length = undefined; obj.unshift = Array.prototype.unshift; obj.unshift(-4); obj.length === 1. Actual: ' + (obj.length)); +} + +if (obj["0"] !== -4) { + throw new Test262Error('#6: var obj = {}; obj.length = undefined; obj.unshift = Array.prototype.unshift; obj.unshift(-4); obj["0"] === -4. Actual: ' + (obj["0"])); +} + +obj.length = null +var unshift = obj.unshift(-7); +if (unshift !== 1) { + throw new Test262Error('#7: var obj = {}; obj.length = null; obj.unshift = Array.prototype.unshift; obj.unshift(-7) === 1. Actual: ' + (unshift)); +} + +if (obj.length !== 1) { + throw new Test262Error('#8: var obj = {}; obj.length = null; obj.unshift = Array.prototype.unshift; obj.unshift(-7); obj.length === 1. Actual: ' + (obj.length)); +} + +if (obj["0"] !== -7) { + throw new Test262Error('#9: var obj = {}; obj.length = null; obj.unshift = Array.prototype.unshift; obj.unshift(-7); obj["0"] === -7. Actual: ' + (obj["0"])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_T2.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_T2.js new file mode 100644 index 0000000000..152ab6e247 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_T2.js @@ -0,0 +1,88 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The unshift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.unshift +description: > + The arguments are prepended to the start of the array, such that + their order within the array is the same as the order in which + they appear in the argument list +---*/ + +var obj = {}; +obj.unshift = Array.prototype.unshift; + +obj.length = NaN; +var unshift = obj.unshift(-1); +if (unshift !== 1) { + throw new Test262Error('#1: var obj = {}; obj.length = NaN; obj.unshift = Array.prototype.unshift; obj.unshift(-1) === 1. Actual: ' + (unshift)); +} + +if (obj.length !== 1) { + throw new Test262Error('#2: var obj = {}; obj.length = NaN; obj.unshift = Array.prototype.unshift; obj.unshift(-1); obj.length === 1. Actual: ' + (obj.length)); +} + +if (obj["0"] !== -1) { + throw new Test262Error('#3: var obj = {}; obj.length = NaN; obj.unshift = Array.prototype.unshift; obj.unshift(-1); obj["0"] === -1. Actual: ' + (obj["0"])); +} + +obj.length = Number.NEGATIVE_INFINITY; +var unshift = obj.unshift(-7); +if (unshift !== 1) { + throw new Test262Error('#7: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.unshift = Array.prototype.unshift; obj.unshift(-7) === 1. Actual: ' + (unshift)); +} + +if (obj.length !== 1) { + throw new Test262Error('#8: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.unshift = Array.prototype.unshift; obj.unshift(-7); obj.length === 1. Actual: ' + (obj.length)); +} + +if (obj["0"] !== -7) { + throw new Test262Error('#9: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.unshift = Array.prototype.unshift; obj.unshift(-7); obj["0"] === -7. Actual: ' + (obj["0"])); +} + +obj.length = 0.5; +var unshift = obj.unshift(-10); +if (unshift !== 1) { + throw new Test262Error('#10: var obj = {}; obj.length = 0.5; obj.unshift = Array.prototype.unshift; obj.unshift(-10) === 1. Actual: ' + (unshift)); +} + +if (obj.length !== 1) { + throw new Test262Error('#11: var obj = {}; obj.length = 0.5; obj.unshift = Array.prototype.unshift; obj.unshift(-10); obj.length === 1. Actual: ' + (obj.length)); +} + +if (obj["0"] !== -10) { + throw new Test262Error('#12: var obj = {}; obj.length = 0.5; obj.unshift = Array.prototype.unshift; obj.unshift(-10); obj["0"] === -10. Actual: ' + (obj["0"])); +} + +obj.length = 1.5; +var unshift = obj.unshift(-13); +if (unshift !== 2) { + throw new Test262Error('#13: var obj = {}; obj.length = 1.5; obj.unshift = Array.prototype.unshift; obj.unshift(-13) === 2. Actual: ' + (unshift)); +} + +if (obj.length !== 2) { + throw new Test262Error('#14: var obj = {}; obj.length = 1.5; obj.unshift = Array.prototype.unshift; obj.unshift(-13); obj.length === 2. Actual: ' + (obj.length)); +} + +if (obj["0"] !== -13) { + throw new Test262Error('#15: var obj = {}; obj.length = 1.5; obj.unshift = Array.prototype.unshift; obj.unshift(-13); obj["0"] === -13. Actual: ' + (obj["0"])); +} + +obj.length = new Number(0); +var unshift = obj.unshift(-16); +if (unshift !== 1) { + throw new Test262Error('#16: var obj = {}; obj.length = new Number(0); obj.unshift = Array.prototype.unshift; obj.unshift(-16) === 1. Actual: ' + (unshift)); +} + +if (obj.length !== 1) { + throw new Test262Error('#17: var obj = {}; obj.length = new Number(0); obj.unshift = Array.prototype.unshift; obj.unshift(-16); obj.length === 1. Actual: ' + (obj.length)); +} + +if (obj["0"] !== -16) { + throw new Test262Error('#18: var obj = {}; obj.length = new Number(0); obj.unshift = Array.prototype.unshift; obj.unshift(-16); obj["0"] === -16. Actual: ' + (obj["0"])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_T3.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_T3.js new file mode 100644 index 0000000000..8979724e9b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_T3.js @@ -0,0 +1,120 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The unshift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.unshift +description: > + Operator use ToNumber from length. If Type(value) is Object, + evaluate ToPrimitive(value, Number) +---*/ + +var obj = {}; +obj.unshift = Array.prototype.unshift; + +obj.length = { + valueOf() { + return 3 + } +}; +var unshift = obj.unshift(); +assert.sameValue(unshift, 3, 'The value of unshift is expected to be 3'); + +obj.length = { + valueOf() { + return 3 + }, + toString() { + return 1 + } +}; +var unshift = obj.unshift(); +assert.sameValue(unshift, 3, 'The value of unshift is expected to be 3'); + +obj.length = { + valueOf() { + return 3 + }, + toString() { + return {} + } +}; +var unshift = obj.unshift(); +assert.sameValue(unshift, 3, 'The value of unshift is expected to be 3'); + +try { + obj.length = { + valueOf() { + return 3 + }, + toString() { + throw "error" + } + }; + var unshift = obj.unshift(); + assert.sameValue(unshift, 3, 'The value of unshift is expected to be 3'); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} + +obj.length = { + toString() { + return 1 + } +}; +var unshift = obj.unshift(); +assert.sameValue(unshift, 1, 'The value of unshift is expected to be 1'); + +obj.length = { + valueOf() { + return {} + }, + toString() { + return 1 + } +} +var unshift = obj.unshift(); +assert.sameValue(unshift, 1, 'The value of unshift is expected to be 1'); + +try { + + obj.length = { + valueOf() { + throw "error" + }, + toString() { + return 1 + } + }; + var unshift = obj.unshift(); + throw new Test262Error('#7.1: obj.length = {valueOf() {throw "error"}, toString() {return 1}}; obj.unshift() throw "error". Actual: ' + (unshift)); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} + +try { + + obj.length = { + valueOf() { + return {} + }, + toString() { + return {} + } + }; + var unshift = obj.unshift(); + throw new Test262Error('#8.1: obj.length = {valueOf() {return {}}, toString() {return {}}} obj.unshift() throw TypeError. Actual: ' + (unshift)); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A3_T2.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A3_T2.js new file mode 100644 index 0000000000..1634da4c16 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A3_T2.js @@ -0,0 +1,40 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.unshift +description: length = -4294967295 +---*/ + +var obj = {}; +obj.unshift = Array.prototype.unshift; +obj[0] = ""; +obj.length = -4294967295; + +var unshift = obj.unshift("x", "y", "z"); +if (unshift !== 3) { + throw new Test262Error('#1: var obj = {}; obj.unshift = Array.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z") === 3. Actual: ' + (unshift)); +} + +if (obj.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.unshift = Array.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z"); obj.length === 3. Actual: ' + (obj.length)); +} + +if (obj[0] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.unshift = Array.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z"); obj[0] === "x". Actual: ' + (obj[0])); +} + +if (obj[1] !== "y") { + throw new Test262Error('#4: var obj = {}; obj.unshift = Array.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z"); obj[1] === "y". Actual: ' + (obj[1])); +} + +if (obj[2] !== "z") { + throw new Test262Error('#5: var obj = {}; obj.unshift = Array.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z"); obj[2] === "z". Actual: ' + (obj[2])); +} + +if (obj[3] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.unshift = Array.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z"); obj[3] === undefined. Actual: ' + (obj[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A4_T1.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A4_T1.js new file mode 100644 index 0000000000..fb0cdeb78e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A4_T1.js @@ -0,0 +1,70 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.unshift +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Array.prototype[0] = -1; +var x = [1]; +x.length = 1; + +var unshift = x.unshift(0); +if (unshift !== 2) { + throw new Test262Error('#1: Array.prototype[0] = -1; x = [1]; x.length = 1; x.unshift(0) === 2. Actual: ' + (unshift)); +} + +if (x[0] !== 0) { + throw new Test262Error('#2: Array.prototype[0] = -1; x = [1]; x.length = 1; x.unshift(0); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#3: Array.prototype[0] = -1; x = [1]; x.length = 1; x.unshift(0); x[1] === 1. Actual: ' + (x[1])); +} + +delete x[0]; + +if (x[0] !== -1) { + throw new Test262Error('#4: Array.prototype[0] = -1; x = [1]; x.length = 1; x.unshift(0); delete x[0]; x[0] === -1. Actual: ' + (x[0])); +} + +Object.prototype[0] = -1; +Object.prototype.length = 1; +Object.prototype.unshift = Array.prototype.unshift; +x = { + 0: 1 +}; + +var unshift = x.unshift(0); +if (unshift !== 2) { + throw new Test262Error('#5: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.unshift = Array.prototype.unshift; x = {0:0}; x.unshift(0) === 2. Actual: ' + (unshift)); +} + +if (x[0] !== 0) { + throw new Test262Error('#6: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.unshift = Array.prototype.unshift; x = {0:0}; x.unshift(0); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#7: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.unshift = Array.prototype.unshift; x = {0:0}; x.unshift(0); x[1] === 1. Actual: ' + (x[1])); +} + +delete x[0]; + +if (x[0] !== -1) { + throw new Test262Error('#8: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.unshift = Array.prototype.unshift; x = {0:0}; x.unshift(0); delete x[0]; x[0] === -1. Actual: ' + (x[0])); +} + +if (x.length !== 2) { + throw new Test262Error('#9: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.unshift = Array.prototype.unshift; x = {0:0}; x.unshift(0); x.length === 1. Actual: ' + (x.length)); +} + +delete x.length; +if (x.length !== 1) { + throw new Test262Error('#10: Object.prototype[1] = -1; Object.prototype.length = 1; Object.prototype.unshift = Array.prototype.unshift; x = {0:0}; x.unshift(0); delete x; x.length === 1. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A4_T2.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A4_T2.js new file mode 100644 index 0000000000..bc63e8cf66 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A4_T2.js @@ -0,0 +1,68 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.unshift +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Array.prototype[0] = 1; +var x = []; +x.length = 1; + +var unshift = x.unshift(0); +if (unshift !== 2) { + throw new Test262Error('#1: Array.prototype[0] = 1; x = []; x.length = 1; x.unshift(0) === 2. Actual: ' + (unshift)); +} + +if (x[0] !== 0) { + throw new Test262Error('#2: Array.prototype[0] = 1; x = []; x.length = 1; x.unshift(0); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#3: Array.prototype[0] = 1; x = []; x.length = 1; x.unshift(0); x[1] === 1. Actual: ' + (x[1])); +} + +delete x[0]; + +if (x[0] !== 1) { + throw new Test262Error('#4: Array.prototype[0] = 1; x = [1]; x.length = 1; x.unshift(0); delete x[0]; x[0] === 1. Actual: ' + (x[0])); +} + +Object.prototype[0] = 1; +Object.prototype.length = 1; +Object.prototype.unshift = Array.prototype.unshift; +x = {}; + +var unshift = x.unshift(0); +if (unshift !== 2) { + throw new Test262Error('#5: Object.prototype[0] = 1; Object.prototype.length = 1; Object.prototype.unshift = Array.prototype.unshift; x = {}; x.unshift(0) === 2. Actual: ' + (unshift)); +} + +if (x[0] !== 0) { + throw new Test262Error('#6: Object.prototype[0] = 1; Object.prototype.length = 1; Object.prototype.unshift = Array.prototype.unshift; x = {}; x.unshift(0); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 1) { + throw new Test262Error('#7: Object.prototype[0] = 1; Object.prototype.length = 1; Object.prototype.unshift = Array.prototype.unshift; x = {}; x.unshift(0); x[1] === 1. Actual: ' + (x[1])); +} + +delete x[0]; + +if (x[0] !== 1) { + throw new Test262Error('#8: Object.prototype[0] = 1; Object.prototype.length = 1; Object.prototype.unshift = Array.prototype.unshift; x = {}; x.unshift(0); delete x[0]; x[0] === 1. Actual: ' + (x[0])); +} + +if (x.length !== 2) { + throw new Test262Error('#9: Object.prototype[0] = 1; Object.prototype.length = 1; Object.prototype.unshift = Array.prototype.unshift; x = {}; x.unshift(0); x.length === 1. Actual: ' + (x.length)); +} + +delete x.length; +if (x.length !== 1) { + throw new Test262Error('#10: Object.prototype[1] = 1; Object.prototype.length = 1; Object.prototype.unshift = Array.prototype.unshift; x = {}; x.unshift(0); delete x; x.length === 1. Actual: ' + (x.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/browser.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/call-with-boolean.js new file mode 100644 index 0000000000..1d01b147ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/call-with-boolean.js @@ -0,0 +1,12 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.unshift +description: Array.prototype.unshift applied to boolean primitive +---*/ + +assert.sameValue(Array.prototype.unshift.call(true), 0, 'Array.prototype.unshift.call(true) must return 0'); +assert.sameValue(Array.prototype.unshift.call(false), 0, 'Array.prototype.unshift.call(false) must return 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/clamps-to-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/clamps-to-integer-limit.js new file mode 100644 index 0000000000..82c3056f5e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/clamps-to-integer-limit.js @@ -0,0 +1,35 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.unshift +description: > + Length values exceeding 2^53-1 are clamped to 2^53-1. +info: | + 1. ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let argCount be the number of actual arguments. + 4. If argCount > 0, then ... + 5. Perform ? Set(O, "length", len+argCount, true). +features: [exponentiation] +---*/ + +var arrayLike = {}; + +arrayLike.length = 2 ** 53 - 1; +Array.prototype.unshift.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53 - 1"); + +arrayLike.length = 2 ** 53; +Array.prototype.unshift.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53"); + +arrayLike.length = 2 ** 53 + 2; +Array.prototype.unshift.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53 + 2"); + +arrayLike.length = Infinity; +Array.prototype.unshift.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/length-near-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/length-near-integer-limit.js new file mode 100644 index 0000000000..f73b36e447 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/length-near-integer-limit.js @@ -0,0 +1,63 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.unshift +description: > + Test properties are correctly accessed when length property is near 2^53-1. +info: | + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let argCount be the number of actual arguments. + 4. If argCount > 0, then + ... + b. Let k be len. + c. Repeat, while k > 0, + i. Let from be ! ToString(k-1). + ii. Let to be ! ToString(k+argCount-1). + iii. Let fromPresent be ? HasProperty(O, from). + iv. If fromPresent is true, then + 1. Let fromValue be ? Get(O, from). + 2. Perform ? Set(O, to, fromValue, true). + v. Else fromPresent is false, + 1. Perform ? DeletePropertyOrThrow(O, to). + vi. Decrease k by 1. +features: [exponentiation] +---*/ + +function StopUnshift() {} + +var arrayLike = { + get "9007199254740986" () { + throw new StopUnshift(); + }, + "9007199254740987": "9007199254740987", + /* "9007199254740988": hole */ + "9007199254740989": "9007199254740989", + /* "9007199254740990": empty */ + "9007199254740991": "9007199254740991", + length: 2 ** 53 - 2 +}; + +assert.throws(StopUnshift, function() { + Array.prototype.unshift.call(arrayLike, null); +}); + +assert.sameValue(arrayLike.length, 2 ** 53 - 2, + "arrayLike.length is unchanged"); + +assert.sameValue(arrayLike["9007199254740987"], "9007199254740987", + "arrayLike['9007199254740987'] is unchanged"); + +assert.sameValue(arrayLike["9007199254740988"], "9007199254740987", + "arrayLike['9007199254740988'] is replaced with arrayLike['9007199254740987']"); + +assert.sameValue("9007199254740989" in arrayLike, false, + "arrayLike['9007199254740989'] is removed"); + +assert.sameValue(arrayLike["9007199254740990"], "9007199254740989", + "arrayLike['9007199254740990'] is replaced with arrayLike['9007199254740989']"); + +assert.sameValue(arrayLike["9007199254740991"], "9007199254740991", + "arrayLike['9007199254740991'] is unchanged"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/length.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/length.js new file mode 100644 index 0000000000..e99bffa6d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.unshift +description: > + The "length" property of Array.prototype.unshift +info: | + 22.1.3.29 Array.prototype.unshift ( ...items ) + + The length property of the unshift method is 1. + + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +---*/ + +assert.sameValue(Array.prototype.unshift.length, 1); + +verifyNotEnumerable(Array.prototype.unshift, 'length'); +verifyNotWritable(Array.prototype.unshift, 'length'); +verifyConfigurable(Array.prototype.unshift, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/name.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/name.js new file mode 100644 index 0000000000..4caa8c29b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.unshift +description: > + Array.prototype.unshift.name is "unshift". +info: | + Array.prototype.unshift ( ...items ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.unshift.name, "unshift"); + +verifyNotEnumerable(Array.prototype.unshift, "name"); +verifyNotWritable(Array.prototype.unshift, "name"); +verifyConfigurable(Array.prototype.unshift, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/not-a-constructor.js new file mode 100644 index 0000000000..415a6e738d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/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: > + Array.prototype.unshift 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.unshift), + false, + 'isConstructor(Array.prototype.unshift) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.unshift(); +}, '`new Array.prototype.unshift()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/prop-desc.js new file mode 100644 index 0000000000..6eee7edd19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.unshift +description: > + "unshift" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.unshift, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "unshift"); +verifyWritable(Array.prototype, "unshift"); +verifyConfigurable(Array.prototype, "unshift"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-array-is-frozen.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-array-is-frozen.js new file mode 100644 index 0000000000..912e021aaa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-array-is-frozen.js @@ -0,0 +1,50 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.unshift +description: > + A TypeError is thrown when "length" is [[Set]] on a frozen array. +info: | + Array.prototype.unshift ( ...items ) + + [...] + 4. If argCount > 0, then + [...] + d. Let j be +0𝔽. + e. For each element E of items, do + i. Perform ? Set(O, ! ToString(j), E, true). + ii. Set j to j + 1𝔽. + 5. Perform ? Set(O, "length", 𝔽(len + argCount), true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = []; +var arrayPrototypeSet0Calls = 0; + +Object.defineProperty(Array.prototype, "0", { + set(_val) { + Object.freeze(array); + arrayPrototypeSet0Calls++; + }, +}); + +assert.throws(TypeError, function() { + array.unshift(1); +}); + +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); +assert.sameValue(arrayPrototypeSet0Calls, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-array-length-is-non-writable.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-array-length-is-non-writable.js new file mode 100644 index 0000000000..9ce38b5d93 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-array-length-is-non-writable.js @@ -0,0 +1,50 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.unshift +description: > + A TypeError is thrown when "length" is [[Set]] on an array with non-writable "length". +info: | + Array.prototype.unshift ( ...items ) + + [...] + 4. If argCount > 0, then + [...] + d. Let j be +0𝔽. + e. For each element E of items, do + i. Perform ? Set(O, ! ToString(j), E, true). + ii. Set j to j + 1𝔽. + 5. Perform ? Set(O, "length", 𝔽(len + argCount), true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = []; +var arrayPrototypeSet0Calls = 0; + +Object.defineProperty(Array.prototype, "0", { + set(_val) { + Object.defineProperty(array, "length", { writable: false }); + arrayPrototypeSet0Calls++; + }, +}); + +assert.throws(TypeError, function() { + array.unshift(1); +}); + +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); +assert.sameValue(arrayPrototypeSet0Calls, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-zero-array-is-frozen.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-zero-array-is-frozen.js new file mode 100644 index 0000000000..0896cb8a25 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-zero-array-is-frozen.js @@ -0,0 +1,38 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.unshift +description: > + A TypeError is thrown when "length" is [[Set]] on an empty frozen array. +info: | + Array.prototype.unshift ( ...items ) + + [...] + 2. Let len be ? LengthOfArrayLike(O). + [...] + 5. Perform ? Set(O, "length", 𝔽(len + argCount), true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = []; +Object.freeze(array); + +assert.throws(TypeError, function() { + array.unshift(); +}); + +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-zero-array-length-is-non-writable.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-zero-array-length-is-non-writable.js new file mode 100644 index 0000000000..c6fa486c03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/set-length-zero-array-length-is-non-writable.js @@ -0,0 +1,38 @@ +// Copyright (C) 2022 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.unshift +description: > + A TypeError is thrown when "length" is [[Set]] on an empty array with non-writable "length". +info: | + Array.prototype.unshift ( ...items ) + + [...] + 2. Let len be ? LengthOfArrayLike(O). + [...] + 5. Perform ? Set(O, "length", 𝔽(len + argCount), true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + + Set ( O, P, V, Throw ) + + [...] + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var array = []; +Object.defineProperty(array, "length", { writable: false }); + +assert.throws(TypeError, function() { + array.unshift(); +}); + +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/shell.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/throws-if-integer-limit-exceeded.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/throws-if-integer-limit-exceeded.js new file mode 100644 index 0000000000..0e9ceada82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/throws-if-integer-limit-exceeded.js @@ -0,0 +1,40 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.unshift +description: > + A TypeError is thrown if the new length exceeds 2^53-1. +info: | + 1. ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let argCount be the number of actual arguments. + 4. If argCount > 0, then + a. If len+argCount > 2^53-1, throw a TypeError exception. + b. ... +features: [exponentiation] +---*/ + +var arrayLike = {}; + +arrayLike.length = 2 ** 53 - 1; +assert.throws(TypeError, function() { + Array.prototype.unshift.call(arrayLike, null); +}, "Length is 2**53 - 1"); + +arrayLike.length = 2 ** 53; +assert.throws(TypeError, function() { + Array.prototype.unshift.call(arrayLike, null); +}, "Length is 2**53"); + +arrayLike.length = 2 ** 53 + 2; +assert.throws(TypeError, function() { + Array.prototype.unshift.call(arrayLike, null); +}, "Length is 2**53 + 2"); + +arrayLike.length = Infinity; +assert.throws(TypeError, function() { + Array.prototype.unshift.call(arrayLike, null); +}, "Length is Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/throws-with-string-receiver.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/throws-with-string-receiver.js new file mode 100644 index 0000000000..7db1e088fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/throws-with-string-receiver.js @@ -0,0 +1,47 @@ +// Copyright (C) 2020 Sony Interactive Entertainment Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.unshift +description: > + Array#unshift throws TypeError upon attempting to modify a string +info: | + Array.prototype.unshift ( ...items ) + ... + 4. If argCount > 0, then + ... + c. Repeat, while k > 0, + ... + iv. If fromPresent is true, then + ... + 2. Perform ? Set(O, to, fromValue, true). + ... + ... + f. Repeat, while items is not empty + ... + Perform ? Set(O, ! ToString(j), E, true). + ... + 5. Perform ? Set(O, "length", len + argCount, true). + + Set ( O, P, V, Throw ) + ... + 4. Let success be ? O.[[Set]](P, V, O). + 5. If success is false and Throw is true, throw a TypeError exception. +---*/ + +assert.throws(TypeError, () => { + Array.prototype.unshift.call(''); +}, "Array.prototype.unshift.call('')"); + +assert.throws(TypeError, () => { + Array.prototype.unshift.call('', 1); +}, "Array.prototype.unshift.call('', 1)"); + +assert.throws(TypeError, () => { + Array.prototype.unshift.call('abc'); +}, "Array.prototype.unshift.call('abc')"); + +assert.throws(TypeError, () => { + Array.prototype.unshift.call('abc', 1); +}, "Array.prototype.unshift.call('abc', 1)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/values/browser.js b/js/src/tests/test262/built-ins/Array/prototype/values/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/values/iteration-mutable.js b/js/src/tests/test262/built-ins/Array/prototype/values/iteration-mutable.js new file mode 100644 index 0000000000..02a7bce3b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/values/iteration-mutable.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-array.prototype.values +description: > + New items in the array are accessible via iteration until iterator is "done". +info: | + When an item is added to the array after the iterator is created but + before the iterator is "done" (as defined by 22.1.5.2.1), the new item's + value should be accessible via iteration. When an item is added to the + array after the iterator is "done", the new item should not be + accessible via iteration. +---*/ + +var array = []; +var iterator = array.values(); +var result; + +array.push('a'); + +result = iterator.next(); +assert.sameValue(result.done, false, 'First result `done` flag'); +assert.sameValue(result.value, 'a', 'First result `value`'); + +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); + +array.push('b'); + +result = iterator.next(); +assert.sameValue( + result.done, true, + 'Exhausted result `done` flag (after push)' +); +assert.sameValue( + result.value, undefined, + 'Exhausted result `value` (after push)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/values/iteration.js b/js/src/tests/test262/built-ins/Array/prototype/values/iteration.js new file mode 100644 index 0000000000..c5e6f232a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/values/iteration.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-array.prototype.values +description: > + The return is a valid iterator with the array's numeric properties. +info: | + 22.1.3.29 Array.prototype.values ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "value"). +---*/ + +var array = ['a', 'b', 'c']; +var iterator = array.values(); +var result; + +result = iterator.next(); +assert.sameValue(result.value, 'a', 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 'b', 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 'c', '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'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/values/length.js b/js/src/tests/test262/built-ins/Array/prototype/values/length.js new file mode 100644 index 0000000000..c87379d29f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/values/length.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-array.prototype.values +description: Array.prototype.values `length` property +info: | + ES6 Section 17: + 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. + + [...] + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.values.length, 0); + +verifyNotEnumerable(Array.prototype.values, 'length'); +verifyNotWritable(Array.prototype.values, 'length'); +verifyConfigurable(Array.prototype.values, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/values/name.js b/js/src/tests/test262/built-ins/Array/prototype/values/name.js new file mode 100644 index 0000000000..71eb0fb243 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/values/name.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-array.prototype.values +description: Array.prototype.values `name` property +info: | + ES6 Section 17: + + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value is a + String. Unless otherwise specified, this value is the name that is given to + the function in this specification. + + [...] + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.values.name, 'values'); + +verifyNotEnumerable(Array.prototype.values, 'name'); +verifyNotWritable(Array.prototype.values, 'name'); +verifyConfigurable(Array.prototype.values, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/values/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/values/not-a-constructor.js new file mode 100644 index 0000000000..2afdde1e37 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/values/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: > + Array.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, Array.prototype.values, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.values), + false, + 'isConstructor(Array.prototype.values) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.values(); +}, '`new Array.prototype.values()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/values/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/values/prop-desc.js new file mode 100644 index 0000000000..111d637b8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/values/prop-desc.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-array.prototype.values +description: Array.prototype.values property descriptor +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.values, 'function'); + +verifyNotEnumerable(Array.prototype, 'values'); +verifyWritable(Array.prototype, 'values'); +verifyConfigurable(Array.prototype, 'values'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/values/returns-iterator-from-object.js b/js/src/tests/test262/built-ins/Array/prototype/values/returns-iterator-from-object.js new file mode 100644 index 0000000000..8bf0aa1d06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/values/returns-iterator-from-object.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-array.prototype.values +description: > + Creates an iterator from a custom object. +info: | + 22.1.3.29 Array.prototype.values ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "value"). +features: [Symbol.iterator] +---*/ + +var obj = { + length: 2 +}; +var iter = Array.prototype.values.call(obj); +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].values() is %ArrayIteratorPrototype%' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/values/returns-iterator.js b/js/src/tests/test262/built-ins/Array/prototype/values/returns-iterator.js new file mode 100644 index 0000000000..f3cabffaea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/values/returns-iterator.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-array.prototype.values +description: > + The method should return an Iterator instance. +info: | + 22.1.3.29 Array.prototype.values ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "value"). + + 22.1.5.1 CreateArrayIterator Abstract Operation + + ... + 2. Let iterator be ObjectCreate(%ArrayIteratorPrototype%, «‍[[IteratedObject]], + [[ArrayIteratorNextIndex]], [[ArrayIterationKind]]»). + ... + 6. Return iterator. +features: [Symbol.iterator] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); +var iter = [].values(); + +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].values() is %ArrayIteratorPrototype%' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/values/shell.js b/js/src/tests/test262/built-ins/Array/prototype/values/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/values/this-val-non-obj-coercible.js b/js/src/tests/test262/built-ins/Array/prototype/values/this-val-non-obj-coercible.js new file mode 100644 index 0000000000..843a6274ba --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/values/this-val-non-obj-coercible.js @@ -0,0 +1,20 @@ +// 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-array.prototype.values +description: > + `this` value not object coercible +info: | + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +assert.throws(TypeError, function() { + Array.prototype.values.call(undefined); +}); + +assert.throws(TypeError, function() { + Array.prototype.values.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/browser.js b/js/src/tests/test262/built-ins/Array/prototype/with/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/frozen-this-value.js b/js/src/tests/test262/built-ins/Array/prototype/with/frozen-this-value.js new file mode 100644 index 0000000000..73cdc284c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/frozen-this-value.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with works on frozen objects +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = Object.freeze([0, 1, 2]); +var result = arr.with(1, 3); +assert.compareArray(result, [0, 3, 2]); + +var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); +var result2 = Array.prototype.with.call(arrayLike, 1, 3); +assert.compareArray(result2, [0, 3, 2]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/holes-not-preserved.js b/js/src/tests/test262/built-ins/Array/prototype/with/holes-not-preserved.js new file mode 100644 index 0000000000..faefdc173d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/holes-not-preserved.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with does not preserve holes in the array +info: | + Array.prototype.with ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 5. Repeat, while k < len + a. Let Pk be ! ToString(𝔽(k)). + b. If k is actualIndex, let fromValue be value. + c. Else, let fromValue be ? Get(O, Pk). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, /* hole */, 2, /* hole */, 4]; +Array.prototype[3] = 3; + +var result = arr.with(2, 6); +assert.compareArray(result, [0, undefined, 6, 3, 4]); +assert(result.hasOwnProperty(1)); +assert(result.hasOwnProperty(3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/ignores-species.js b/js/src/tests/test262/built-ins/Array/prototype/with/ignores-species.js new file mode 100644 index 0000000000..7b198186fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/ignores-species.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with ignores @@species +info: | + Array.prototype.with ( ) + + ... + 8. Let A be ? ArrayCreate(𝔽(len)). + ... +features: [change-array-by-copy] +---*/ + +var a = [1, 2, 3]; +a.constructor = {}; +a.constructor[Symbol.species] = function () {} + +assert.sameValue(Object.getPrototypeOf(a.with(0, 0)), Array.prototype); + +var b = [1, 2, 3]; +Object.defineProperty(b, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } +}); + +b.with(0, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/immutable.js b/js/src/tests/test262/built-ins/Array/prototype/with/immutable.js new file mode 100644 index 0000000000..04c1621dff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/immutable.js @@ -0,0 +1,19 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with does not mutate its this value +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2]; +arr.with(1, 3); + +assert.compareArray(arr, [0, 1, 2]); +assert.notSameValue(arr.with(1, 3), arr); +assert.notSameValue(arr.with(1, 1), arr); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js b/js/src/tests/test262/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js new file mode 100644 index 0000000000..752b280db7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js @@ -0,0 +1,37 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with throws if the index is bigger than or equal to the array length. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + 6. If actualIndex >= len or actualIndex < 0, throw a *RangeError* exception. + ... +features: [change-array-by-copy, exponentiation] +---*/ + +assert.throws(RangeError, function() { + [0, 1, 2].with(3, 7); +}); + +assert.throws(RangeError, function() { + [0, 1, 2].with(10, 7); +}); + +assert.throws(RangeError, function() { + [0, 1, 2].with(2 ** 53 + 2, 7); +}); + +assert.throws(RangeError, function() { + [0, 1, 2].with(Infinity, 7); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/index-casted-to-number.js b/js/src/tests/test262/built-ins/Array/prototype/with/index-casted-to-number.js new file mode 100644 index 0000000000..e0543723e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/index-casted-to-number.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with casts the index to an integer. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 4, 16]; + +assert.compareArray(arr.with(1.2, 7), [0, 7, 16]); +assert.compareArray(arr.with("1", 3), [0, 3, 16]); +assert.compareArray(arr.with("-1", 5), [0, 4, 5]); +assert.compareArray(arr.with(NaN, 2), [2, 4, 16]); +assert.compareArray(arr.with("dog", "cat"), ["cat", 4, 16]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/index-negative.js b/js/src/tests/test262/built-ins/Array/prototype/with/index-negative.js new file mode 100644 index 0000000000..d9b8a8eaac --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/index-negative.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with adds length to index if it's negative. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2]; + +assert.compareArray(arr.with(-1, 4), [0, 1, 4]); +assert.compareArray(arr.with(-3, 4), [4, 1, 2]); + +// -0 is not < 0 +assert.compareArray(arr.with(-0, 4), [4, 1, 2]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/index-smaller-than-minus-length.js b/js/src/tests/test262/built-ins/Array/prototype/with/index-smaller-than-minus-length.js new file mode 100644 index 0000000000..d1f98336ab --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/index-smaller-than-minus-length.js @@ -0,0 +1,39 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with throws if the (negative) index is smaller than -length. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + 6. If actualIndex >= len or actualIndex < 0, throw a *RangeError* exception. + ... +features: [change-array-by-copy, exponentiation] +---*/ + +[0, 1, 2].with(-3, 7); + +assert.throws(RangeError, function() { + [0, 1, 2].with(-4, 7); +}); + +assert.throws(RangeError, function() { + [0, 1, 2].with(-10, 7); +}); + +assert.throws(RangeError, function() { + [0, 1, 2].with(-(2 ** 53) - 2, 7); +}); + +assert.throws(RangeError, function() { + [0, 1, 2].with(-Infinity, 7); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/length-decreased-while-iterating.js b/js/src/tests/test262/built-ins/Array/prototype/with/length-decreased-while-iterating.js new file mode 100644 index 0000000000..8102da0e52 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/length-decreased-while-iterating.js @@ -0,0 +1,42 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with caches the length getting the array elements. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 5. Repeat, while k < len + a. Let Pk be ! ToString(𝔽(k)). + b. If k is actualIndex, let fromValue be value. + c. Else, let fromValue be ? Get(O, Pk). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +Array.prototype[4] = 5; + +var arr = Object.defineProperty([0, 1, 2, 3, 4], "1", { + get() { + arr.length = 1; + return 1; + } +}); +assert.compareArray(arr.with(2, 7), [0, 1, 7, undefined, 5]); + +arr = Object.defineProperty([0, 1, 2, 3, 4], "1", { + get() { + arr.length = 1; + return 1; + } +}); +assert.compareArray(arr.with(0, 7), [7, 1, undefined, undefined, 5]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js b/js/src/tests/test262/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js new file mode 100644 index 0000000000..76dd9cf5ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js @@ -0,0 +1,41 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with limits the length to 2 ** 32 - 1 +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 7. Let A be ? ArrayCreate(𝔽(len)). + ... + + ArrayCreate ( length [, proto ] ) + + 1. If length > 2 ** 32 - 1, throw a RangeError exception. +features: [change-array-by-copy, exponentiation] +---*/ + +// Object with large "length" property +var arrayLike = { + get "0"() { + throw new Test262Error("Get 0"); + }, + get "4294967295" () { // 2 ** 32 - 1 + throw new Test262Error("Get 4294967295"); + }, + get "4294967296" () { // 2 ** 32 + throw new Test262Error("Get 4294967296"); + }, + length: 2 ** 32 +}; + +assert.throws(RangeError, function() { + Array.prototype.with.call(arrayLike, 0, 0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/length-increased-while-iterating.js b/js/src/tests/test262/built-ins/Array/prototype/with/length-increased-while-iterating.js new file mode 100644 index 0000000000..01e3147e51 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/length-increased-while-iterating.js @@ -0,0 +1,34 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with caches the length getting the array elements. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 5. Repeat, while k < len + a. Let Pk be ! ToString(𝔽(k)). + b. If k is actualIndex, let fromValue be value. + c. Else, let fromValue be ? Get(O, Pk). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2]; +Object.defineProperty(arr, "0", { + get() { + arr.push(4); + return 0; + } +}); + +assert.compareArray(arr.with(1, 4), [0, 4, 2]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/length-tolength.js b/js/src/tests/test262/built-ins/Array/prototype/with/length-tolength.js new file mode 100644 index 0000000000..2573c8532f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/length-tolength.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with converts the this value length to a number. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arrayLike = { length: "2", 0: 1, 1: 2, 2: 3 }; +assert.compareArray(Array.prototype.with.call(arrayLike, 0, 4), [4, 2]); + +var arrayLike = { + length: { + valueOf: () => 2 + }, + 0: 1, + 1: 2, + 2: 3, +}; + +assert.compareArray(Array.prototype.with.call(arrayLike, 0, 4), [4, 2]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/metadata/browser.js b/js/src/tests/test262/built-ins/Array/prototype/with/metadata/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/metadata/length.js b/js/src/tests/test262/built-ins/Array/prototype/with/metadata/length.js new file mode 100644 index 0000000000..7fac787816 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/metadata/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + The "length" property of Array.prototype.with +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.with, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/metadata/name.js b/js/src/tests/test262/built-ins/Array/prototype/with/metadata/name.js new file mode 100644 index 0000000000..108a0b9a7e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/metadata/name.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with.name is "with". +info: | + Array.prototype.with ( index, value ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.with, "name", { + value: "with", + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/metadata/property-descriptor.js b/js/src/tests/test262/built-ins/Array/prototype/with/metadata/property-descriptor.js new file mode 100644 index 0000000000..2c43f28ec6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/metadata/property-descriptor.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + "with" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +assert.sameValue(typeof Array.prototype.with, "function", "typeof"); + +verifyProperty(Array.prototype, "with", { + value: Array.prototype.with, + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/metadata/shell.js b/js/src/tests/test262/built-ins/Array/prototype/with/metadata/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/no-get-replaced-index.js b/js/src/tests/test262/built-ins/Array/prototype/with/no-get-replaced-index.js new file mode 100644 index 0000000000..91c77a539e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/no-get-replaced-index.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with does not [[Get]] the value in the replaced position +info: | + Array.prototype.with ( ) + + ... + 5. Repeat, while k < len + a. Let Pk be ! ToString(𝔽(k)). + b. If k is actualIndex, let fromValue be value. + c. Else, let fromValue be ? Get(O, Pk). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "2", { + get() { + throw new Test262Error("Should not get '2'"); + } +}); + +var result = arr.with(2, 6); +assert.compareArray(result, [0, 1, 6, 3]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/with/not-a-constructor.js new file mode 100644 index 0000000000..257a21aa51 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.with 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: [change-array-by-copy, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.with), + false, + 'isConstructor(Array.prototype.with) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.with(); +}, '`new Array.prototype.with()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/shell.js b/js/src/tests/test262/built-ins/Array/prototype/with/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/this-value-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/with/this-value-boolean.js new file mode 100644 index 0000000000..453817c2a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/this-value-boolean.js @@ -0,0 +1,41 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with casts primitive receivers to objects +info: | + Array.prototype.with ( index, value ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +Boolean.prototype.length = 2; +Boolean.prototype[0] = 0; +Boolean.prototype[1] = 1; + +assert.compareArray(Array.prototype.with.call(true, 0, 2), [2, 1]); +assert.compareArray(Array.prototype.with.call(false, 0, 2), [2, 1]); + +/* Add length and indexed properties to `Boolean.prototype` */ +Boolean.prototype.length = 3; +delete Boolean.prototype[0]; +delete Boolean.prototype[1]; +assert.compareArray(Array.prototype.with.call(true, 0, 2), [2, undefined, undefined]); +assert.compareArray(Array.prototype.with.call(false, 0, 2), [2, undefined, undefined]); +delete Boolean.prototype.length; +Boolean.prototype[0] = "monkeys"; +Boolean.prototype[2] = "bogus"; +assert.throws(RangeError, + () => compareArray(Array.prototype.with.call(true, 0, 2)), + "Array.prototype.with on object with undefined length"); +assert.throws(RangeError, + () => compareArray(Array.prototype.with.call(false, 0, 2)), + "Array.prototype.with on object with undefined length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/this-value-nullish.js b/js/src/tests/test262/built-ins/Array/prototype/with/this-value-nullish.js new file mode 100644 index 0000000000..befef0642d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/with/this-value-nullish.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with throws if the receiver is null or undefined +info: | + Array.prototype.with ( index, value ) + + 1. Let O be ? ToObject(this value). + ... +features: [change-array-by-copy] +---*/ + +assert.throws(TypeError, () => { + Array.prototype.with.call(null, 0, 0); +}, '`Array.prototype.with.call(null, 0, 0)` throws TypeError'); + +assert.throws(TypeError, () => { + Array.prototype.with.call(undefined, 0, 0); +}, '`Array.prototype.with.call(undefined, 0, 0)` throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/shell.js b/js/src/tests/test262/built-ins/Array/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/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; +} -- cgit v1.2.3