From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.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 | 22 + .../test262/built-ins/Array/S15.4.1_A1.1_T2.js | 27 + .../test262/built-ins/Array/S15.4.1_A1.1_T3.js | 18 + .../test262/built-ins/Array/S15.4.1_A1.2_T1.js | 24 + .../test262/built-ins/Array/S15.4.1_A1.3_T1.js | 24 + .../test262/built-ins/Array/S15.4.1_A2.1_T1.js | 27 + .../test262/built-ins/Array/S15.4.1_A2.2_T1.js | 40 + .../test262/built-ins/Array/S15.4.1_A3.1_T1.js | 22 + .../test262/built-ins/Array/S15.4.2.1_A1.1_T1.js | 27 + .../test262/built-ins/Array/S15.4.2.1_A1.1_T2.js | 27 + .../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 | 24 + .../test262/built-ins/Array/S15.4.2.1_A1.3_T1.js | 24 + .../test262/built-ins/Array/S15.4.2.1_A2.1_T1.js | 27 + .../test262/built-ins/Array/S15.4.2.1_A2.2_T1.js | 40 + .../test262/built-ins/Array/S15.4.3_A1.1_T1.js | 26 + .../test262/built-ins/Array/S15.4.3_A1.1_T2.js | 18 + .../test262/built-ins/Array/S15.4.3_A1.1_T3.js | 17 + .../test262/built-ins/Array/S15.4.5.1_A1.2_T2.js | 27 + .../test262/built-ins/Array/S15.4.5.1_A2.1_T1.js | 45 + .../test262/built-ins/Array/S15.4.5.1_A2.2_T1.js | 31 + .../test262/built-ins/Array/S15.4.5.1_A2.3_T1.js | 25 + .../test262/built-ins/Array/S15.4.5.2_A1_T1.js | 43 + .../test262/built-ins/Array/S15.4.5.2_A1_T2.js | 28 + .../test262/built-ins/Array/S15.4.5.2_A2_T1.js | 36 + .../test262/built-ins/Array/S15.4.5.2_A3_T1.js | 33 + .../test262/built-ins/Array/S15.4.5.2_A3_T2.js | 52 + .../test262/built-ins/Array/S15.4.5.2_A3_T3.js | 30 + .../test262/built-ins/Array/S15.4_A1.1_T10.js | 28 + .../tests/test262/built-ins/Array/S15.4_A1.1_T4.js | 26 + .../tests/test262/built-ins/Array/S15.4_A1.1_T5.js | 36 + .../tests/test262/built-ins/Array/S15.4_A1.1_T6.js | 35 + .../tests/test262/built-ins/Array/S15.4_A1.1_T7.js | 33 + .../tests/test262/built-ins/Array/S15.4_A1.1_T8.js | 33 + .../tests/test262/built-ins/Array/S15.4_A1.1_T9.js | 145 ++ .../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 | 15 + .../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 | 38 + .../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 | 68 + .../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 | 52 + .../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 | 33 + 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 | 13 + .../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 + .../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 | 15 + .../built-ins/Array/isArray/15.4.3.2-0-4.js | 24 + .../built-ins/Array/isArray/15.4.3.2-0-5.js | 16 + .../built-ins/Array/isArray/15.4.3.2-0-6.js | 15 + .../built-ins/Array/isArray/15.4.3.2-0-7.js | 16 + .../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 | 15 + .../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 | 23 + .../built-ins/Array/length/S15.4.2.2_A1.1_T2.js | 21 + .../built-ins/Array/length/S15.4.2.2_A1.1_T3.js | 19 + .../built-ins/Array/length/S15.4.2.2_A1.2_T1.js | 18 + .../built-ins/Array/length/S15.4.2.2_A2.1_T1.js | 31 + .../built-ins/Array/length/S15.4.2.2_A2.2_T1.js | 43 + .../built-ins/Array/length/S15.4.2.2_A2.2_T2.js | 43 + .../built-ins/Array/length/S15.4.2.2_A2.2_T3.js | 43 + .../built-ins/Array/length/S15.4.2.2_A2.3_T1.js | 38 + .../built-ins/Array/length/S15.4.2.2_A2.3_T2.js | 39 + .../built-ins/Array/length/S15.4.2.2_A2.3_T3.js | 39 + .../built-ins/Array/length/S15.4.2.2_A2.3_T4.js | 53 + .../built-ins/Array/length/S15.4.2.2_A2.3_T5.js | 53 + .../built-ins/Array/length/S15.4.4_A1.3_T1.js | 16 + .../built-ins/Array/length/S15.4.5.1_A1.1_T1.js | 44 + .../built-ins/Array/length/S15.4.5.1_A1.1_T2.js | 55 + .../built-ins/Array/length/S15.4.5.1_A1.2_T1.js | 33 + .../built-ins/Array/length/S15.4.5.1_A1.2_T3.js | 29 + .../built-ins/Array/length/S15.4.5.1_A1.3_T1.js | 53 + .../built-ins/Array/length/S15.4.5.1_A1.3_T2.js | 138 ++ .../built-ins/Array/length/S15.4.5.2_A3_T4.js | 40 + .../test262/built-ins/Array/length/browser.js | 0 .../define-own-prop-length-coercion-order-set.js | 45 + .../define-own-prop-length-coercion-order.js | 60 + .../define-own-prop-length-no-value-order.js | 58 + .../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 | 31 + .../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 | 17 + .../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 .../Array/prototype/Symbol.unscopables/browser.js | 0 .../prototype/Symbol.unscopables/prop-desc.js | 18 + .../Array/prototype/Symbol.unscopables/shell.js | 0 .../Array/prototype/Symbol.unscopables/value.js | 81 + .../built-ins/Array/prototype/at/browser.js | 0 .../Array/prototype/at/index-argument-tointeger.js | 30 + ...index-non-numeric-argument-tointeger-invalid.js | 23 + .../at/index-non-numeric-argument-tointeger.js | 29 + .../test262/built-ins/Array/prototype/at/length.js | 27 + .../test262/built-ins/Array/prototype/at/name.js | 29 + .../built-ins/Array/prototype/at/prop-desc.js | 29 + .../Array/prototype/at/return-abrupt-from-this.js | 25 + .../prototype/at/returns-item-relative-index.js | 33 + .../built-ins/Array/prototype/at/returns-item.js | 34 + ...returns-undefined-for-holes-in-sparse-arrays.js | 46 + .../at/returns-undefined-for-out-of-range-index.js | 23 + .../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 | 27 + ...pe.concat_array-like-length-to-string-throws.js | 27 + ...ype.concat_array-like-length-value-of-throws.js | 27 + ....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 | 19 + .../Array.prototype.concat_large-typed-array.js | 51 + .../concat/Array.prototype.concat_length-throws.js | 28 + .../concat/Array.prototype.concat_no-prototype.js | 12 + .../concat/Array.prototype.concat_non-array.js | 27 + ...ray.prototype.concat_sloppy-arguments-throws.js | 25 + ...prototype.concat_sloppy-arguments-with-dupes.js | 24 + .../Array.prototype.concat_sloppy-arguments.js | 23 + .../Array.prototype.concat_small-typed-array.js | 50 + ....prototype.concat_spreadable-boolean-wrapper.js | 39 + .../Array.prototype.concat_spreadable-function.js | 34 + ...ay.prototype.concat_spreadable-getter-throws.js | 27 + ...y.prototype.concat_spreadable-number-wrapper.js | 39 + .../Array.prototype.concat_spreadable-reg-exp.js | 37 + ...ay.prototype.concat_spreadable-sparse-object.js | 21 + ...y.prototype.concat_spreadable-string-wrapper.js | 28 + .../Array.prototype.concat_strict-arguments.js | 24 + .../Array/prototype/concat/S15.4.4.4_A1_T1.js | 55 + .../Array/prototype/concat/S15.4.4.4_A1_T2.js | 65 + .../Array/prototype/concat/S15.4.4.4_A1_T3.js | 43 + .../Array/prototype/concat/S15.4.4.4_A1_T4.js | 43 + .../Array/prototype/concat/S15.4.4.4_A2_T1.js | 65 + .../Array/prototype/concat/S15.4.4.4_A2_T2.js | 33 + .../Array/prototype/concat/S15.4.4.4_A3_T1.js | 56 + .../Array/prototype/concat/S15.4.4.4_A3_T2.js | 66 + .../Array/prototype/concat/S15.4.4.4_A3_T3.js | 66 + .../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 | 36 + .../concat/create-proto-from-ctor-realm-array.js | 44 + .../create-proto-from-ctor-realm-non-array.js | 45 + .../Array/prototype/concat/create-proxy.js | 41 + .../Array/prototype/concat/create-revoked-proxy.js | 40 + .../prototype/concat/create-species-abrupt.js | 34 + .../prototype/concat/create-species-non-ctor.js | 33 + .../create-species-non-extensible-spreadable.js | 45 + .../concat/create-species-non-extensible.js | 43 + .../Array/prototype/concat/create-species-null.js | 34 + .../prototype/concat/create-species-poisoned.js | 33 + .../Array/prototype/concat/create-species-undef.js | 36 + ...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 | 44 + .../concat/is-concat-spreadable-get-err.js | 40 + .../concat/is-concat-spreadable-get-order.js | 67 + .../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 | 28 + .../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 | 59 + .../coerced-values-start-change-start.js | 61 + .../coerced-values-start-change-target.js | 48 + .../prototype/copyWithin/coerced-values-start.js | 74 + .../prototype/copyWithin/coerced-values-target.js | 74 + .../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 | 76 + .../copyWithin/negative-out-of-bounds-end.js | 90 + .../copyWithin/negative-out-of-bounds-start.js | 75 + .../copyWithin/negative-out-of-bounds-target.js | 45 + .../Array/prototype/copyWithin/negative-start.js | 59 + .../Array/prototype/copyWithin/negative-target.js | 38 + .../copyWithin/non-negative-out-of-bounds-end.js | 64 + .../non-negative-out-of-bounds-target-and-start.js | 137 ++ .../copyWithin/non-negative-target-and-start.js | 58 + .../non-negative-target-start-and-end.js | 82 + .../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 | 31 + .../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 + .../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 | 0 .../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 | 91 + .../fill/fill-values-custom-start-and-end.js | 28 + .../prototype/fill/fill-values-relative-end.js | 35 + .../prototype/fill/fill-values-relative-start.js | 32 + .../built-ins/Array/prototype/fill/fill-values.js | 38 + .../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 + .../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 | 39 + .../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 | 0 .../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 + .../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 | 0 .../findIndex/array-altered-during-loop.js | 49 + .../built-ins/Array/prototype/findIndex/browser.js | 0 .../Array/prototype/findIndex/call-with-boolean.js | 20 + .../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 | 0 .../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 | 22 + .../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 | 70 + .../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 | 40 + .../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 | 76 + .../this-value-ctor-object-species-bad-throws.js | 131 ++ ...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 | 143 ++ .../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 + .../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 | 0 .../built-ins/Array/prototype/includes/browser.js | 0 .../Array/prototype/includes/call-with-boolean.js | 16 + ...mIndex-equal-or-greater-length-returns-false.js | 25 + .../Array/prototype/includes/fromIndex-infinity.js | 36 + .../prototype/includes/fromIndex-minus-zero.js | 23 + .../built-ins/Array/prototype/includes/get-prop.js | 45 + .../Array/prototype/includes/length-boundaries.js | 84 + .../includes/length-zero-returns-false.js | 29 + .../built-ins/Array/prototype/includes/length.js | 31 + .../built-ins/Array/prototype/includes/name.js | 28 + .../built-ins/Array/prototype/includes/no-arg.js | 21 + .../Array/prototype/includes/not-a-constructor.js | 35 + .../Array/prototype/includes/prop-desc.js | 18 + .../prototype/includes/return-abrupt-get-length.js | 27 + .../prototype/includes/return-abrupt-get-prop.js | 40 + .../return-abrupt-tointeger-fromindex-symbol.js | 25 + .../includes/return-abrupt-tointeger-fromindex.js | 28 + .../return-abrupt-tonumber-length-symbol.js | 24 + .../includes/return-abrupt-tonumber-length.js | 39 + .../Array/prototype/includes/samevaluezero.js | 29 + .../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 | 53 + .../Array/prototype/includes/this-is-not-object.js | 24 + .../prototype/includes/tointeger-fromindex.js | 54 + .../Array/prototype/includes/tolength-length.js | 89 + .../Array/prototype/includes/using-fromindex.js | 51 + .../prototype/includes/values-are-not-cached.js | 45 + .../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 | 24 + .../Array/prototype/join/S15.4.4.5_A1.2_T1.js | 31 + .../Array/prototype/join/S15.4.4.5_A1.2_T2.js | 31 + .../Array/prototype/join/S15.4.4.5_A1.3_T1.js | 30 + .../Array/prototype/join/S15.4.4.5_A2_T1.js | 50 + .../Array/prototype/join/S15.4.4.5_A2_T2.js | 73 + .../Array/prototype/join/S15.4.4.5_A2_T3.js | 57 + .../Array/prototype/join/S15.4.4.5_A2_T4.js | 136 ++ .../Array/prototype/join/S15.4.4.5_A3.1_T1.js | 54 + .../Array/prototype/join/S15.4.4.5_A3.1_T2.js | 148 ++ .../Array/prototype/join/S15.4.4.5_A3.2_T1.js | 60 + .../Array/prototype/join/S15.4.4.5_A3.2_T2.js | 137 ++ .../Array/prototype/join/S15.4.4.5_A4_T3.js | 27 + .../Array/prototype/join/S15.4.4.5_A5_T1.js | 31 + .../Array/prototype/join/S15.4.4.5_A6.6.js | 15 + .../Array/prototype/join/S15.4.4.5_A6.7.js | 23 + .../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 + .../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 | 39 + .../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 | 0 .../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 | 37 + .../Array/prototype/pop/S15.4.4.6_A1.2_T1.js | 70 + .../Array/prototype/pop/S15.4.4.6_A2_T1.js | 55 + .../Array/prototype/pop/S15.4.4.6_A2_T2.js | 93 + .../Array/prototype/pop/S15.4.4.6_A2_T3.js | 41 + .../Array/prototype/pop/S15.4.4.6_A2_T4.js | 150 ++ .../Array/prototype/pop/S15.4.4.6_A3_T1.js | 37 + .../Array/prototype/pop/S15.4.4.6_A3_T2.js | 37 + .../Array/prototype/pop/S15.4.4.6_A3_T3.js | 31 + .../Array/prototype/pop/S15.4.4.6_A4_T1.js | 56 + .../Array/prototype/pop/S15.4.4.6_A4_T2.js | 57 + .../Array/prototype/pop/S15.4.4.6_A5.7.js | 23 + .../built-ins/Array/prototype/pop/browser.js | 0 .../Array/prototype/pop/call-with-boolean.js | 12 + .../Array/prototype/pop/clamps-to-integer-limit.js | 37 + .../prototype/pop/length-near-integer-limit.js | 45 + .../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 + .../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 | 52 + .../Array/prototype/push/S15.4.4.7_A1_T2.js | 61 + .../Array/prototype/push/S15.4.4.7_A2_T1.js | 70 + .../Array/prototype/push/S15.4.4.7_A2_T2.js | 119 ++ .../Array/prototype/push/S15.4.4.7_A2_T3.js | 145 ++ .../built-ins/Array/prototype/push/S15.4.4.7_A3.js | 39 + .../Array/prototype/push/S15.4.4.7_A4_T1.js | 70 + .../Array/prototype/push/S15.4.4.7_A4_T2.js | 40 + .../Array/prototype/push/S15.4.4.7_A4_T3.js | 55 + .../Array/prototype/push/S15.4.4.7_A5_T1.js | 47 + .../Array/prototype/push/S15.4.4.7_A6.7.js | 23 + .../built-ins/Array/prototype/push/browser.js | 0 .../Array/prototype/push/call-with-boolean.js | 12 + .../prototype/push/clamps-to-integer-limit.js | 37 + .../push/length-near-integer-limit-set-failure.js | 49 + .../prototype/push/length-near-integer-limit.js | 41 + .../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 + .../built-ins/Array/prototype/push/shell.js | 0 .../push/throws-if-integer-limit-exceeded.js | 40 + .../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 + .../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 | 0 .../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 | 33 + .../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/length-near-integer-limit.js | 51 + .../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 | 0 .../Array/prototype/reverse/S15.4.4.8_A1_T1.js | 49 + .../Array/prototype/reverse/S15.4.4.8_A1_T2.js | 128 ++ .../Array/prototype/reverse/S15.4.4.8_A2_T1.js | 133 ++ .../Array/prototype/reverse/S15.4.4.8_A2_T2.js | 133 ++ .../Array/prototype/reverse/S15.4.4.8_A2_T3.js | 133 ++ .../Array/prototype/reverse/S15.4.4.8_A3_T3.js | 43 + .../Array/prototype/reverse/S15.4.4.8_A4_T1.js | 70 + .../Array/prototype/reverse/S15.4.4.8_A4_T2.js | 71 + .../Array/prototype/reverse/S15.4.4.8_A5.7.js | 23 + .../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 | 34 + .../length-exceeding-integer-limit-with-proxy.js | 121 ++ .../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 | 37 + .../Array/prototype/shift/S15.4.4.9_A1.2_T1.js | 70 + .../Array/prototype/shift/S15.4.4.9_A2_T1.js | 55 + .../Array/prototype/shift/S15.4.4.9_A2_T2.js | 81 + .../Array/prototype/shift/S15.4.4.9_A2_T3.js | 41 + .../Array/prototype/shift/S15.4.4.9_A2_T4.js | 54 + .../Array/prototype/shift/S15.4.4.9_A2_T5.js | 150 ++ .../Array/prototype/shift/S15.4.4.9_A3_T3.js | 37 + .../Array/prototype/shift/S15.4.4.9_A4_T1.js | 66 + .../Array/prototype/shift/S15.4.4.9_A4_T2.js | 67 + .../Array/prototype/shift/S15.4.4.9_A5.7.js | 23 + .../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 + .../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 | 46 + .../Array/prototype/slice/S15.4.4.10_A1.1_T2.js | 31 + .../Array/prototype/slice/S15.4.4.10_A1.1_T3.js | 31 + .../Array/prototype/slice/S15.4.4.10_A1.1_T4.js | 31 + .../Array/prototype/slice/S15.4.4.10_A1.1_T5.js | 41 + .../Array/prototype/slice/S15.4.4.10_A1.1_T6.js | 41 + .../Array/prototype/slice/S15.4.4.10_A1.1_T7.js | 41 + .../Array/prototype/slice/S15.4.4.10_A1.2_T1.js | 36 + .../Array/prototype/slice/S15.4.4.10_A1.2_T2.js | 36 + .../Array/prototype/slice/S15.4.4.10_A1.2_T3.js | 36 + .../Array/prototype/slice/S15.4.4.10_A1.2_T4.js | 56 + .../Array/prototype/slice/S15.4.4.10_A1.3_T1.js | 46 + .../Array/prototype/slice/S15.4.4.10_A1.3_T2.js | 31 + .../Array/prototype/slice/S15.4.4.10_A1.3_T3.js | 31 + .../Array/prototype/slice/S15.4.4.10_A1.3_T4.js | 31 + .../Array/prototype/slice/S15.4.4.10_A1.4_T1.js | 46 + .../Array/prototype/slice/S15.4.4.10_A1.4_T2.js | 41 + .../Array/prototype/slice/S15.4.4.10_A1.4_T3.js | 51 + .../Array/prototype/slice/S15.4.4.10_A1.4_T4.js | 31 + .../Array/prototype/slice/S15.4.4.10_A1.5_T1.js | 39 + .../Array/prototype/slice/S15.4.4.10_A1.5_T2.js | 39 + .../Array/prototype/slice/S15.4.4.10_A2.1_T1.js | 39 + .../Array/prototype/slice/S15.4.4.10_A2.1_T2.js | 44 + .../Array/prototype/slice/S15.4.4.10_A2.1_T3.js | 29 + .../Array/prototype/slice/S15.4.4.10_A2.1_T4.js | 44 + .../Array/prototype/slice/S15.4.4.10_A2.1_T5.js | 51 + .../Array/prototype/slice/S15.4.4.10_A2.2_T1.js | 39 + .../Array/prototype/slice/S15.4.4.10_A2.2_T2.js | 29 + .../Array/prototype/slice/S15.4.4.10_A2.2_T3.js | 54 + .../Array/prototype/slice/S15.4.4.10_A2.2_T4.js | 29 + .../Array/prototype/slice/S15.4.4.10_A2.2_T5.js | 51 + .../Array/prototype/slice/S15.4.4.10_A2_T1.js | 55 + .../Array/prototype/slice/S15.4.4.10_A2_T2.js | 55 + .../Array/prototype/slice/S15.4.4.10_A2_T3.js | 55 + .../Array/prototype/slice/S15.4.4.10_A2_T4.js | 55 + .../Array/prototype/slice/S15.4.4.10_A2_T5.js | 53 + .../Array/prototype/slice/S15.4.4.10_A2_T6.js | 53 + .../Array/prototype/slice/S15.4.4.10_A3_T1.js | 25 + .../Array/prototype/slice/S15.4.4.10_A3_T2.js | 25 + .../Array/prototype/slice/S15.4.4.10_A3_T3.js | 26 + .../Array/prototype/slice/S15.4.4.10_A4_T1.js | 30 + .../Array/prototype/slice/S15.4.4.10_A5.7.js | 23 + .../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 | 34 + .../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 | 58 + .../slice/length-exceeding-integer-limit.js | 49 + .../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 + .../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 | 0 .../Array/prototype/sort/S15.4.4.11_A1.1_T1.js | 30 + .../Array/prototype/sort/S15.4.4.11_A1.2_T1.js | 51 + .../Array/prototype/sort/S15.4.4.11_A1.2_T2.js | 57 + .../Array/prototype/sort/S15.4.4.11_A1.3_T1.js | 30 + .../Array/prototype/sort/S15.4.4.11_A1.4_T1.js | 48 + .../Array/prototype/sort/S15.4.4.11_A1.4_T2.js | 54 + .../Array/prototype/sort/S15.4.4.11_A1.5_T1.js | 46 + .../Array/prototype/sort/S15.4.4.11_A2.1_T1.js | 27 + .../Array/prototype/sort/S15.4.4.11_A2.1_T2.js | 27 + .../Array/prototype/sort/S15.4.4.11_A2.1_T3.js | 37 + .../Array/prototype/sort/S15.4.4.11_A2.2_T1.js | 32 + .../Array/prototype/sort/S15.4.4.11_A2.2_T2.js | 32 + .../Array/prototype/sort/S15.4.4.11_A2.2_T3.js | 42 + .../Array/prototype/sort/S15.4.4.11_A3_T1.js | 56 + .../Array/prototype/sort/S15.4.4.11_A3_T2.js | 64 + .../Array/prototype/sort/S15.4.4.11_A4_T3.js | 42 + .../Array/prototype/sort/S15.4.4.11_A5_T1.js | 24 + .../Array/prototype/sort/S15.4.4.11_A6_T2.js | 71 + .../Array/prototype/sort/S15.4.4.11_A7.7.js | 23 + .../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 + .../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 + .../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 | 51 + .../Array/prototype/splice/S15.4.4.12_A1.1_T2.js | 61 + .../Array/prototype/splice/S15.4.4.12_A1.1_T3.js | 51 + .../Array/prototype/splice/S15.4.4.12_A1.1_T4.js | 61 + .../Array/prototype/splice/S15.4.4.12_A1.1_T5.js | 51 + .../Array/prototype/splice/S15.4.4.12_A1.1_T6.js | 61 + .../Array/prototype/splice/S15.4.4.12_A1.2_T1.js | 41 + .../Array/prototype/splice/S15.4.4.12_A1.2_T2.js | 41 + .../Array/prototype/splice/S15.4.4.12_A1.2_T3.js | 51 + .../Array/prototype/splice/S15.4.4.12_A1.2_T4.js | 51 + .../Array/prototype/splice/S15.4.4.12_A1.2_T5.js | 51 + .../Array/prototype/splice/S15.4.4.12_A1.3_T1.js | 41 + .../Array/prototype/splice/S15.4.4.12_A1.3_T2.js | 41 + .../Array/prototype/splice/S15.4.4.12_A1.3_T3.js | 51 + .../Array/prototype/splice/S15.4.4.12_A1.3_T4.js | 51 + .../Array/prototype/splice/S15.4.4.12_A1.3_T5.js | 51 + .../Array/prototype/splice/S15.4.4.12_A1.4_T1.js | 51 + .../Array/prototype/splice/S15.4.4.12_A1.4_T2.js | 61 + .../Array/prototype/splice/S15.4.4.12_A1.4_T3.js | 51 + .../Array/prototype/splice/S15.4.4.12_A1.4_T4.js | 61 + .../Array/prototype/splice/S15.4.4.12_A1.4_T5.js | 51 + .../Array/prototype/splice/S15.4.4.12_A1.4_T6.js | 61 + .../Array/prototype/splice/S15.4.4.12_A1.5_T1.js | 49 + .../Array/prototype/splice/S15.4.4.12_A1.5_T2.js | 49 + .../Array/prototype/splice/S15.4.4.12_A2.1_T1.js | 49 + .../Array/prototype/splice/S15.4.4.12_A2.1_T2.js | 49 + .../Array/prototype/splice/S15.4.4.12_A2.1_T3.js | 44 + .../Array/prototype/splice/S15.4.4.12_A2.1_T4.js | 49 + .../Array/prototype/splice/S15.4.4.12_A2.1_T5.js | 56 + .../Array/prototype/splice/S15.4.4.12_A2.2_T1.js | 49 + .../Array/prototype/splice/S15.4.4.12_A2.2_T2.js | 39 + .../Array/prototype/splice/S15.4.4.12_A2.2_T3.js | 49 + .../Array/prototype/splice/S15.4.4.12_A2.2_T4.js | 39 + .../Array/prototype/splice/S15.4.4.12_A2.2_T5.js | 56 + .../Array/prototype/splice/S15.4.4.12_A2_T1.js | 75 + .../Array/prototype/splice/S15.4.4.12_A2_T2.js | 63 + .../Array/prototype/splice/S15.4.4.12_A2_T3.js | 63 + .../Array/prototype/splice/S15.4.4.12_A2_T4.js | 75 + .../Array/prototype/splice/S15.4.4.12_A3_T1.js | 42 + .../Array/prototype/splice/S15.4.4.12_A3_T3.js | 36 + .../Array/prototype/splice/S15.4.4.12_A4_T1.js | 86 + .../Array/prototype/splice/S15.4.4.12_A4_T2.js | 86 + .../Array/prototype/splice/S15.4.4.12_A4_T3.js | 77 + .../Array/prototype/splice/S15.4.4.12_A5.7.js | 23 + .../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 | 38 + .../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 | 34 + .../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 | 56 + .../length-exceeding-integer-limit-shrink-array.js | 66 + .../splice/length-near-integer-limit-grow-array.js | 64 + .../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 | 42 + .../prototype/toLocaleString/S15.4.4.3_A1_T1.js | 29 + .../prototype/toLocaleString/S15.4.4.3_A3_T1.js | 26 + .../prototype/toLocaleString/S15.4.4.3_A4.7.js | 24 + .../Array/prototype/toLocaleString/browser.js | 0 .../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/toString/S15.4.4.2_A1_T1.js | 35 + .../Array/prototype/toString/S15.4.4.2_A1_T2.js | 60 + .../Array/prototype/toString/S15.4.4.2_A1_T3.js | 93 + .../Array/prototype/toString/S15.4.4.2_A1_T4.js | 164 ++ .../Array/prototype/toString/S15.4.4.2_A3_T1.js | 19 + .../Array/prototype/toString/S15.4.4.2_A4.7.js | 24 + .../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 + .../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 | 57 + .../Array/prototype/unshift/S15.4.4.13_A1_T2.js | 61 + .../Array/prototype/unshift/S15.4.4.13_A2_T1.js | 70 + .../Array/prototype/unshift/S15.4.4.13_A2_T2.js | 103 + .../Array/prototype/unshift/S15.4.4.13_A2_T3.js | 144 ++ .../Array/prototype/unshift/S15.4.4.13_A3_T2.js | 46 + .../Array/prototype/unshift/S15.4.4.13_A4_T1.js | 80 + .../Array/prototype/unshift/S15.4.4.13_A4_T2.js | 78 + .../Array/prototype/unshift/S15.4.4.13_A5.7.js | 23 + .../built-ins/Array/prototype/unshift/browser.js | 0 .../Array/prototype/unshift/call-with-boolean.js | 12 + .../prototype/unshift/clamps-to-integer-limit.js | 34 + .../prototype/unshift/length-near-integer-limit.js | 62 + .../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 + .../built-ins/Array/prototype/unshift/shell.js | 0 .../unshift/throws-if-integer-limit-exceeded.js | 39 + .../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 + js/src/tests/test262/built-ins/Array/shell.js | 19 + 2824 files changed, 86576 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/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/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-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/browser.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/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/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/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/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/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/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/S15.4.4.5_A6.7.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/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/S15.4.4.6_A5.7.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/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/S15.4.4.7_A6.7.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/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/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/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/S15.4.4.8_A5.7.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/S15.4.4.9_A5.7.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/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/S15.4.4.10_A5.7.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/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_A7.7.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/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/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_A5.7.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/S15.4.4.3_A4.7.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/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/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/S15.4.4.2_A4.7.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/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/S15.4.4.13_A5.7.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/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/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..9eeaf40bf3 --- /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]', 's'); + +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..0b102eb797 --- /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", 'a[4294967295]'); + +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..ad8fc471f0 --- /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, 'a.length'); + +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..7c92ac0ca9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.1_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: | + 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 +---*/ + +//CHECK#1 +Array.prototype.myproperty = 42; +var x = Array(); +assert.sameValue(x.myproperty, 42); + +assert.sameValue(Object.prototype.hasOwnProperty.call(x, 'myproperty'), 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..3748e7eac7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.1_A1.1_T2.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: | + 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 +---*/ + +//CHECK#1 +Array.prototype.toString = Object.prototype.toString; +var x = Array(); +if (x.toString() !== "[object " + "Array" + "]") { + $ERROR('#1: Array.prototype.toString = Object.prototype.toString; var x = Array(); x.toString() === "[object " + "Array" + "]". Actual: ' + (x.toString())); +} + +//CHECK#2 +Array.prototype.toString = Object.prototype.toString; +var x = Array(0, 1, 2); +if (x.toString() !== "[object " + "Array" + "]") { + $ERROR('#2: Array.prototype.toString = Object.prototype.toString; var x = Array(0,1,2); x.toString() === "[object " + "Array" + "]". Actual: ' + (x.toString())); +} + +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..ab14a0292b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.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.1_A1.1_T3 +description: Checking use isPrototypeOf +---*/ + +//CHECK#1 +if (Array.prototype.isPrototypeOf(Array()) !== true) { + $ERROR('#1: Array.prototype.isPrototypeOf(Array()) === true. Actual: ' + (Array.prototype.isPrototypeOf(Array()))); +} + +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..2eb347e201 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.1_A1.2_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: 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 +---*/ + +//CHECK#1 +var x = Array(); +x.getClass = Object.prototype.toString; +if (x.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = Array(); x.getClass = Object.prototype.toString; x is Array object. Actual: ' + (x.getClass())); +} + +//CHECK#2 +var x = Array(0, 1, 2); +x.getClass = Object.prototype.toString; +if (x.getClass() !== "[object " + "Array" + "]") { + $ERROR('#2: var x = Array(0,1,2); x.getClass = Object.prototype.toString; x is Array object. Actual: ' + (x.getClass())); +} + +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..f3925a862a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.1_A1.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. + +/*--- +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); + +//CHECK#1 +if (x.length === 1) { + $ERROR('#1: var x = Array(2); x.length !== 1'); +} + +//CHECK#2 +if (x[0] === 2) { + $ERROR('#2: var x = Array(2); x[0] !== 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..fd8bf09c5f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.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: | + 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 +---*/ + +//CHECK#1 +if (Array().length !== 0) { + $ERROR('#1: (Array().length === 0. Actual: ' + (Array().length)); +} + +//CHECK#2 +if (Array(0, 1, 0, 1).length !== 4) { + $ERROR('#2: (Array(0,1,0,1).length === 4. Actual: ' + (Array(0, 1, 0, 1).length)); +} + +//CHECK#3 +if (Array(undefined, undefined).length !== 2) { + $ERROR('#3: (Array(undefined, undefined).length === 2. Actual: ' + (Array(undefined, undefined).length)); +} + +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..b080341e7c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.1_A2.2_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: | + 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 +---*/ + +//CHECK# +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; + } +} + +if (result !== true) { + $ERROR('#1: x[i] === i. Actual: ' + (x[i])); +} + +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..9dbb93db42 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.1_A3.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: | + 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 +---*/ + +//CHECK#1 +if (typeof Array() !== "object") { + $ERROR('#1: typeof Array() === "object". Actual: ' + (typeof Array())); +} + +//CHECK#2 +if ((Array() instanceof Array) !== true) { + $ERROR('#2: (Array() instanceof Array) === true. Actual: ' + (Array() instanceof Array)); +} + +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..b88999cb95 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.2.1_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: | + 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 +---*/ + +//CHECK#1 +Array.prototype.myproperty = 1; +var x = new Array(); +if (x.myproperty !== 1) { + $ERROR('#1: Array.prototype.myproperty = 1; var x = new Array(); x.myproperty === 1. Actual: ' + (x.myproperty)); +} + +//CHECK#2 +if (x.hasOwnProperty('myproperty') !== false) { + $ERROR('#2: Array.prototype.myproperty = 1; var x = new Array(); x.hasOwnProperty(\'myproperty\') === false. Actual: ' + (x.hasOwnProperty('myproperty'))); +} + +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..7b6cf68867 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.1_T2.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: | + 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 +---*/ + +//CHECK#1 +Array.prototype.toString = Object.prototype.toString; +var x = new Array(); +if (x.toString() !== "[object " + "Array" + "]") { + $ERROR('#1: Array.prototype.toString = Object.prototype.toString; var x = new Array(); x.toString() === "[object " + "Array" + "]". Actual: ' + (x.toString())); +} + +//CHECK#2 +Array.prototype.toString = Object.prototype.toString; +var x = new Array(0, 1, 2); +if (x.toString() !== "[object " + "Array" + "]") { + $ERROR('#2: Array.prototype.toString = Object.prototype.toString; var x = new Array(0,1,2); x.toString() === "[object " + "Array" + "]". Actual: ' + (x.toString())); +} + +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..9ce83368c9 --- /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 +---*/ + +//CHECK#1 +if (Array.prototype.isPrototypeOf(new Array()) !== true) { + $ERROR('#1: Array.prototype.isPrototypeOf(new Array()) === true. Actual: ' + (Array.prototype.isPrototypeOf(new Array()))); +} + +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..d2af051180 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.2_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: 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 +---*/ + +//CHECK#1 +var x = new Array(); +x.getClass = Object.prototype.toString; +if (x.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = new Array(); x.getClass = Object.prototype.toString; x is Array object. Actual: ' + (x.getClass())); +} + +//CHECK#2 +var x = new Array(0, 1, 2); +x.getClass = Object.prototype.toString; +if (x.getClass() !== "[object " + "Array" + "]") { + $ERROR('#2: var x = new Array(0,1,2); x.getClass = Object.prototype.toString; x is Array object. Actual: ' + (x.getClass())); +} + +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..5a17ba1aea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A1.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. + +/*--- +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); + +//CHECK#1 +if (x.length === 1) { + $ERROR('#1: var x = new Array(2); x.length !== 1'); +} + +//CHECK#2 +if (x[0] === 2) { + $ERROR('#2: var x = new Array(2); x[0] !== 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..635297eff1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.2.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: | + 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 +---*/ + +//CHECK#1 +if (new Array().length !== 0) { + $ERROR('#1: new Array().length === 0. Actual: ' + (new Array().length)); +} + +//CHECK#2 +if (new Array(0, 1, 0, 1).length !== 4) { + $ERROR('#2: new Array(0,1,0,1).length === 4. Actual: ' + (new Array(0, 1, 0, 1).length)); +} + +//CHECK#3 +if (new Array(undefined, undefined).length !== 2) { + $ERROR('#3: new Array(undefined, undefined).length === 2. Actual: ' + (new Array(undefined, undefined).length)); +} + +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..238a522d8b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.2.1_A2.2_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: | + 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 +---*/ + +//CHECK# +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; + } +} + +if (result !== true) { + $ERROR('#1: x[i] === i. Actual: ' + (x[i])); +} + +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..dde9b4f355 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.3_A1.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: | + 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; + +//CHECK#1 +if (Array.myproperty !== 1) { + $ERROR('#1: Function.prototype.myproperty = 1; Array.myproperty === 1. Actual: ' + (Array.myproperty)); +} + +//CHECK#2 +if (Array.hasOwnProperty('myproperty') !== false) { + $ERROR('#2: Function.prototype.myproperty = 1; Array.hasOwnProperty(\'myproperty\') === false. Actual: ' + (Array.hasOwnProperty('myproperty'))); +} + +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..e50ec09491 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.3_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. + +/*--- +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 +---*/ + +//CHECK#1 +Function.prototype.toString = Object.prototype.toString; +if (Array.toString() !== "[object " + "Function" + "]") { + $ERROR('#1: Function.prototype.toString = Object.prototype.toString; Array.toString() === "[object " + "Function" + "]". Actual: ' + (Array.toString())); +} + +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..a2a7d94c6c --- /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 +---*/ + +//CHECK#1 +if (Function.prototype.isPrototypeOf(Array) !== true) { + $ERROR('#1: Function.prototype.isPrototypeOf(Array) === true. Actual: ' + (Function.prototype.isPrototypeOf(Array))); +} + +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..47170587bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.1_A1.2_T2.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: | + 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 +---*/ + +//CHECK#1 +Array.prototype[2] = -1; +var x = [0, 1, 2]; +if (x[2] !== 2) { + $ERROR('#1: Array.prototype[2] = -1; x = [0,1,3]; x[2] === 2. Actual: ' + (x[2])); +} + +//CHECK#2 +x.length = 2; +if (x[2] !== -1) { + $ERROR('#2: Array.prototype[2] = -1; x = [0,1,3]; x.length = 2; x[2] === -1. Actual: ' + (x[2])); +} + +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..a66582da68 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.1_A2.1_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 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] +---*/ + +//CHECK#1 +var x = []; +x[4294967295] = 1; +if (x.length !== 0) { + $ERROR('#1.1: x = []; x[4294967295] = 1; x.length === 0. Actual: ' + (x.length)); +} + +if (x[4294967295] !== 1) { + $ERROR('#1.2: x = []; x[4294967295] = 1; x[4294967295] === 1. Actual: ' + (x[4294967295])); +} + +//CHECK#2 +x = []; +x[-1] = 1; +if (x.length !== 0) { + $ERROR('#2.1: x = []; x[-1] = 1; x.length === 0. Actual: ' + (x.length)); +} + +if (x[-1] !== 1) { + $ERROR('#2.2: x = []; x[-1] = 1; x[-1] === 1. Actual: ' + (x[-1])); +} + +//CHECK#3 +x = []; +x[true] = 1; +if (x.length !== 0) { + $ERROR('#3.1: x = []; x[true] = 1; x.length === 0. Actual: ' + (x.length)); +} + +if (x[true] !== 1) { + $ERROR('#3.2: x = []; x[true] = 1; x[true] === 1. Actual: ' + (x[true])); +} + +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..76522df0d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.1_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: | + 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] +---*/ + +//CHECK#1 +var x = Array(100); +x[0] = 1; +if (x.length !== 100) { + $ERROR('#1: x = Array(100); x[0] = 1; x.length === 100. Actual: ' + (x.length)); +} + +//CHECK#2 +x[98] = 1; +if (x.length !== 100) { + $ERROR('#2: x = Array(100); x[0] = 1; x[98] = 1; x.length === 100. Actual: ' + (x.length)); +} + +//CHECK#3 +x[99] = 1; +if (x.length !== 100) { + $ERROR('#3: x = Array(100); x[0] = 1; x[98] = 1; x[99] = 1; x.length === 100. Actual: ' + (x.length)); +} + +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..244960da5b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.1_A2.3_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: | + 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] +---*/ + +//CHECK#1 +var x = Array(100); +x[100] = 1; +if (x.length !== 101) { + $ERROR('#1: x = Array(100); x[100] = 1; x.length === 101. Actual: ' + (x.length)); +} + +//CHECK#2 +x[199] = 1; +if (x.length !== 200) { + $ERROR('#2: x = Array(100); x[100] = 1; x[199] = 1; x.length === 100. Actual: ' + (x.length)); +} + +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..9c9620dde9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.2_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: | + 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 +---*/ + +//CHECK#1 +var x = []; +if (x.length !== 0) { + $ERROR('#1: x = []; x.length === 0. Actual: ' + (x.length)); +} + +//CHECK#2 +x[0] = 1; +if (x.length !== 1) { + $ERROR('#2: x = []; x[1] = 1; x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#3 +x[1] = 1; +if (x.length !== 2) { + $ERROR('#3: x = []; x[0] = 1; x[1] = 1; x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#4 +x[2147483648] = 1; +if (x.length !== 2147483649) { + $ERROR('#4: x = []; x[0] = 1; x[1] = 1; x[2147483648] = 1; x.length === 2147483649. Actual: ' + (x.length)); +} + +//CHECK#5 +x[4294967294] = 1; +if (x.length !== 4294967295) { + $ERROR('#5: x = []; x[0] = 1; x[1] = 1; x[2147483648] = 1; x[42949672954] = 1; x.length === 4294967295. Actual: ' + (x.length)); +} + +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..2866cb9167 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A1_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: | + 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 +---*/ + +//CHECK#1 +var x = []; +x[4294967295] = 1; +if (x.length !== 0) { + $ERROR('#1: x = []; x[4294967295] = 1; x.length === 0. Actual: ' + (x.length)); +} + +//CHECK#2 +var y = []; +y[1] = 1; +y[4294967295] = 1; +if (y.length !== 2) { + $ERROR('#2: y = []; y[1] = 1; y[4294967295] = 1; y.length === 2. Actual: ' + (y.length)); +} + +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..bcf17b2edd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A2_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 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 +---*/ + +//CHECK#1 +var x = []; +if (x.length !== 0) { + $ERROR('#1: x = []; x.length === 0. Actual: ' + (x.length)); +} + +//CHECK#2 +x[0] = 1; +if (x.length !== 1) { + $ERROR('#2: x = []; x[1] = 1; x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#3 +x[1] = 1; +if (x.length !== 2) { + $ERROR('#3: x = []; x[0] = 1; x[1] = 1; x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#4 +x[9] = 1; +if (x.length !== 10) { + $ERROR('#4: x = []; x[0] = 1; x[1] = 1; x[9] = 1; x.length === 10. Actual: ' + (x.length)); +} + +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..0a85bc4b52 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.2_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: | + 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 +---*/ + +//CHECK#1 +var x = []; +x.length = 1; +if (x.length !== 1) { + $ERROR('#1: x = []; x.length = 1; x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#2 +x[5] = 1; +x.length = 10; +if (x.length !== 10) { + $ERROR('#2: x = []; x.length = 1; x[5] = 1; x.length = 10; x.length === 10. Actual: ' + (x.length)); +} + +//CHECK#3 +if (x[5] !== 1) { + $ERROR('#3: x = []; x.length = 1; x[5] = 1; x.length = 10; x[5] = 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..a91232ac11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A3_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 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 +---*/ + +//CHECK#1 +var x = []; +x[1] = 1; +x[3] = 3; +x[5] = 5; +x.length = 4; +if (x.length !== 4) { + $ERROR('#1: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length === 4. Actual: ' + (x.length)); +} + +//CHECK#2 +if (x[5] !== undefined) { + $ERROR('#2: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x[5] === undefined. Actual: ' + (x[5])); +} + +//CHECK#3 +if (x[3] !== 3) { + $ERROR('#3: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x[3] === 3. Actual: ' + (x[3])); +} + +//CHECK#4 +x.length = new Number(6); +if (x[5] !== undefined) { + $ERROR('#4: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length = new Number(6); x[5] === undefined. Actual: ' + (x[5])); +} + +//CHECK#5 +x.length = 0; +if (x[0] !== undefined) { + $ERROR('#5: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length = new Number(6); x.length = 0; x[0] === undefined. Actual: ' + (x[0])); +} + +//CHECK#6 +x.length = 1; +if (x[1] !== undefined) { + $ERROR('#6: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length = new Number(6); x.length = 0; x.length = 1; x[1] === undefined. Actual: ' + (x[1])); +} + +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..b23bf90df0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4.5.2_A3_T3.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: | + 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)" +---*/ + +//CHECK#1 +var x = []; +x.length = 4294967295; +if (x.length !== 4294967295) { + $ERROR('#1: x = []; x.length = 4294967295; x.length === 4294967295'); +} + +//CHECK#2 +try { + x = []; + x.length = 4294967296; + $ERROR('#2.1: x = []; x.length = 4294967296 throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#2.2: x = []; x.length = 4294967296 throw RangeError. Actual: ' + (e)); + } +} + +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..8ca8f98769 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T10.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_T10 +description: Array index is power of two +---*/ + +//CHECK# +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; + if (x[k - 2] !== k) { + $ERROR('#' + (k - 2) + ': '); + } +} + +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..dea662fe08 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_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: | + 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 +---*/ + +//CHECK#1 +var x = []; +x["0"] = 0; +if (x[0] !== 0) { + $ERROR('#1: x = []; x["0"] = 0; x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#2 +var y = []; +y["1"] = 1; +if (y[1] !== 1) { + $ERROR('#2: y = []; y["1"] = 1; y[1] === 1. Actual: ' + (y[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..25e8a00256 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4_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: | + 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 +---*/ + +//CHECK#1 +var x = []; +x[null] = 0; +if (x[0] !== undefined) { + $ERROR('#1: x = []; x[null] = 1; x[0] === undefined. Actual: ' + (x[0])); +} + +//CHECK#2 +if (x["null"] !== 0) { + $ERROR('#2: x = []; x[null] = 1; x["null"] === 0. Actual: ' + (x["null"])); +} + +//CHECK#3 +var y = []; +y[undefined] = 0; +if (y[0] !== undefined) { + $ERROR('#3: y = []; y[undefined] = 0; y[0] === undefined. Actual: ' + (y[0])); +} + +//CHECK#4 +if (y["undefined"] !== 0) { + $ERROR('#4: y = []; y[undefined] = 1; y["undefined"] === 0. Actual: ' + (y["undefined"])); +} + +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..9f65cc4ab8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T6.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: | + 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 +---*/ + +//CHECK#1 +var x = []; +x[new Boolean(true)] = 1; +if (x[1] !== undefined) { + $ERROR('#1: x = []; x[new Boolean(true)] = 1; x[1] === undefined. Actual: ' + (x[1])); +} + +//CHECK#2 +if (x["true"] !== 1) { + $ERROR('#2: x = []; x[true] = 1; x["true"] === 1. Actual: ' + (x["true"])); +} + +//CHECK#3 +x[new Boolean(false)] = 0; +if (x[0] !== undefined) { + $ERROR('#3: x = []; x[true] = 1; x[new Boolean(false)] = 0; x[0] === undefined. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x["false"] !== 0) { + $ERROR('#4: x = []; x[false] = 1; x["false"] === 0. Actual: ' + (x["false"])); +} + +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..57785086fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T7.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: | + 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 +---*/ + +//CHECK#1 +var x = []; +x[new Number(0)] = 0; +if (x[0] !== 0) { + $ERROR('#1: x = []; x[new Number(0)] = 0; x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#2 +var y = []; +y[new Number(1)] = 1; +if (y[1] !== 1) { + $ERROR('#2: y = []; y[new Number(1)] = 1; y[1] === 1. Actual: ' + (y[1])); +} + +//CHECK#3 +var z = []; +z[new Number(1.1)] = 1; +if (z["1.1"] !== 1) { + $ERROR('#3: z = []; z[new Number(1.1)] = 1; z["1.1"] === 1. Actual: ' + (z["1.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..fbd4420411 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T8.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: | + 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 +---*/ + +//CHECK#1 +var x = []; +x[new String("0")] = 0; +if (x[0] !== 0) { + $ERROR('#1: x = []; x[new String("0")] = 0; x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#2 +var y = []; +y[new String("1")] = 1; +if (y[1] !== 1) { + $ERROR('#2: y = []; y[new String("1")] = 1; y[1] === 1. Actual: ' + (y[1])); +} + +//CHECK#3 +var z = []; +z[new String("1.1")] = 1; +if (z["1.1"] !== 1) { + $ERROR('#3: z = []; z[new String("1.1")] = 1; z["1.1"] === 1. Actual: ' + (z["1.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..f7f2689b6a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/S15.4_A1.1_T9.js @@ -0,0 +1,145 @@ +// 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) +---*/ + +//CHECK#1 +var x = []; +var object = { + valueOf: function() { + return 1 + } +}; +x[object] = 0; +if (x["[object Object]"] !== 0) { + $ERROR('#1: x = []; var object = {valueOf: function() {return 1}}; x[object] = 0; x["[object Object]"] === 0. Actual: ' + (x["[object Object]"])); +} + +//CHECK#2 +x = []; +var object = { + valueOf: function() { + return 1 + }, + toString: function() { + return 0 + } +}; +x[object] = 0; +if (x[0] !== 0) { + $ERROR('#2: x = []; var object = {valueOf: function() {return 1}, toString: function() {return 0}}; x[object] = 0; x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#3 +x = []; +var object = { + valueOf: function() { + return 1 + }, + toString: function() { + return {} + } +}; +x[object] = 0; +if (x[1] !== 0) { + $ERROR('#3: x = []; var object = {valueOf: function() {return 1}, toString: function() {return {}}}; x[object] = 0; x[1] === 0. Actual: ' + (x[1])); +} + +//CHECK#4 +try { + x = []; + var object = { + valueOf: function() { + throw "error" + }, + toString: function() { + return 1 + } + }; + x[object] = 0; + if (x[1] !== 0) { + $ERROR('#4.1: x = []; var object = {valueOf: function() {throw "error"}, toString: function() {return 1}}; x[object] = 0; x[1] === 1. Actual: ' + (x[1])); + } +} +catch (e) { + if (e === "error") { + $ERROR('#4.2: x = []; var object = {valueOf: function() {throw "error"}, toString: function() {return 1}}; x[object] = 0; x[1] === 1. Actual: ' + ("error")); + } else { + $ERROR('#4.3: x = []; var object = {valueOf: function() {throw "error"}, toString: function() {return 1}}; x[object] = 0; x[1] === 1. Actual: ' + (e)); + } +} + +//CHECK#5 +x = []; +var object = { + toString: function() { + return 1 + } +}; +x[object] = 0; +if (x[1] !== 0) { + $ERROR('#5: x = []; var object = {toString: function() {return 1}}; x[object] = 0; x[1] === 0. Actual: ' + (x[1])); +} + +//CHECK#6 +x = []; +var object = { + valueOf: function() { + return {} + }, + toString: function() { + return 1 + } +} +x[object] = 0; +if (x[1] !== 0) { + $ERROR('#6: x = []; var object = {valueOf: function() {return {}}, toString: function() {return 1}}; x[object] = 0; x[1] === 0. Actual: ' + (x[1])); +} + +//CHECK#7 +try { + x = []; + var object = { + valueOf: function() { + return 1 + }, + toString: function() { + throw "error" + } + }; + x[object]; + $ERROR('#7.1: x = []; var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; x[object] throw "error". Actual: ' + (x[object])); +} +catch (e) { + if (e !== "error") { + $ERROR('#7.2: x = []; var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; x[object] throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + x = []; + var object = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + x[object]; + $ERROR('#8.1: x = []; var object = {valueOf: function() {return {}}, toString: function() {return {}}}; x[object] throw TypeError. Actual: ' + (x[object])); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#8.2: x = []; var object = {valueOf: function() {return {}}, toString: function() {return {}}}; x[object] throw TypeError. Actual: ' + (e)); + } +} + +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..e811084aaa --- /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'); + +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..c468b95e30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/Array.from-descriptor.js @@ -0,0 +1,15 @@ +// 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..af50dc8251 --- /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 `"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..63fc7fc096 --- /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); + +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..8336177787 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/Array.from_forwards-length-for-array-likes.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.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); +assert.sameValue(result.args[0], 42); +assert(result instanceof MyCollection); + +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..64d68c26ff --- /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, 'result.length'); +assert.sameValue(result[0], 82, 'result[0]'); +assert.sameValue(result[1], 84, 'result[1]'); +assert.sameValue(result[2], 86, 'result[2]'); + +assert.sameValue(calls.length, 3, 'calls.length'); + +assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length'); +assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]'); +assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]'); +assert.sameValue(calls[0].thisArg, this, 'calls[0].thisArg'); + +assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length'); +assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]'); +assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]'); +assert.sameValue(calls[1].thisArg, this, 'calls[1].thisArg'); + +assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length'); +assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]'); +assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]'); +assert.sameValue(calls[2].thisArg, this, 'calls[2].thisArg'); + +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..6b8873f386 --- /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, 'result.length'); +assert.sameValue(result[0], 82, 'result[0]'); +assert.sameValue(result[1], 84, 'result[1]'); +assert.sameValue(result[2], 86, 'result[2]'); + +assert.sameValue(calls.length, 3, 'calls.length'); + +assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length'); +assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]'); +assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]'); +assert.sameValue(calls[0].thisArg, undefined, 'calls[0].thisArg'); + +assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length'); +assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]'); +assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]'); +assert.sameValue(calls[1].thisArg, undefined, 'calls[1].thisArg'); + +assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length'); +assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]'); +assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]'); +assert.sameValue(calls[2].thisArg, undefined, 'calls[2].thisArg'); + +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..f637941bcc --- /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, 'result.length'); +assert.sameValue(result[0], 82, 'result[0]'); +assert.sameValue(result[1], 84, 'result[1]'); +assert.sameValue(result[2], 86, 'result[2]'); + +assert.sameValue(calls.length, 3, 'calls.length'); + +assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length'); +assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]'); +assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]'); +assert.sameValue(calls[0].thisArg, thisArg, 'calls[0].thisArg'); + +assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length'); +assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]'); +assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]'); +assert.sameValue(calls[1].thisArg, thisArg, 'calls[1].thisArg'); + +assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length'); +assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]'); +assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]'); +assert.sameValue(calls[2].thisArg, thisArg, 'calls[2].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..aabc288d6e --- /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], "Value mismatch in mapFn at index " + index + "."); + assert.sameValue(index, arrayIndex, "Index mismatch in mapFn."); + obj[originalLength + arrayIndex] = 2 * arrayIndex + 1; + + return obj[arrayIndex]; +} + + +var a = Array.from(obj, mapFn); +assert.sameValue(a.length, array.length, "Length mismatch."); + +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], array[j], "Element mismatch for array at index " + 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..dd834138fd --- /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], "Value mismatch in mapFn at index " + index + "."); + assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn."); + + array.splice(array.length - 1, 1); + return 127; +} + + +a = Array.from(array, mapFn, this); + +assert.sameValue(a.length, originalArray.length / 2, "Length mismatch. Old array : " + (originalArray.length / 2) + ". array : " + a.length + "."); + +for (var j = 0; j < originalArray.length / 2; j++) { + assert.sameValue(a[j], 127, "Element mismatch for mapped array at index " + j + "."); +} + +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..e646055fec --- /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, "Value mismatch in mapFn at index " + index + "."); + assert.sameValue(index, arrayIndex, "Index mismatch in mapFn."); + + return value; +} + +var a = Array.from(array, mapFn); +assert.sameValue(a.length, array.length, "Length mismatch."); +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], 127, "Element mismatch for mapped array."); +} + +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..a8400f467d --- /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, 'result.length'); +assert.sameValue(result[0], 0, 'result[0]'); +assert.sameValue(result[1], 'foo', 'result[1]'); +assert.sameValue(result[2], undefined, 'result[2]'); +assert.sameValue(result[3], Infinity, 'result[3]'); + +assert.notSameValue( + result, array, + 'result is not the object from items argument' +); + +assert(result instanceof Array, 'result instanceof Array'); + +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..206fe883df --- /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, 'result.length'); +assert.sameValue(result[0], 'T', 'result[0]'); +assert.sameValue(result[1], 'e', 'result[1]'); +assert.sameValue(result[2], 's', 'result[2]'); +assert.sameValue(result[3], 't', 'result[3]'); + +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..0de32cb3a1 --- /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); +}); + +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..5d1f829fce --- /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); + +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..05c9dcb400 --- /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); +}); + +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..ddb6af3e46 --- /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); +}); + +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..d478c6da8c --- /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); +}); + +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..22ecf1d10f --- /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, 'Constructed value is an instance of the constructor' +); +assert.sameValue( + result.constructor, + C, + 'Constructed value correctly defines a `constructor` property' +); +assert.sameValue(callCount, 1, 'Constructor invoked exactly once'); +assert.sameValue(thisVal, result, 'Constructed value is returned'); +assert.sameValue(args.length, 0, 'Constructor invoked without arguments'); + +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..78d40f7be4 --- /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 items = {}; +items[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + Array.from(items); +}); + +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..42221ffaf8 --- /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 items = {}; +var poisonedValue = {}; +Object.defineProperty(poisonedValue, 'value', { + get: function() { + throw new Test262Error(); + } +}); +items[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + Array.from(items); +}); + +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..89fe9c9ebd --- /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, 'Iteration count'); + +assert.sameValue(args[0].length, 2, 'First iteration: arguments length'); +assert.sameValue( + args[0][0], firstResult.value, 'First iteration: first argument' +); +assert.sameValue(args[0][1], 0, 'First iteration: second argument'); + +assert.sameValue(args[1].length, 2, 'Second iteration: arguments length'); +assert.sameValue( + args[1][0], secondResult.value, 'Second iteration: first argument' +); +assert.sameValue(args[1][1], 1, 'Second iteration: second argument'); + +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..f22c37527a --- /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); +}); + +assert.sameValue(closeCount, 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..eeb83400c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-map-fn-return.js @@ -0,0 +1,68 @@ +// Copyright (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); +assert.sameValue(result[0], firstReturnVal); +assert.sameValue(result[1], 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..199342aa83 --- /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); +assert.sameValue(thisVals[0], thisVal, 'First iteration `this` value'); +assert.sameValue(thisVals[1], thisVal, 'Second iteration `this` value'); + +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..14b44fe52f --- /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); +assert.sameValue(thisVals[0], global, 'First iteration `this` value'); +assert.sameValue(thisVals[1], global, 'Second iteration `this` value'); + +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..70926da85c --- /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); +assert.sameValue(thisVals[0], undefined, 'First iteration `this` value'); +assert.sameValue(thisVals[1], undefined, 'Second iteration `this` value'); + +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..ae18edfe4a --- /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 C = 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(C, items); +}); + +assert.sameValue(closeCount, 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..6228efac5c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/iter-set-elem-prop.js @@ -0,0 +1,52 @@ +// Copyright (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); +assert.sameValue(result[1], 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..8acf5f6cb0 --- /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 C = function() {}; +var items = {}; +Object.defineProperty(C.prototype, 'length', { + set: function(_) { + throw new Test262Error(); + } +}); +items[Symbol.iterator] = function() { + return { + next: function() { + return { + done: true + }; + } + }; +}; + +assert.throws(Test262Error, function() { + Array.from.call(C, items); +}); + +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..50dd0fd113 --- /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); + +nextIterResult = { + done: false +}; +lastIterResult = { + done: true +}; +result = Array.from(items); + +assert.sameValue(result.length, 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..3f54b8b8cb --- /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); +}); + +assert.throws(TypeError, function() { + Array.from([], {}); +}); + +assert.throws(TypeError, function() { + Array.from([], 'string'); +}); + +assert.throws(TypeError, function() { + Array.from([], true); +}); + +assert.throws(TypeError, function() { + Array.from([], 42); +}); + +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..40473321e5 --- /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')); +}); + +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..4f24458043 --- /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 mapFn(value, index, obj) { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + Array.from(array, mapFn); +}); + +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..339abfddd4 --- /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 TypeError'); + + +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..27088479e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/proto-from-ctor-realm.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.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); + +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..5251652c21 --- /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], "Value mismatch in mapFn at index " + index + "."); + assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn."); + + return value; +} + +var a = Array.from(array, mapFn, this); + +assert.sameValue(a.length, array.length, "Length mismatch."); +assert.sameValue(a[0], Number.MAX_VALUE, "Element mismatch for mapped array at index 0."); +assert.sameValue(a[1], Number.MIN_VALUE, "Element mismatch for mapped array at index 1."); +assert.sameValue(a[2], Number.NaN, "Element mismatch for mapped array at index 2."); +assert.sameValue(a[3], Number.NEGATIVE_INFINITY, "Element mismatch for mapped array at index 3."); +assert.sameValue(a[4], Number.POSITIVE_INFINITY, "Element mismatch for mapped array at index 4."); + +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..683d25c791 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/from/source-object-constructor.js @@ -0,0 +1,13 @@ +// 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); + +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..e31a7d7286 --- /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); +}); + +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..d707e84a2a --- /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 returned type is expected to be object."); +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], array[j], "Elements mismatch at " + 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..0f51481248 --- /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); +}); + +var A2 = function(_length) { + Object.defineProperty(this, "0", { + writable: true, + configurable: false, + }); +}; + +assert.throws(TypeError, function() { + Array.from.call(A2, items); +}); + +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..f578688227 --- /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], "Elements mismatch at " + 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..0b63af28a3 --- /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 returned type is expected to be object."); +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], array[j], "Elements mismatch at " + 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..f85a284317 --- /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, "Expected an array of length 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..97e936b370 --- /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, 'Does not throw if this is null'); +assert.sameValue(result.length, 0, 'result.length'); + +reportCompare(0, 0); 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..3eabfa3b4e --- /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", 'typeof(f)'); + +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..40b5a6d63a --- /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, 'Array.isArray.length'); + +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..cb98535abe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-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.isarray +es5id: 15.4.3.2-0-3 +description: Array.isArray return true if its argument is an Array +---*/ + +var a = []; +var b = Array.isArray(a); + +assert.sameValue(b, true, 'b'); + +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..c5ee865fc5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-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.isarray +description: Array.isArray return false if its argument is not an Array +---*/ + +var b_num = Array.isArray(42); +var b_undef = Array.isArray(undefined); +var b_bool = Array.isArray(true); +var b_str = Array.isArray("abc"); +var b_obj = Array.isArray({}); +var b_null = Array.isArray(null); + + +assert.sameValue(b_num, false, 'b_num'); +assert.sameValue(b_undef, false, 'b_undef'); +assert.sameValue(b_bool, false, 'b_bool'); +assert.sameValue(b_str, false, 'b_str'); +assert.sameValue(b_obj, false, 'b_obj'); +assert.sameValue(b_null, false, 'b_null'); + +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..247161bbeb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-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.isarray +es5id: 15.4.3.2-0-5 +description: > + Array.isArray return true if its argument is an Array + (Array.prototype) +---*/ + +var b = Array.isArray(Array.prototype); + +assert.sameValue(b, true, 'b'); + +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..eb2008a3df --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-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.isarray +es5id: 15.4.3.2-0-6 +description: Array.isArray return true if its argument is an Array (new Array()) +---*/ + +var a = new Array(10); +var b = Array.isArray(a); + +assert.sameValue(b, true, 'b'); + +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..8c9f59791b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/15.4.3.2-0-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.isarray +es5id: 15.4.3.2-0-7 +description: Array.isArray returns false if its argument is not an Array +---*/ + +var o = new Object(); +o[12] = 13; +var b = Array.isArray(o); + +assert.sameValue(b, false, 'b'); + +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..66729153f0 --- /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)'); + +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..93ae80e68e --- /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())'); + +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..bc6cd27fc2 --- /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)'); + +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..7915a82f7f --- /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())'); + +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..ed34801cd2 --- /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(arg)'); + +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..270908205d --- /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)'); + +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..120c004ed0 --- /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))'); + +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..e6e6c15690 --- /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)'); + +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..92e5d08284 --- /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))'); + +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..5320c172f8 --- /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")'); + +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..b8c7a67767 --- /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\\!"))'); + +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..3b63b74e02 --- /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 () { })'); + +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..35294773e7 --- /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)'); + +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..3edd365ddd --- /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())'); + +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..6d05b9dff9 --- /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(child)'); + +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..3ffc745335 --- /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(child)'); + +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..d88d536b98 --- /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 })'); + +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..70e5c8fbb9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/isArray/descriptor.js @@ -0,0 +1,15 @@ +// 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..8e290b8835 --- /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"); + +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..e137915971 --- /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 TypeError'); + + +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..05d67890f1 --- /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); +}); + +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..c5dcd63633 --- /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); +assert.sameValue(Array.isArray(arrayProxy), true, 'proxy for array'); +assert.sameValue( + Array.isArray(arrayProxyProxy), true, 'proxy for proxy for array' +); + +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..7ceb85a32f --- /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); + +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..a72f4ce727 --- /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; +}); + +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..0a3bfcfe6f --- /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; +}); + +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..af8ec6f601 --- /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, 'a.length'); + +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..1d5559b38d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_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-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 +---*/ + +//CHECK#1 +Array.prototype.myproperty = 1; +var x = new Array(0); +if (x.myproperty !== 1) { + $ERROR('#1: Array.prototype.myproperty = 1; var x = new Array(0); x.myproperty === 1. Actual: ' + (x.myproperty)); +} + +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..e97227c1dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_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. + +/*--- +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 +---*/ + +//CHECK#1 +Array.prototype.toString = Object.prototype.toString; +var x = new Array(0); +if (x.toString() !== "[object " + "Array" + "]") { + $ERROR('#1: Array.prototype.toString = Object.prototype.toString; var x = new Array(0); x.toString() === "[object " + "Array" + "]". Actual: ' + (x.toString())); +} + +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..f686040180 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_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. + +/*--- +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 +---*/ + +//CHECK#1 +if (Array.prototype.isPrototypeOf(new Array(0)) !== true) { + $ERROR('#1: Array.prototype.isPrototypeOf(new Array(0)) === true. Actual: ' + (Array.prototype.isPrototypeOf(new Array(0)))); +} + +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..5cf69c6cd8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_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. + +/*--- +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 +---*/ + +//CHECK#1 +var x = new Array(0); +x.getClass = Object.prototype.toString; +if (x.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = new Array(0); x.getClass = Object.prototype.toString; x is Array object. Actual: ' + (x.getClass())); +} + +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..a93c3e1cd6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.1_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. + +/*--- +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 +---*/ + +//CHECK#1 +var x = new Array(0); +if (x.length !== 0) { + $ERROR('#1: var x = new Array(0); x.length === 0. Actual: ' + (x.length)); +} + +//CHECK#2 +var x = new Array(1); +if (x.length !== 1) { + $ERROR('#2: var x = new Array(1); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#3 +var x = new Array(4294967295); +if (x.length !== 4294967295) { + $ERROR('#3: var x = new Array(4294967295); x.length === 4294967295. Actual: ' + (x.length)); +} + +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..acf5afbbfd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_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. + +/*--- +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 +---*/ + +//CHECK#1 +try { + new Array(-1); + $ERROR('#1.1: new Array(-1) throw RangeError. Actual: ' + (new Array(-1))); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#1.2: new Array(-1) throw RangeError. Actual: ' + (e)); + } +} + +//CHECK#2 +try { + new Array(4294967296); + $ERROR('#2.1: new Array(4294967296) throw RangeError. Actual: ' + (new Array(4294967296))); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#2.2: new Array(4294967296) throw RangeError. Actual: ' + (e)); + } +} + +//CHECK#3 +try { + new Array(4294967297); + $ERROR('#3.1: new Array(4294967297) throw RangeError. Actual: ' + (new Array(4294967297))); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#3.2: new Array(4294967297) throw RangeError. Actual: ' + (e)); + } +} + +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..7c3cf7ba2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T2.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. + +/*--- +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 +---*/ + +//CHECK#1 +try { + new Array(NaN); + $ERROR('#1.1: new Array(NaN) throw RangeError. Actual: ' + (new Array(NaN))); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#1.2: new Array(NaN) throw RangeError. Actual: ' + (e)); + } +} + +//CHECK#2 +try { + new Array(Number.POSITIVE_INFINITY); + $ERROR('#2.1: new Array(Number.POSITIVE_INFINITY) throw RangeError. Actual: ' + (new Array(Number.POSITIVE_INFINITY))); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#2.2: new Array(Number.POSITIVE_INFINITY) throw RangeError. Actual: ' + (e)); + } +} + +//CHECK#3 +try { + new Array(Number.NEGATIVE_INFINITY); + $ERROR('#3.1: new Array(Number.NEGATIVE_INFINITY) throw RangeError. Actual: ' + (new Array(Number.NEGATIVE_INFINITY))); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#3.2: new Array(Number.NEGATIVE_INFINITY) throw RangeError. Actual: ' + (e)); + } +} + +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..109246ca10 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T3.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. + +/*--- +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 +---*/ + +//CHECK#1 +try { + new Array(1.5); + $ERROR('#1.1: new Array(1.5) throw RangeError. Actual: ' + (new Array(1.5))); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#1.2: new Array(1.5) throw RangeError. Actual: ' + (e)); + } +} + +//CHECK#2 +try { + new Array(Number.MAX_VALUE); + $ERROR('#2.1: new Array(Number.MAX_VALUE) throw RangeError. Actual: ' + (new Array(Number.MAX_VALUE))); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#2.2: new Array(Number.MAX_VALUE) throw RangeError. Actual: ' + (e)); + } +} + +//CHECK#3 +try { + new Array(Number.MIN_VALUE); + $ERROR('#3.1: new Array(Number.MIN_VALUE) throw RangeError. Actual: ' + (new Array(Number.MIN_VALUE))); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#3.2: new Array(Number.MIN_VALUE) throw RangeError. Actual: ' + (e)); + } +} + +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..8fee44e419 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T1.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. + +/*--- +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); + +//CHECK#1 +if (x.length !== 1) { + $ERROR('#1: var x = new Array(null); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#2 +if (x[0] !== null) { + $ERROR('#2: var x = new Array(null); x[0] === null. Actual: ' + (x[0])); +} + +var x = new Array(undefined); + +//CHECK#3 +if (x.length !== 1) { + $ERROR('#3: var x = new Array(undefined); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#4 +if (x[0] !== undefined) { + $ERROR('#4: var x = new Array(undefined); x[0] === undefined. Actual: ' + (x[0])); +} + +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..0f1c2f5e24 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T2.js @@ -0,0 +1,39 @@ +// 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); + +//CHECK#1 +if (x.length !== 1) { + $ERROR('#1: var x = new Array(true); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#2 +if (x[0] !== true) { + $ERROR('#2: var x = new Array(true); x[0] === true. Actual: ' + (x[0])); +} + +var obj = new Boolean(false); +var x = new Array(obj); + +//CHECK#3 +if (x.length !== 1) { + $ERROR('#3: var obj = new Boolean(false); var x = new Array(obj); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#4 +if (x[0] !== obj) { + $ERROR('#4: var obj = new Boolean(false); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0])); +} + +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..b29d18c062 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T3.js @@ -0,0 +1,39 @@ +// 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"); + +//CHECK#1 +if (x.length !== 1) { + $ERROR('#1: var x = new Array("1"); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#2 +if (x[0] !== "1") { + $ERROR('#2: var x = new Array("1"); x[0] === "1". Actual: ' + (x[0])); +} + +var obj = new String("0"); +var x = new Array(obj); + +//CHECK#3 +if (x.length !== 1) { + $ERROR('#3: var obj = new String("0"); var x = new Array(obj); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#4 +if (x[0] !== obj) { + $ERROR('#4: var obj = new String("0"); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0])); +} + +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..05cd3d6e38 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T4.js @@ -0,0 +1,53 @@ +// 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); + +//CHECK#1 +if (x.length !== 1) { + $ERROR('#1: var obj = new Number(0); var x = new Array(obj); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#2 +if (x[0] !== obj) { + $ERROR('#2: var obj = new Number(0); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0])); +} + +var obj = new Number(1); +var x = new Array(obj); + +//CHECK#3 +if (x.length !== 1) { + $ERROR('#3: var obj = new Number(1); var x = new Array(obj); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#4 +if (x[0] !== obj) { + $ERROR('#4: var obj = new Number(1); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0])); +} + +var obj = new Number(4294967295); +var x = new Array(obj); + +//CHECK#5 +if (x.length !== 1) { + $ERROR('#5: var obj = new Number(4294967295); var x = new Array(obj); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#6 +if (x[0] !== obj) { + $ERROR('#6: var obj = new Number(4294967295); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0])); +} + +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..339f24d024 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T5.js @@ -0,0 +1,53 @@ +// 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); + +//CHECK#1 +if (x.length !== 1) { + $ERROR('#1: var obj = new Number(-1); var x = new Array(obj); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#2 +if (x[0] !== obj) { + $ERROR('#2: var obj = new Number(-1); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0])); +} + +var obj = new Number(4294967296); +var x = new Array(obj); + +//CHECK#3 +if (x.length !== 1) { + $ERROR('#3: var obj = new Number(4294967296); var x = new Array(obj); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#4 +if (x[0] !== obj) { + $ERROR('#4: var obj = new Number(4294967296); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0])); +} + +var obj = new Number(4294967297); +var x = new Array(obj); + +//CHECK#5 +if (x.length !== 1) { + $ERROR('#5: var obj = new Number(4294967297); var x = new Array(obj); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#6 +if (x[0] !== obj) { + $ERROR('#6: var obj = new Number(4294967297); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0])); +} + +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..705139aa3b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.4_A1.3_T1.js @@ -0,0 +1,16 @@ +// 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 +---*/ + +//CHECK#1 +if (Array.prototype.length !== 0) { + $ERROR('#1.1: Array.prototype.length === 0. Actual: ' + (Array.prototype.length)); +} + +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..6ccfdfd0fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_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. + +/*--- +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] +---*/ + +//CHECK#1 +try { + var x = []; + x.length = 4294967296; + $ERROR('#1.1: x = []; x.length = 4294967296 throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#1.2: x = []; x.length = 4294967296 throw RangeError. Actual: ' + (e)); + } +} + +//CHECK#2 +try { + x = []; + x.length = -1; + $ERROR('#2.1: x = []; x.length = -1 throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#2.2: x = []; x.length = -1 throw RangeError. Actual: ' + (e)); + } +} + +//CHECK#3 +try { + x = []; + x.length = 1.5; + $ERROR('#3.1: x = []; x.length = 1.5 throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#3.2: x = []; x.length = 1.5 throw RangeError. Actual: ' + (e)); + } +} + +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..ad1d408417 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_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. + +/*--- +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] +---*/ + +//CHECK#1 +try { + var x = []; + x.length = NaN; + $ERROR('#1.1: x = []; x.length = NaN throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#1.2: x = []; x.length = NaN throw RangeError. Actual: ' + (e)); + } +} + +//CHECK#2 +try { + x = []; + x.length = Number.POSITIVE_INFINITY; + $ERROR('#2.1: x = []; x.length = Number.POSITIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#2.2: x = []; x.length = Number.POSITIVE_INFINITY throw RangeError. Actual: ' + (e)); + } +} + +//CHECK#3 +try { + x = []; + x.length = Number.NEGATIVE_INFINITY; + $ERROR('#3.1: x = []; x.length = Number.NEGATIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#3.2: x = []; x.length = Number.NEGATIVE_INFINITY throw RangeError. Actual: ' + (e)); + } +} + +//CHECK#4 +try { + x = []; + x.length = undefined; + $ERROR('#4.1: x = []; x.length = undefined throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#4.2: x = []; x.length = undefined throw RangeError. Actual: ' + (e)); + } +} + +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..eb32f26370 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_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-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 +---*/ + +//CHECK#1 +var x = [0, , 2, , 4]; +x.length = 4; +if (x[4] !== undefined) { + $ERROR('#1: x = [0,,2,,4]; x.length = 4; x[4] === undefined. Actual: ' + (x[4])); +} + +//CHECK#2 +x.length = 3; +if (x[3] !== undefined) { + $ERROR('#2: x = [0,,2,,4]; x.length = 4; x.length = 3; x[3] === undefined. Actual: ' + (x[3])); +} + +//CHECK#3 +if (x[2] !== 2) { + $ERROR('#3: x = [0,,2,,4]; x.length = 4; x.length = 3; x[2] === 2. Actual: ' + (x[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..1944a52f9c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T3.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. + +/*--- +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 +---*/ + +//CHECK#1 +Array.prototype[2] = 2; +var x = [0, 1]; +x.length = 3; +if (x.hasOwnProperty('2') !== false) { + $ERROR('#1: Array.prototype[2] = 2; x = [0,1]; x.length = 3; x.hasOwnProperty(\'2\') === false. Actual: ' + (x.hasOwnProperty('2'))); +} + +//CHECK#2 +x.length = 2; +if (x[2] !== 2) { + $ERROR('#2: Array.prototype[2] = 2; x = [0,1]; x.length = 3; x.length = 2; x[2] === 2. Actual: ' + (x[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..cb50bc0cb7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T1.js @@ -0,0 +1,53 @@ +// 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 +---*/ + +//CHECK#1 +var x = []; +x.length = true; +if (x.length !== 1) { + $ERROR('#1: x = []; x.length = true; x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#2 +x = [0]; +x.length = null; +if (x.length !== 0) { + $ERROR('#2: x = [0]; x.length = null; x.length === 0. Actual: ' + (x.length)); +} + +//CHECK#3 +x = [0]; +x.length = new Boolean(false); +if (x.length !== 0) { + $ERROR('#3: x = [0]; x.length = new Boolean(false); x.length === 0. Actual: ' + (x.length)); +} + +//CHECK#4 +x = []; +x.length = new Number(1); +if (x.length !== 1) { + $ERROR('#4: x = []; x.length = new Number(1); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#5 +x = []; +x.length = "1"; +if (x.length !== 1) { + $ERROR('#5: x = []; x.length = "1"; x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#6 +x = []; +x.length = new String("1"); +if (x.length !== 1) { + $ERROR('#6: x = []; x.length = new String("1"); x.length === 1. Actual: ' + (x.length)); +} + +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..e03a8318d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T2.js @@ -0,0 +1,138 @@ +// 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 +---*/ + +//CHECK#1 +var x = []; +x.length = { + valueOf: function() { + return 2 + } +}; +if (x.length !== 2) { + $ERROR('#1: x = []; x.length = {valueOf: function() {return 2}}; x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#2 +x = []; +x.length = { + valueOf: function() { + return 2 + }, + toString: function() { + return 1 + } +}; +if (x.length !== 2) { + $ERROR('#0: x = []; x.length = {valueOf: function() {return 2}, toString: function() {return 1}}; x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#3 +x = []; +x.length = { + valueOf: function() { + return 2 + }, + toString: function() { + return {} + } +}; +if (x.length !== 2) { + $ERROR('#3: x = []; x.length = {valueOf: function() {return 2}, toString: function() {return {}}}; x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#4 +try { + x = []; + x.length = { + valueOf: function() { + return 2 + }, + toString: function() { + throw "error" + } + }; + if (x.length !== 2) { + $ERROR('#4.1: x = []; x.length = {valueOf: function() {return 2}, toString: function() {throw "error"}}; x.length === ",". Actual: ' + (x.length)); + } +} +catch (e) { + if (e === "error") { + $ERROR('#4.2: x = []; x.length = {valueOf: function() {return 2}, toString: function() {throw "error"}}; x.length not throw "error"'); + } else { + $ERROR('#4.3: x = []; x.length = {valueOf: function() {return 2}, toString: function() {throw "error"}}; x.length not throw Error. Actual: ' + (e)); + } +} + +//CHECK#5 +x = []; +x.length = { + toString: function() { + return 1 + } +}; +if (x.length !== 1) { + $ERROR('#5: x = []; x.length = {toString: function() {return 1}}; x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#6 +x = []; +x.length = { + valueOf: function() { + return {} + }, + toString: function() { + return 1 + } +} +if (x.length !== 1) { + $ERROR('#6: x = []; x.length = {valueOf: function() {return {}}, toString: function() {return 1}}; x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#7 +try { + x = []; + x.length = { + valueOf: function() { + throw "error" + }, + toString: function() { + return 1 + } + }; + x.length; + $ERROR('#7.1: x = []; x.length = {valueOf: function() {throw "error"}, toString: function() {return 1}}; x.length throw "error". Actual: ' + (x.length)); +} +catch (e) { + if (e !== "error") { + $ERROR('#7.2: x = []; x.length = {valueOf: function() {throw "error"}, toString: function() {return 1}}; x.length throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + x = []; + x.length = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + x.length; + $ERROR('#8.1: x = []; x.length = {valueOf: function() {return {}}, toString: function() {return {}}} x.length throw TypeError. Actual: ' + (x.length)); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#8.2: x = []; x.length = {valueOf: function() {return {}}, toString: function() {return {}}} x.length throw TypeError. Actual: ' + (e)); + } +} + +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..542692f386 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.2_A3_T4.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. + +/*--- +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 +---*/ + +//CHECK#1 +var x = [0, 1, 2]; +x[4294967294] = 4294967294; +x.length = 2; + +//CHECK#1 +if (x[0] !== 0) { + $ERROR('#1: x = [0,1,2]; x[4294967294] = 4294967294; x.length = 2; x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#2 +if (x[1] !== 1) { + $ERROR('#2: x = [0,1,2]; x[4294967294] = 4294967294; x.length = 2; x[1] === 1. Actual: ' + (x[1])); +} + +//CHECK#3 +if (x[2] !== undefined) { + $ERROR('#3: x = [0,1,2]; x[4294967294] = 4294967294; x.length = 2; x[2] === undefined. Actual: ' + (x[2])); +} + +//CHECK#4 +if (x[4294967294] !== undefined) { + $ERROR('#4: x = [0,1,2]; x[4294967294] = 4294967294; x.length = 2; x[4294967294] === undefined. Actual: ' + (x[4294967294])); +} + +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..a933348825 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order-set.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. + +/*--- +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; +}); +assert.compareArray(hints, ["number", "number"]); + + +array = [1, 2, 3]; +hints = []; + +assert(!Reflect.set(array, "length", length)); +assert.compareArray(hints, ["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..81dc7cd163 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order.js @@ -0,0 +1,60 @@ +// 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}); +}); +assert.sameValue(valueOfCalls, 2); + + +array = [1, 2]; +valueOfCalls = 0; + +assert(!Reflect.defineProperty(array, "length", {value: length, writable: true})); +assert.sameValue(valueOfCalls, 2); + +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..aa39ae4236 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-no-value-order.js @@ -0,0 +1,58 @@ +// 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}); +}); + +assert(!Reflect.defineProperty([], "length", {enumerable: true})); + +assert.throws(TypeError, function() { + Object.defineProperty([], "length", { + get: function() { + throw new Test262Error("[[Get]] shouldn't be called"); + }, + }); +}); + +assert(!Reflect.defineProperty([], "length", {set: function(_value) {}})); + +var array = []; +Object.defineProperty(array, "length", {writable: false}); +assert.throws(TypeError, function() { + Object.defineProperty(array, "length", {writable: true}); +}); + +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..7e9b345fcf --- /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}); +}); + +assert.throws(RangeError, function() { + Object.defineProperty([], "length", {value: NaN, enumerable: true}); +}); + +var array = []; +Object.defineProperty(array, "length", {writable: false}); +assert.throws(RangeError, function() { + Object.defineProperty(array, "length", {value: Number.MAX_SAFE_INTEGER, writable: true}); +}); + +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..565de0b0e7 --- /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; +}); + +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..0649ec0381 --- /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'); + +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..7a4a987f04 --- /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, '`Array.of.call(C);` called `new C(0)`'); +assert.sameValue(hits, 1, 'Called constructor once per call'); + +Array.of.call(C, 'a', 'b') +assert.sameValue(len, 2, '`Array.of.call(C, "a", "b"));` called `new C(2)`'); +assert.sameValue(hits, 2, 'Called constructor once per call'); + +Array.of.call(C, false, null, undefined); +assert.sameValue( + len, 3, + '`Array.of.call(C, false, null, undefined);` called `new C(3)`' +); +assert.sameValue(hits, 3, 'Called constructor once per call'); + +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..a303d3a870 --- /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 new array length is the same as the arguments size' +); +assert.sameValue(a1[0], 'Mike', 'set each property in order - #1'); +assert.sameValue(a1[1], 'Rick', 'set each property in order - #2'); +assert.sameValue(a1[2], 'Leo', 'set each property in order - #3'); + +var a2 = Array.of(undefined, false, null, undefined); +assert.sameValue( + a2.length, 4, + 'Creates an array from the arguments, regarless of their type values' +); +assert.sameValue(a2[0], undefined, 'set each property in order - #1'); +assert.sameValue(a2[1], false, 'set each property in order - #2'); +assert.sameValue(a2[2], null, 'set each property in order - #3'); +assert.sameValue(a2[3], undefined, 'set each property in order - #4'); + +var a3 = Array.of(); +assert.sameValue(a3.length, 0, 'Array.of() returns an empty array'); + +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..a7fed502e3 --- /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) { + $ERROR('Should define own properties'); + } +}); + +var arr = Array.of(true); +assert.sameValue(arr[0], true); + +function Custom() {} + +Object.defineProperty(Custom.prototype, "0", { + set: function(v) { + $ERROR('Should define own properties'); + } +}); + +var custom = Array.of.call(Custom, true); +assert.sameValue(custom[0], 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..62c1110d83 --- /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 `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..d890ef6548 --- /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 `"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..1327964630 --- /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 TypeError'); + + +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..a2f8b4923b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/of/proto-from-ctor-realm.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-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); + +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..d587255c3f --- /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, + 'Sets a length property with the number of arguments' +); +assert.sameValue( + coop[0], 'Mike', + 'Sets each argument in order as integer properties - #1 argument' +); +assert.sameValue( + coop[1], 'Rick', + 'Sets each argument in order as integer properties - #2 argument' +); +assert.sameValue( + coop[2], 'Leo', + 'Sets each argument in order as integer properties - #3 argument' +); +assert(coop instanceof Coop, 'Returns an instance from a custom constructor'); + +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..f5235fe514 --- /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, 'Array.of() returns a new Array'); + +result = Array.of.call(undefined); +assert( + result instanceof Array, + 'this is not a constructor' +); + +result = Array.of.call(Math.cos); +assert( + result instanceof Array, + 'this is a builtin function with no [[Construct]] slot' +); + +result = Array.of.call(Math.cos.bind(Math)); +assert( + result instanceof Array, + 'this is a bound builtin function with no [[Construct]] slot' +); + +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..b574f5fb7a --- /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); +}); + +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..0c070b450c --- /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'); +}); + +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..b87d93dd06 --- /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'); +}); + +function T2() { + Object.defineProperty(this, 0, { + configurable: false, + writable: true, + enumerable: true + }); +} + +assert.throws(TypeError, function() { + Array.of.call(T2, 'Bob'); +}) + +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..abe52c5924 --- /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); +}); + +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..11ad6a3b9b --- /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, 'instance length setter called once'); +assert.sameValue( + value, 4, + 'setter is called with the number of Array.of arguments' +); +assert.sameValue(_this_, result, 'setter is called with the new object'); + +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..e763c24d36 --- /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, "x[1]"); +assert.sameValue(x["true"], 1, "x['true']"); + +x[false] = 0; +assert.sameValue(x[0], undefined, "x[0]"); +assert.sameValue(x["false"], 0, "x['false']") + +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..5c361f0789 --- /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, "x[NaN] does not cast to x[0]"); +assert.sameValue(x["NaN"], 1, "x[NaN] casts to x['NaN']"); + +var y = []; +y[Number.POSITIVE_INFINITY] = 1; +assert.sameValue(y[0], undefined, "y[Number.POSITIVE_INFINITY] !== y[0]"); +assert.sameValue(y["Infinity"], 1, "y[Number.POSITIVE_INFINITY] === y['Infinity']"); + +var z = []; +z[Number.NEGATIVE_INFINITY] = 1; +assert.sameValue(z[0], undefined, "z[Number.NEGATIVE_INFINITY] !== z[0]"); +assert.sameValue(z["-Infinity"], 1, "z[Number.NEGATIVE_INFINITY] === z['-Infinity']"); + +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..fb36d5de30 --- /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, "x[0]"); +assert.sameValue(x["4294967296"], 1, "x['4294967296'] !== 1"); + +var y = []; +y[4294967297] = 1; +if (y[1] !== undefined) { + $ERROR('#3: y = []; y[4294967297] = 1; y[1] === undefined. Actual: ' + (y[1])); +} + +//CHECK#4 +if (y["4294967297"] !== 1) { + $ERROR('#4: y = []; y[4294967297] = 1; y["4294967297"] === 1. Actual: ' + (y["4294967297"])); +} + +//CHECK#5 +var z = []; +z[1.1] = 1; +if (z[1] !== undefined) { + $ERROR('#5: z = []; z[1.1] = 1; z[1] === undefined. Actual: ' + (z[1])); +} + +//CHECK#6 +if (z["1.1"] !== 1) { + $ERROR('#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..fa70c762c6 --- /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, 'newTarget.prototype is undefined'); + +newTarget.prototype = null; +arr = Reflect.construct(Array, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is null'); + +newTarget.prototype = true; +arr = Reflect.construct(Array, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is a Boolean'); + +newTarget.prototype = ''; +arr = Reflect.construct(Array, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is a String'); + +newTarget.prototype = Symbol(); +arr = Reflect.construct(Array, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is a Symbol'); + +newTarget.prototype = 0; +arr = Reflect.construct(Array, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is a Number'); + +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..cb7aa55c43 --- /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, 'newTarget.prototype is undefined'); + +newTarget.prototype = null; +arr = Reflect.construct(Array, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is null'); + +newTarget.prototype = false; +arr = Reflect.construct(Array, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is a Boolean'); + +newTarget.prototype = ''; +arr = Reflect.construct(Array, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is a String'); + +newTarget.prototype = Symbol(); +arr = Reflect.construct(Array, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is a Symbol'); + +newTarget.prototype = -1; +arr = Reflect.construct(Array, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is a Number'); + +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..2a2616c195 --- /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, 'newTarget.prototype is undefined'); + +newTarget.prototype = null; +arr = Reflect.construct(Array, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is null'); + +newTarget.prototype = true; +arr = Reflect.construct(Array, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is a Boolean'); + +newTarget.prototype = 'str'; +arr = Reflect.construct(Array, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is a String'); + +newTarget.prototype = Symbol(); +arr = Reflect.construct(Array, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is a Symbol'); + +newTarget.prototype = 1; +arr = Reflect.construct(Array, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.Array.prototype, 'newTarget.prototype is a Number'); + +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..22015626d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/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-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); + +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/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/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..ee807ebc72 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/Symbol.unscopables/value.js @@ -0,0 +1,81 @@ +// 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..1037cd3e85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/index-argument-tointeger.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!Array.prototype.at) -- Array.prototype.at is not enabled unconditionally +// 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'); + +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 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..a3517920b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js @@ -0,0 +1,23 @@ +// |reftest| skip-if(!Array.prototype.at) -- Array.prototype.at is not enabled unconditionally +// 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'); + +let a = [0,1,2,3]; + +assert.throws(TypeError, () => { + a.at(Symbol()); +}, '`a.at(Symbol())` throws TypeError'); + +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..45f1b72b76 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/index-non-numeric-argument-tointeger.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!Array.prototype.at) -- Array.prototype.at is not enabled unconditionally +// 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'); + +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..b127ec5e92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/length.js @@ -0,0 +1,27 @@ +// |reftest| skip-if(!Array.prototype.at) -- Array.prototype.at is not enabled unconditionally +// 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'); + +assert.sameValue( + Array.prototype.at.length, 1, + 'The value of Array.prototype.at.length is 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..2ba900a9b0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/name.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!Array.prototype.at) -- Array.prototype.at is not enabled unconditionally +// 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'); + +assert.sameValue( + Array.prototype.at.name, 'at', + 'The value of Array.prototype.at.name is "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..c8ad88ce87 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/prop-desc.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!Array.prototype.at) -- Array.prototype.at is not enabled unconditionally +// 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'); + +assert.sameValue( + typeof Array.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is "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..18db6397d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/return-abrupt-from-this.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!Array.prototype.at) -- Array.prototype.at is not enabled unconditionally +// 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'); + +assert.throws(TypeError, () => { + Array.prototype.at.call(undefined); +}, '`Array.prototype.at.call(undefined)` throws TypeError'); + +assert.throws(TypeError, () => { + Array.prototype.at.call(null); +}, '`Array.prototype.at.call(null)` throws TypeError'); + +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..ad384a0955 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/returns-item-relative-index.js @@ -0,0 +1,33 @@ +// |reftest| skip-if(!Array.prototype.at) -- Array.prototype.at is not enabled unconditionally +// 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'); + +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) must return 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..a3dfb189d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/returns-item.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!Array.prototype.at) -- Array.prototype.at is not enabled unconditionally +// 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'); + +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) must return 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..6d6531f3ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js @@ -0,0 +1,46 @@ +// |reftest| skip-if(!Array.prototype.at) -- Array.prototype.at is not enabled unconditionally +// 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 "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) must return 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) must return 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) must return 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) must return 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..cbeff51467 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/at/returns-undefined-for-out-of-range-index.js @@ -0,0 +1,23 @@ +// |reftest| skip-if(!Array.prototype.at) -- Array.prototype.at is not enabled unconditionally +// 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'); + +let a = []; + +assert.sameValue(a.at(-2), undefined, 'a.at(-2) must return undefined'); // wrap around the end +assert.sameValue(a.at(0), undefined, 'a.at(0) must return undefined'); +assert.sameValue(a.at(1), undefined, 'a.at(1) must return 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..db31ace969 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/15.4.4.4-5-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.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 newArr = Array.prototype.concat.call(101); + +assert(newArr[0] instanceof Number); +verifyProperty(newArr, "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..406ac3b66e --- /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,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 array like length to string throws +features: [Symbol.isConcatSpreadable] +---*/ +function MyError() {} +var obj = { + "length": { + toString: function() { + throw new MyError(); + }, + valueOf: null + }, + "1": "A", + "3": "B", + "5": "C" +}; +obj[Symbol.isConcatSpreadable] = true; +assert.throws(MyError, function() { + [].concat(obj); +}); + +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..2da189ad85 --- /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,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 array like length valueOf throws +features: [Symbol.isConcatSpreadable] +---*/ +function MyError() {} +var obj = { + "length": { + valueOf: function() { + throw new MyError(); + }, + toString: null + }, + "1": "A", + "3": "B", + "5": "C" +}; +obj[Symbol.isConcatSpreadable] = true; +assert.throws(MyError, function() { + [].concat(obj); +}); + +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..3b9f09f000 --- /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), [])); +obj.length = -4294967294; +assert(compareArray([].concat(obj), [])); +obj.length = "-4294967294"; +assert(compareArray([].concat(obj), [])); + +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..2e05ceb690 --- /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), [])); +obj.length = { + toString: null, + valueOf: function() { + return "SIX"; + } +}; +assert(compareArray([].concat(obj), [])); + +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..7723cff87e --- /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)); + +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..e0e5697b3b --- /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 obj = { + "length": { + valueOf: null, + toString: null + }, + "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"]; +assert.throws(TypeError, function() { + Array.prototype.concat.call(obj, obj2, arr); +}); + +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..e710e0923d --- /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)); + +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..9b2e73ad65 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_holey-sloppy-arguments.js @@ -0,0 +1,19 @@ +// 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))); + +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..1e51da5d0c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_large-typed-array.js @@ -0,0 +1,51 @@ +// 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)); +} + +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..1d4ad8b275 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_length-throws.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 length throws +features: [Symbol.isConcatSpreadable] +---*/ +function MyError() {} +var obj = {}; +obj[Symbol.isConcatSpreadable] = true; +Object.defineProperty(obj, "length", { + get: function() { + throw new MyError(); + } +}); + +assert.throws(MyError, function() { + [].concat(obj); +}); + +assert.throws(MyError, function() { + Array.prototype.concat.call(obj, 1, 2, 3); +}); + +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..22c6a6b61e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_no-prototype.js @@ -0,0 +1,12 @@ +// 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); + +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..d881c95d92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_non-array.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-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); +assert.sameValue(result instanceof NonArray, false); +assert(compareArray(result, [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..021775ee00 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments-throws.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 sloppy arguments throws +features: [Symbol.isConcatSpreadable] +---*/ +function MyError() {} +var args = (function(a) { + return arguments; +})(1, 2, 3); +Object.defineProperty(args, 0, { + get: function() { + throw new MyError(); + } +}); +args[Symbol.isConcatSpreadable] = true; +assert.throws(MyError, function() { + return [].concat(args, args); +}); + +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..73df5a0ec0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments-with-dupes.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 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])); + +Object.defineProperty(args, "length", { + value: 6 +}); +assert(compareArray([].concat(args), [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..c2d86b4f8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments.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.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])); + +Object.defineProperty(args, "length", { + value: 6 +}); +assert(compareArray([].concat(args), [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..1c1d569647 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_small-typed-array.js @@ -0,0 +1,50 @@ +// 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]; +[ + Uint8Array, + Uint16Array, + Uint32Array, + Float32Array, + Float64Array +].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..9a53cd3641 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-boolean-wrapper.js @@ -0,0 +1,39 @@ +// 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))); + +// 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))); + +Boolean.prototype[Symbol.isConcatSpreadable] = true; +// Boolean wrapper objects may be concat-spreadable +assert(compareArray([], [].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)))); + +// Boolean values are never concat-spreadable +assert(compareArray([true], [].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..6532e2e915 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-function.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 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))); + +// 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))); + +Function.prototype[Symbol.isConcatSpreadable] = true; +// Functions may be concat-spreadable +assert(compareArray([void 0, void 0, void 0], [].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) {}))); + +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..28e7a68ff8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-getter-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 Symbol.isConcatSpreadable getter throws +features: [Symbol.isConcatSpreadable] +---*/ +function MyError() {} +var obj = {}; +Object.defineProperty(obj, Symbol.isConcatSpreadable, { + get: function() { + throw new MyError(); + } +}); + +assert.throws(MyError, function() { + [].concat(obj); +}); + +assert.throws(MyError, function() { + Array.prototype.concat.call(obj, 1, 2, 3); +}); + +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..667195e2f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-number-wrapper.js @@ -0,0 +1,39 @@ +// 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))); + +// 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))); + +Number.prototype[Symbol.isConcatSpreadable] = true; +// Number wrapper objects may be concat-spreadable +assert(compareArray([], [].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)))); + +// Number values are never concat-spreadable +assert(compareArray([true], [].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..19054418e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-reg-exp.js @@ -0,0 +1,37 @@ +// 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])); + +// 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])); + +// RegExps may be concat-spreadable +RegExp.prototype[Symbol.isConcatSpreadable] = true; +RegExp.prototype.length = 3; + +assert(compareArray([].concat(/abc/), [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])); + +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..ac04a77dd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-sparse-object.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 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))); + +obj.length = 4000; +assert(compareArray(new Array(4000), [].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..5ae4f9bf92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-string-wrapper.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 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))); + +// String wrapper objects may be individually concat-spreadable +str1[Symbol.isConcatSpreadable] = true; +assert(compareArray(["y", "u", "c", "k", "\uD83D", "\uDCA9"], [].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")))); + +// String values are never concat-spreadable +assert(compareArray(["yuck\uD83D\uDCA9"], [].concat("yuck\uD83D\uDCA9"))); +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..c9a0992f55 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_strict-arguments.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 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])); + +Object.defineProperty(args, "length", { + value: 6 +}); +assert(compareArray([].concat(args), [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..e340eba2ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T1.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. + +/*--- +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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = new Array(); var y = new Array(0,1); var z = new Array(2,3,4); var arr = x.concat(y,z); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr[0] !== 0) { + $ERROR('#1: var x = new Array(); var y = new Array(0,1); var z = new Array(2,3,4); var arr = x.concat(y,z); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#2 +if (arr[1] !== 1) { + $ERROR('#2: var x = new Array(); var y = new Array(0,1); var z = new Array(2,3,4); var arr = x.concat(y,z); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#3 +if (arr[2] !== 2) { + $ERROR('#3: var x = new Array(); var y = new Array(0,1); var z = new Array(2,3,4); var arr = x.concat(y,z); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#4 +if (arr[3] !== 3) { + $ERROR('#4: var x = new Array(); var y = new Array(0,1); var z = new Array(2,3,4); var arr = x.concat(y,z); arr[3] === 3. Actual: ' + (arr[3])); +} + +//CHECK#5 +if (arr[4] !== 4) { + $ERROR('#5: var x = new Array(); var y = new Array(0,1); var z = new Array(2,3,4); var arr = x.concat(y,z); arr[4] === 4. Actual: ' + (arr[4])); +} + +//CHECK#6 +if (arr.length !== 5) { + $ERROR('#6: var x = new Array(); var y = new Array(0,1); var z = new Array(2,3,4); var arr = x.concat(y,z); arr.length === 5. Actual: ' + (arr.length)); +} + +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..7fc99eb589 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T2.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. + +/*--- +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"); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [0]; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr[0] !== 0) { + $ERROR('#1: var x = [0]; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#2 +if (arr[1] !== y) { + $ERROR('#2: var x = [0]; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr[1] === y. Actual: ' + (arr[1])); +} + +//CHECK#3 +if (arr[2] !== 1) { + $ERROR('#3: var x = [0]; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr[2] === 1. Actual: ' + (arr[2])); +} + +//CHECK#4 +if (arr[3] !== 2) { + $ERROR('#4: var x = [0]; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr[3] === 2. Actual: ' + (arr[3])); +} + +//CHECK#5 +if (arr[4] !== -1) { + $ERROR('#5: var x = [0]; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr[4] === -1. Actual: ' + (arr[4])); +} + +//CHECK#6 +if (arr[5] !== true) { + $ERROR('#6: var x = [0]; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr[5] === true. Actual: ' + (arr[5])); +} + +//CHECK#7 +if (arr[6] !== "NaN") { + $ERROR('#7: var x = [0]; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr[6] === "NaN". Actual: ' + (arr[6])); +} + +//CHECK#8 +if (arr.length !== 7) { + $ERROR('#8: var x = [0]; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr.length === 7. Actual: ' + (arr.length)); +} + +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..dcefa564f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T3.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. + +/*--- +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(); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [0,1]; var arr = x.concat(); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr[0] !== 0) { + $ERROR('#1: var x = [0,1]; var arr = x.concat(); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#2 +if (arr[1] !== 1) { + $ERROR('#2: var x = [0,1]; var arr = x.concat(); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#3 +if (arr.length !== 2) { + $ERROR('#3: var x = [0,1]; var arr = x.concat(); arr.length === 2. Actual: ' + (arr.length)); +} + +//CHECK#4 +if (arr === x) { + $ERROR('#4: var x = [0,1]; var arr = x.concat(); arr !== 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..1a68355536 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A1_T4.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. + +/*--- +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([], [, ]); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [,1]; var arr = x.concat([], [,]); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr[0] !== undefined) { + $ERROR('#1: var x = [,1]; var arr = x.concat([], [,]); arr[0] === undefined. Actual: ' + (arr[0])); +} + +//CHECK#2 +if (arr[1] !== 1) { + $ERROR('#2: var x = [,1]; var arr = x.concat([], [,]); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#2 +if (arr[2] !== undefined) { + $ERROR('#2: var x = [,1]; var arr = x.concat([], [,]); arr[2] === undefined. Actual: ' + (arr[2])); +} + +//CHECK#4 +if (arr.length !== 3) { + $ERROR('#4: var x = [,1]; var arr = x.concat([], [,]); arr.length === 3. Actual: ' + (arr.length)); +} + +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..0732be446f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_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. + +/*--- +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"); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: 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 is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr[0] !== x) { + $ERROR('#1: 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[0] === x. Actual: ' + (arr[0])); +} + +//CHECK#2 +if (arr[1] !== y) { + $ERROR('#2: 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[1] === y. Actual: ' + (arr[1])); +} + +//CHECK#3 +if (arr[2] !== 1) { + $ERROR('#3: 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[2] === 1. Actual: ' + (arr[2])); +} + +//CHECK#4 +if (arr[3] !== 2) { + $ERROR('#4: 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[3] === 2. Actual: ' + (arr[3])); +} + +//CHECK#5 +if (arr[4] !== -1) { + $ERROR('#5: 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[4] === -1. Actual: ' + (arr[4])); +} + +//CHECK#6 +if (arr[5] !== true) { + $ERROR('#6: 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[5] === true. Actual: ' + (arr[5])); +} + +//CHECK#7 +if (arr[6] !== "NaN") { + $ERROR('#7: 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[6] === "NaN". Actual: ' + (arr[6])); +} + +//CHECK#8 +if (arr.length !== 7) { + $ERROR('#8: 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.length === 7. Actual: ' + (arr.length)); +} + +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..6f488bb317 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A2_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. + +/*--- +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(); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = {}; x.concat = Array.prototype.concat; var arr = x.concat() arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr[0] !== x) { + $ERROR('#1: var x = {}; x.concat = Array.prototype.concat; var arr = x.concat(); arr[0] === x. Actual: ' + (arr[0])); +} + +//CHECK#2 +if (arr.length !== 1) { + $ERROR('#2: var x = {}; x.concat = Array.prototype.concat; var arr = x.concat(); arr.length === 1. Actual: ' + (arr.length)); +} + +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..d1fe3e7805 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T1.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.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(); + +//CHECK#1 +if (arr[0] !== 0) { + $ERROR('#1: Array.prototype[1] = 1; x = [0]; x.length = 2; var arr = x.concat(); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#2 +if (arr[1] !== 1) { + $ERROR('#2: Array.prototype[1] = 1; x = [0]; x.length = 2; var arr = x.concat(); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#3 +if (arr.hasOwnProperty('1') !== true) { + $ERROR('#3: Array.prototype[1] = 1; x = [0]; x.length = 2; var arr = x.concat(); arr.hasOwnProperty(\'1\') === true. Actual: ' + (arr.hasOwnProperty('1'))); +} + +Object.prototype[1] = 1; +Object.prototype.length = 2; +Object.prototype.concat = Array.prototype.concat; +x = { + 0: 0 +}; +var arr = x.concat(); + +//CHECK#4 +if (arr[0] !== x) { + $ERROR('#4: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.concat = Array.prototype.concat; x = {0:0}; var arr = x.concat(); arr[0] === x. Actual: ' + (arr[0])); +} + +//CHECK#5 +if (arr[1] !== 1) { + $ERROR('#5: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.concat = Array.prototype.concat; x = {0:0}; var arr = x.concat(); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#6 +if (arr.hasOwnProperty('1') !== false) { + $ERROR('#6: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.concat = Array.prototype.concat; x = {0:0}; var arr = x.concat(); arr.hasOwnProperty(\'1\') === false. Actual: ' + (arr.hasOwnProperty('1'))); +} + +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..2f85d8a997 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T2.js @@ -0,0 +1,66 @@ +// 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]; + +if (a.length !== 1) { + $ERROR("expected a.length === 1, actually " + a.length); +} + +a.length = 3; + +if (a[1] !== undefined) { + $ERROR("expected a[1] === undefined, actually " + a[1]); +} +if (a[2] !== undefined) { + $ERROR("expected a[2] === undefined, actually " + a[2]); +} + +Array.prototype[2] = 2; + +if (a[1] !== undefined) { + $ERROR("expected a[1] === undefined, actually " + a[1]); +} +if (a[2] !== 2) { + $ERROR("expected a[2] === 2, actually " + a[2]); +} + +if (a.hasOwnProperty('1') !== false) { + $ERROR("a.hasOwnProperty('1') === false, actually " + a.hasOwnProperty('1')); +} +if (a.hasOwnProperty('2') !== false) { + $ERROR("a.hasOwnProperty('2') === false, actually " + a.hasOwnProperty('2')); +} + +var b = a.concat(); + +if (b.length !== 3) { + $ERROR("expected b.length === 3, actually " + b.length); +} + +if (b[0] !== 0) { + $ERROR("expected b[0] === 0, actually " + b[0]); +} +if (b[1] !== undefined) { + $ERROR("expected b[1] === undefined, actually " + b[1]); +} +if (b[2] !== 2) { + $ERROR("expected b[2] === 2, actually " + b[2]); +} + +if (b.hasOwnProperty('1') !== false) { + $ERROR("expected b.hasOwnProperty('1') === false, actually " + b.hasOwnProperty('1')); +} +if (b.hasOwnProperty('2') !== true) { + $ERROR("expected b.hasOwnProperty('2') === true, actually " + b.hasOwnProperty('2')); +} + +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..9888c4374e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/S15.4.4.4_A3_T3.js @@ -0,0 +1,66 @@ +// 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]; + +if (a.length !== 1) { + $ERROR("expected a.length === 1, actually " + a.length); +} + +a.length = 3; + +if (a[1] !== undefined) { + $ERROR("expected a[1] === undefined, actually " + a[1]); +} +if (a[2] !== undefined) { + $ERROR("expected a[2] === undefined, actually " + a[2]); +} + +Object.prototype[2] = 2; + +if (a[1] !== undefined) { + $ERROR("expected a[1] === undefined, actually " + a[1]); +} +if (a[2] !== 2) { + $ERROR("expected a[2] === 2, actually " + a[2]); +} + +if (a.hasOwnProperty('1') !== false) { + $ERROR("a.hasOwnProperty('1') === false, actually " + a.hasOwnProperty('1')); +} +if (a.hasOwnProperty('2') !== false) { + $ERROR("a.hasOwnProperty('2') === false, actually " + a.hasOwnProperty('2')); +} + +var b = a.concat(); + +if (b.length !== 3) { + $ERROR("expected b.length === 3, actually " + b.length); +} + +if (b[0] !== 0) { + $ERROR("expected b[0] === 0, actually " + b[0]); +} +if (b[1] !== undefined) { + $ERROR("expected b[1] === undefined, actually " + b[1]); +} +if (b[2] !== 2) { + $ERROR("expected b[2] === 2, actually " + b[2]); +} + +if (b.hasOwnProperty('1') !== false) { + $ERROR("expected b.hasOwnProperty('1') === false, actually " + b.hasOwnProperty('1')); +} +if (b.hasOwnProperty('2') !== true) { + $ERROR("expected b.hasOwnProperty('2') === true, actually " + b.hasOwnProperty('2')); +} + +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..c8490fd48b --- /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 spreadable = {}; +spreadable.length = Number.MAX_SAFE_INTEGER; +spreadable[Symbol.isConcatSpreadable] = true; + +assert.throws(TypeError, function() { + [1].concat(spreadable); +}); + +var proxy = new Proxy([], { + get: function(_target, key) { + if (key === "length") { + return Number.MAX_SAFE_INTEGER; + } + }, +}); + +assert.throws(TypeError, function() { + [].concat(1, proxy); +}); + +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..99b94bfd23 --- /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 spreadable = { + length: Number.MAX_SAFE_INTEGER, + get 0() { + throw new Test262Error(); + }, +}; +spreadable[Symbol.isConcatSpreadable] = true; + +assert.throws(Test262Error, function() { + [].concat(spreadable); +}); + +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..c6245e6acc --- /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 `(Array.prototype.concat.call(true)[0] instanceof Boolean)` is true' +); +assert.sameValue( + Array.prototype.concat.call(false)[0] instanceof Boolean, + true, + 'The result of `(Array.prototype.concat.call(false)[0] instanceof Boolean)` is 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..d4a01307eb --- /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(); +}, 'null value'); + +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.concat(); +}, 'number value'); + +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.concat(); +}, 'string value'); + +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.concat(); +}, 'boolean value'); + +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..d190b5d461 --- /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(); +}); + +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..2a79375828 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/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.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, '`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, 1, 'array created with appropriate length'); +assert.sameValue(result[0], 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..d78f910a25 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-proto-from-ctor-realm-array.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: 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); +assert.sameValue(callCount, 0, 'Species constructor is not referenced'); + +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..765b0440d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-proto-from-ctor-realm-non-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.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); +assert.sameValue(callCount, 0, 'Array species constructor is not referenced'); + +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..397187c656 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/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.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); + +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..02ec3957f1 --- /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); +}); + +assert.sameValue(callCount, 0, '`constructor` property not accessed'); + +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..d673ed2c7b --- /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(); +}); + +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..1f490d707c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-non-ctor.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: > + 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. +features: [Symbol.species] +---*/ + +var a = []; + +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; + +assert.throws(TypeError, function() { + a.concat(); +}); + +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..44c6b8f112 --- /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]); +}); + +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..1373b44b7f --- /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); +}); + +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..11b061d9b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species-null.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: > + 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); +assert(Array.isArray(result), 'result is an Array exotic object'); + +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..46b93e3bb7 --- /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(); +}); + +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..4f245ee6e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/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.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); +assert(Array.isArray(result), 'result is an Array exotic object'); + +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..57c788936a --- /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]); +}); + +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..b61d967605 --- /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); +}); + +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..c17120e387 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/create-species.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: 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, '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/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..c0f503c2a9 --- /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); +}); + +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..6ffa669f98 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/is-concat-spreadable-get-order.js @@ -0,0 +1,67 @@ +// 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]); +assert.compareArray(calls, ["constructor", "isConcatSpreadable"]); + +calls = []; + +var arr2 = []; +var arg = {}; +Object.defineProperty(arr2, "constructor", descConstructor); +Object.defineProperty(arg, Symbol.isConcatSpreadable, descSpreadable); + +assert.compareArray(arr2.concat(arg), [arg]); +assert.compareArray(calls, ["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..dcca344d70 --- /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); +}); + +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..5323accda1 --- /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); +}); + +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..385662e6f7 --- /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, 'Proxy for an array'); +assert.sameValue( + [].concat(arrayProxyProxy).length, 0, 'Proxy for a proxy for an array' +); +assert.sameValue( + [].concat(spreadableProxy).length, + 0, + 'Proxy for an ordinary object with a truthy @@isConcatSpreadable property' +); + +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..19fc4d3a36 --- /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); +assert.sameValue(result[0], item); + +item[Symbol.isConcatSpreadable] = false; +result = [].concat(item); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], item); + +item[Symbol.isConcatSpreadable] = 0; +result = [].concat(item); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], item); + +item[Symbol.isConcatSpreadable] = NaN; +result = [].concat(item); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], 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..f5fee5c27e --- /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); + +item[Symbol.isConcatSpreadable] = 86; +result = [].concat(item); +assert.sameValue(result.length, 0); + +item[Symbol.isConcatSpreadable] = 'string'; +result = [].concat(item); +assert.sameValue(result.length, 0); + +item[Symbol.isConcatSpreadable] = Symbol(); +result = [].concat(item); +assert.sameValue(result.length, 0); + +item[Symbol.isConcatSpreadable] = {}; +result = [].concat(item); +assert.sameValue(result.length, 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..00af927ef6 --- /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); + +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..50d5c663ba --- /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); + +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..e544511368 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/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.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"); + +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..8a362cdf13 --- /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 TypeError'); + + +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..6fd81ff902 --- /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', 'typeof'); + +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..9a020d641f --- /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 `(Array.prototype.copyWithin.call(true) instanceof Boolean)` is true' +); +assert.sameValue( + Array.prototype.copyWithin.call(false) instanceof Boolean, + true, + 'The result of `(Array.prototype.copyWithin.call(false) instanceof Boolean)` is 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..485eadf7c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-end.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: > + 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] + ), + 'null value coerced to 0' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(1, 0, NaN), [0, 1, 2, 3] + ), + 'NaN value coerced to 0' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(1, 0, false), [0, 1, 2, 3] + ), + 'false value coerced to 0' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(1, 0, true), [0, 0, 2, 3] + ), + 'true value coerced to 1' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(1, 0, '-2'), [0, 0, 1, 3] + ), + 'string "-2" value coerced to integer -2' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(1, 0, -2.5), [0, 0, 1, 3] + ), + 'float -2.5 value coerced to integer -2' +); + +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..60991c6774 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start-change-start.js @@ -0,0 +1,61 @@ +// 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 + ), + 'coercion side-effect makes start out of bounds' +); + +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 + ), + 'coercion side-effect makes start out of bounds with prototype' +); + +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..40c961974b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start-change-target.js @@ -0,0 +1,48 @@ +// 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 + ), + 'coercion side-effect makes target out of bounds' +); + +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..d887077ebd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-start.js @@ -0,0 +1,74 @@ +// Copyright (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] + ), + 'undefined value coerced to 0' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(1, false), [0, 0, 1, 2] + ), + 'false value coerced to 0' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(1, NaN), [0, 0, 1, 2] + ), + 'NaN value coerced to 0' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(1, null), [0, 0, 1, 2] + ), + 'null value coerced to 0' +); + + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(0, true), [1, 2, 3, 3] + ), + 'true value coerced to 1' +); + + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(0, '1'), [1, 2, 3, 3] + ), + 'string "1" value coerced to 1' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(1, 0.5), [0, 0, 1, 2] + ), + '0.5 float value coerced to integer 0' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(0, 1.5), [1, 2, 3, 3] + ), + '1.5 float value coerced to integer 1' +); + +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..e171ad9aa7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/coerced-values-target.js @@ -0,0 +1,74 @@ +// Copyright (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] + ), + 'undefined value coerced to 0' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(false, 1), [1, 2, 3, 3] + ), + 'false value coerced to 0' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(NaN, 1), [1, 2, 3, 3] + ), + 'NaN value coerced to 0' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(null, 1), [1, 2, 3, 3] + ), + 'null value coerced to 0' +); + + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(true, 0), [0, 0, 1, 2] + ), + 'true value coerced to 1' +); + + +assert( + compareArray( + [0, 1, 2, 3].copyWithin('1', 0), [0, 0, 1, 2] + ), + 'string "1" value coerced to 1' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(0.5, 1), [1, 2, 3, 3] + ), + '0.5 float value coerced to integer 0' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(1.5, 0), [0, 0, 1, 2] + ), + '1.5 float value coerced to integer 1' +); + +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..46df82acdd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-end.js @@ -0,0 +1,76 @@ +// Copyright (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) -> [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) -> [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) -> [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) -> [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) -> [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) -> [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) -> [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) -> [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..3856db355f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-end.js @@ -0,0 +1,90 @@ +// Copyright (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) -> [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) -> [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) -> [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) -> [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) -> [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) -> [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) -> [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) -> [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) -> [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) -> [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..6dec81252d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-start.js @@ -0,0 +1,75 @@ +// Copyright (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) -> [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) -> [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, -2) -> [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) -> [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) -> [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) -> [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) -> [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) -> [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..412d237dc3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-out-of-bounds-target.js @@ -0,0 +1,45 @@ +// Copyright (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) -> [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) -> [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) -> [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) -> [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..44496c79b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-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 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) -> [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) -> [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) -> [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) -> [ 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) -> [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) -> [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..cc86b0bfe9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/negative-target.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: > + 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) -> [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) -> [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) -> [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..eab3fe706d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-out-of-bounds-end.js @@ -0,0 +1,64 @@ +// Copyright (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) -> [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) -> [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) -> [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) -> [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..651ce9f449 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js @@ -0,0 +1,137 @@ +// Copyright (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) => [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(6, 0) => [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) => [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) => [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) => [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) => [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) => [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) => [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) => [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) => [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) => [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) => [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) => [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) => [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) => [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..535ef1d5a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-target-and-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: > + 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..b040213b3c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/non-negative-target-start-and-end.js @@ -0,0 +1,82 @@ +// Copyright (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) -> [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) -> [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) -> [1, 1, 2, 3]' +); + +/* + * 15. If from [0, 0, 1, 3]' +); + +assert( + compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5), [0, 3, 4, 3, 4, 5] + ), + '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5) -> [0, 3, 4, 3, 4, 5]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/not-a-constructor.js new file mode 100644 index 0000000000..f16770a6c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/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.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..3c8b235440 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/undefined-end.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.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) -> [1, 2, 3]' +); + +assert( + compareArray( + [0, 1, 2, 3].copyWithin(0, 1), [1, 2, 3, 3] + ), + '[0, 1, 2, 3].copyWithin(0, 1) -> [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/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..e69de29bb2 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..918a138e11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/coerced-indexes.js @@ -0,0 +1,91 @@ +// Copyright (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]), + '`undefined` start coerced to 0' +); + +assert( + compareArray([0, 0].fill(1, 0, undefined), [1, 1]), + 'If end is undefined, let relativeEnd be len' +); + +assert( + compareArray([0, 0].fill(1, null), [1, 1]), + '`null` start coerced to 0' +); + +assert( + compareArray([0, 0].fill(1, 0, null), [0, 0]), + '`null` end coerced to 0' +); + +assert( + compareArray([0, 0].fill(1, true), [0, 1]), + '`true` start coerced to 1' +); + +assert( + compareArray([0, 0].fill(1, 0, true), [1, 0]), + '`true` end coerced to 1' +); + +assert( + compareArray([0, 0].fill(1, false), [1, 1]), + '`false` start coerced to 0' +); + +assert( + compareArray([0, 0].fill(1, 0, false), [0, 0]), + '`false` end coerced to 0' +); + +assert( + compareArray([0, 0].fill(1, NaN), [1, 1]), + '`NaN` start coerced to 0' +); + +assert( + compareArray([0, 0].fill(1, 0, NaN), [0, 0]), + '`NaN` end coerced to 0' +); + +assert( + compareArray([0, 0].fill(1, '1'), [0, 1]), + 'string start coerced' +); + +assert( + compareArray([0, 0].fill(1, 0, '1'), [1, 0]), + 'string end coerced' +); + +assert( + compareArray([0, 0].fill(1, 1.5), [0, 1]), + 'start as a float number coerced' +); + +assert( + compareArray([0, 0].fill(1, 0, 1.5), [1, 0]), + 'end as a float number coerced' +); + +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..ac797e382e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-custom-start-and-end.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.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])); +assert(compareArray([0, 0, 0, 0, 0].fill(8, -3, 4), [0, 0, 8, 8, 0])); +assert(compareArray([0, 0, 0, 0, 0].fill(8, -2, -1), [0, 0, 0, 8, 0])); +assert(compareArray([0, 0, 0, 0, 0].fill(8, -1, -3), [0, 0, 0, 0, 0])); +assert(compareArray([, , , , 0].fill(8, 1, 3), [, 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..d2719db128 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-relative-end.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 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]), + 'Fill elements from custom end position' +); + +assert( + compareArray([0, 0, 0].fill(8, 0, -1), [8, 8, 0]), + 'negative end sets final position to max((this.length + relativeEnd), 0)' +); + +assert( + compareArray([0, 0, 0].fill(8, 0, 5), [8, 8, 8]), + 'end position is never higher than of this.length' +); + +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..2ba8680144 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values-relative-start.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 ] ] ) + + ... + 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]), + 'Fill elements from custom start position' +); + +assert( + compareArray([0, 0, 0].fill(8, 4), [0, 0, 0]), + 'start position is never higher than this.length' +); + +assert( + compareArray([0, 0, 0].fill(8, -1), [0, 0, 8]), + 'negative start sets initial position to max((this.length + relativeStart),0)' +); + +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..c3f1dd7632 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/fill-values.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.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), [])); + +assert(compareArray( + [0, 0].fill(), [undefined, undefined] +)); + +assert( + compareArray([0, 0, 0].fill(8), [8, 8, 8]), + 'Default start and end indexes are 0 and this.length' +); + +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/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..43908b773e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/create-species-non-ctor.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: > + 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. +features: [Symbol.species] +---*/ + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 1; +}; + +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; + +assert.throws(TypeError, 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-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..e69de29bb2 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/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..e69de29bb2 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/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..e69de29bb2 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..fd97943c4f --- /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], 'arguments objects'); + +a = { + length: 1, + 0: [1], +}; +actual = [].flat.call(a); +assert.compareArray(actual, [1], 'array-like objects'); + +a = { + length: undefined, + 0: [1], +}; +actual = [].flat.call(a); +assert.compareArray(actual, [], 'array-like objects; undefined length'); + +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..4684bde497 --- /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], 'bound flat'); + +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..c184b02b34 --- /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(), []); +assert.compareArray([ + [], + [] +].flat(), []); +assert.compareArray([ + [], + [1] +].flat(), [1]); +assert.compareArray([ + [], + [1, a] +].flat(), [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..e69f78ea97 --- /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]); +assert.compareArray([a, [b]].flat(), [a, b]); +assert.compareArray([ + [a], b +].flat(), [a, b]); +assert.compareArray([ + [a], + [b] +].flat(), [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..1654076926 --- /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), 'non integral string depthNum'); + +// object type depthNum is converted to 0 +depthNum = {}; +actual = a.flat(depthNum); +assert(compareArray(actual, expected), 'object type depthNum'); + +// negative infinity depthNum is converted to 0 +depthNum = Number.NEGATIVE_INFINITY; +actual = a.flat(depthNum); +assert(compareArray(actual, expected), 'negative infinity depthNum'); + +// positive zero depthNum is converted to 0 +depthNum = +0; +actual = a.flat(depthNum); +assert(compareArray(actual, expected), 'positive zero depthNum'); + +// negative zero depthNum is converted to 0 +depthNum = -0; +actual = a.flat(depthNum); +assert(compareArray(actual, expected), 'negative zero depthNum'); + +// integral string depthNum is converted to an integer +depthNum = '1'; +actual = a.flat(depthNum); +expected = [1, 2] +assert(compareArray(actual, expected), 'integral string depthNum'); + +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..ecc4123659 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/null-undefined-elements.js @@ -0,0 +1,22 @@ +// 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])); +assert(compareArray([1, [null, void 0]].flat(), [1, null, undefined])); +assert(compareArray([ + [null, void 0], + [null, void 0] +].flat(), [null, undefined, null, undefined])); +assert(compareArray([1, [null, a]].flat(1), [1, null, a])); +assert(compareArray([1, [null, a]].flat(2), [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..8fc7a98c01 --- /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]), 'positive infinity depthNum'); + +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..a3951f0057 --- /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"], 'getProperty by .flat should occur exactly once per property and once for length and constructor'); +assert.compareArray(hasCalls, ["0", "1", "2", "3", "0", "1", "4"], 'hasProperty by .flat should occur exactly once per property'); + +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..f7cbb2918d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/array-like-objects-nested.js @@ -0,0 +1,70 @@ +// 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, 'returns a similar array'); +assert.notSameValue(actual, arr, 'not the same array'); + +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], 'returns a similar array'); +assert.notSameValue(actual, arrLike, 'not the same object'); +assert.sameValue(Object.getPrototypeOf(actual), 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..3c74d39899 --- /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], 'compare returned array'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype, 'returned object is an array #1'); +assert.sameValue(actual instanceof Int32Array, false, 'returned object is not an instance of Int32Array #1'); + +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, [], 'compare returned empty array'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype, 'returned object is an array #2'); +assert.sameValue(actual instanceof Int32Array, false, 'returned object is not an instance of Int32Array #2'); + +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..6985a1fa0e --- /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], 'array-like flattened object, number length'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype, 'returned object is an array #1'); + +a = { + length: undefined, + get 0() { throw 'it should not get this property'; }, +}; +actual = [].flatMap.call(a, fn); +assert.compareArray(actual, [], 'array-like objects; undefined length'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype, 'returned object is an array #2'); + +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], 'array-like flattened objects; custom get length'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype, 'returned object is an array #3'); + +a = { + length: 10001, + [10000]: 7, +}; +actual = [].flatMap.call(a, fn); +assert.compareArray(actual, [39, 14], 'array-like flattened object, long length simulating shallow array'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype, 'returned object is an array #4'); + +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..cc8e5414ba --- /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]); + +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..41411250b5 --- /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], 'array depth is 1'); + +var result = [1, 2, 3].flatMap(function(ele) { + return [ + [ele * 2] + ]; +}); +assert.sameValue(result.length, 3, 'array depth is more than 1 - length'); +assert.compareArray(result[0], [2], 'array depth is more than 1 - 1st element'); +assert.compareArray(result[1], [4], 'array depth is more than 1 - 2nd element'); +assert.compareArray(result[2], [6], 'array depth is more than 1 - 3rd element'); + +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..79e6b6ccc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/proxy-access-count.js @@ -0,0 +1,40 @@ +// 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'); + +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"], 'getProperty by .flatMap should occur exactly once per property and once for length and constructor'); +assert.compareArray(hasCalls, ["0", "1", "2", "3", "0", "1", "4"], 'hasProperty by .flatMap should occur exactly once per property'); + +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..9d5778ff44 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-non-object.js @@ -0,0 +1,76 @@ +// 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'); + +var a = []; +var mapperFn = function() {}; + +a.constructor = null; +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'null value'); + +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'number value'); + +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'string value'); + +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'boolean value'); + +a = []; +a.constructor = Symbol(); +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'symbol value'); + +a = []; +a.constructor = undefined; +var actual = a.flatMap(mapperFn); +assert.compareArray(actual, [], 'undefined value does not throw'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype); +assert.notSameValue(actual, a, 'returns a new array'); + +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..9b7e888777 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js @@ -0,0 +1,131 @@ +// 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'); + +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], 'undefined species does not throw'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype); + +var called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return 0; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'throw TypeError if @@species is a number'); +assert.sameValue(called, 1, 'got species once'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return ''; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'throw TypeError if @@species is a string'); +assert.sameValue(called, 1, 'got species once'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return false; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'throw TypeError if @@species is a boolean'); +assert.sameValue(called, 1, 'got species once'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return {}; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'throw TypeError if @@species is an object'); +assert.sameValue(called, 1, 'got species once'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return []; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'throw TypeError if @@species is an array'); +assert.sameValue(called, 1, 'got species once'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return Symbol(); + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'throw TypeError if @@species is a symbol'); +assert.sameValue(called, 1, 'got species once'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + throw new Test262Error + } +}; +assert.throws(Test262Error, function() { + arr.flatMap(mapperFn); +}, 'Return abrupt completion from getting the @@species'); +assert.sameValue(called, 1, 'got species once'); + +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..614ce40157 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-ctor-object-species.js @@ -0,0 +1,143 @@ +// 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'); + +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], 'undefined species does not throw'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype); + +var called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return null; + } +}; +actual = arr.flatMap(mapperFn); +assert.compareArray(actual, [42, 1, 42, 2], 'null species value does not throw'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype); +assert.sameValue(called, 1, 'got species once'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return undefined; + } +}; +actual = arr.flatMap(mapperFn); +assert.compareArray(actual, [42, 1, 42, 2], 'undefined species value does not throw'); +assert.sameValue(Object.getPrototypeOf(actual), Array.prototype); +assert.sameValue(called, 1, 'got species once'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return 0; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'throw TypeError if @@species is a number'); +assert.sameValue(called, 1, 'got species once'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return ''; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'throw TypeError if @@species is a string'); +assert.sameValue(called, 1, 'got species once'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return false; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'throw TypeError if @@species is a boolean'); +assert.sameValue(called, 1, 'got species once'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return {}; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'throw TypeError if @@species is an object'); +assert.sameValue(called, 1, 'got species once'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return []; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'throw TypeError if @@species is an array'); +assert.sameValue(called, 1, 'got species once'); + +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return Symbol(); + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'throw TypeError if @@species is a symbol'); +assert.sameValue(called, 1, 'got species once'); + +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..2e1952524c --- /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"]); + +actual = [1].flatMap(function() { + return [this]; +}, 1); +assert.compareArray(actual, [1]); + +actual = [1].flatMap(function() { + return [this]; +}, null); +assert.compareArray(actual, [null]); + +actual = [1].flatMap(function() { + return [this]; +}, true); +assert.compareArray(actual, [true]); + +actual = [1].flatMap(function() { + return [this]; +}, a); +assert.compareArray(actual, [a]); + +actual = [1].flatMap(function() { + return [this]; +}, void 0); +assert.compareArray(actual, [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/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..e69de29bb2 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..4a3bf4e31a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/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.includes +description: Array.prototype.includes applied to boolean primitive +---*/ + +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..e5c7f46623 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-equal-or-greater-length-returns-false.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 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. +---*/ + +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..05a2b08a14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-infinity.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.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. +---*/ + +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..8c95a3dd8f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/fromIndex-minus-zero.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.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 + ... +---*/ + +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..2755be53d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/get-prop.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: 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] +---*/ + +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); +assert( + compareArray(calls, ["length", "0", "1", "2", "3"]), + "loops through all indexes" +); + +calls = []; +assert.sameValue([].includes.call(p, 10), true, "uses the returned value"); +assert(compareArray(calls, ["length", "0", "1"]), "loops until value is found"); + +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..7b13e27371 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/length-boundaries.js @@ -0,0 +1,84 @@ +// 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). +---*/ + +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..77dcbf9414 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/length-zero-returns-false.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: 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. + ... +---*/ + +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..367e9bed89 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/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.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] +---*/ + +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..7292b6ef92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/name.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: > + 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] +---*/ + +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..6bc16f0112 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/no-arg.js @@ -0,0 +1,21 @@ +// 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. + ... +---*/ + +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..863bfcf2fd --- /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] +---*/ + +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..1ae6d67f94 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/prop-desc.js @@ -0,0 +1,18 @@ +// 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] +---*/ + +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..4b6022211b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-get-length.js @@ -0,0 +1,27 @@ +// 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")). + ... +---*/ + +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..31a9be5d9e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-get-prop.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 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)). + ... +---*/ + +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..d2c6b86b34 --- /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] +---*/ + +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..eec41e83b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tointeger-fromindex.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 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.) + ... +---*/ + +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..634cc96959 --- /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] +---*/ + +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..3b4719ffae --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-tonumber-length.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.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")). + ... +---*/ + +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..2cc785376e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/samevaluezero.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: 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. + ... +---*/ + +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..aeb56c66c8 --- /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] +---*/ + +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..35e7e5f541 --- /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] +---*/ + +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..f0fa31f281 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/sparse.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.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. + ... +---*/ + +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..c2d73e1ca6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/this-is-not-object.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: > + 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). + ... +---*/ + +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..bcf2fddc3a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/tointeger-fromindex.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: 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. +---*/ + +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..475c3760b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/tolength-length.js @@ -0,0 +1,89 @@ +// 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). +---*/ + +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..593583e0ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/using-fromindex.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.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. + ... +---*/ + +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..3f6131af4e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/values-are-not-cached.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: 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)). + ... +---*/ + +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..5896397d33 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.1_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 length is zero, return the empty string +esid: sec-array.prototype.join +description: Checking this use new Array() and [] +---*/ + +//CHECK#1 +var x = new Array(); +if (x.join() !== "") { + $ERROR('#1: x = new Array(); x.join() === "". Actual: ' + (x.join())); +} + +//CHECK#2 +x = []; +x[0] = 1; +x.length = 0; +if (x.join() !== "") { + $ERROR('#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..fb0abddf04 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.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: If separator is undefined, a single comma is used as the separator +esid: sec-array.prototype.join +description: Checking this use new Array() and [] +---*/ + +//CHECK#1 +var x = new Array(0, 1, 2, 3); +if (x.join() !== "0,1,2,3") { + $ERROR('#1: x = new Array(0,1,2,3); x.join() === "0,1,2,3". Actual: ' + (x.join())); +} + +//CHECK#2 +x = []; +x[0] = 0; +x[3] = 3; +if (x.join() !== "0,,,3") { + $ERROR('#2: x = []; x[0] = 0; x[3] = 3; x.join() === "0,,,3". Actual: ' + (x.join())); +} + +//CHECK#3 +x = []; +x[0] = 0; +if (x.join() !== "0") { + $ERROR('#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..5977a33e22 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.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: If separator is undefined, a single comma is used as the separator +esid: sec-array.prototype.join +description: Checking this use new Array() and [] +---*/ + +//CHECK#1 +var x = new Array(0, 1, 2, 3); +if (x.join(undefined) !== "0,1,2,3") { + $ERROR('#1: x = new Array(0,1,2,3); x.join(undefined) === "0,1,2,3". Actual: ' + (x.join(undefined))); +} + +//CHECK#2 +x = []; +x[0] = 0; +x[3] = 3; +if (x.join(undefined) !== "0,,,3") { + $ERROR('#2: x = []; x[0] = 0; x[3] = 3; x.join(undefined) === "0,,,3". Actual: ' + (x.join(undefined))); +} + +//CHECK#3 +x = []; +x[0] = 0; +if (x.join(undefined) !== "0") { + $ERROR('#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..aa132840eb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A1.3_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. + +/*--- +info: If array element is undefined or null, use the empty string +esid: sec-array.prototype.join +description: Checking this use new Array() and [] +---*/ + +//CHECK#1 +var x = []; +x[0] = undefined; +if (x.join() !== "") { + $ERROR('#1: x = []; x[0] = undefined; x.join() === "". Actual: ' + (x.join())); +} + +//CHECK#2 +x = []; +x[0] = null; +if (x.join() !== "") { + $ERROR('#2: x = []; x[0] = null; x.join() === "". Actual: ' + (x.join())); +} + +//CHECK#3 +x = Array(undefined, 1, null, 3); +if (x.join() !== ",1,,3") { + $ERROR('#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..facb0b953f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_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: | + 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) { + $ERROR('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + //CHECK#1 + if (obj.join() !== "") { + $ERROR('#1: var obj = {}; obj.join = Array.prototype.join; obj.join() === "". Actual: ' + (obj.join())); + } + //CHECK#2 + if (obj.length !== undefined) { + $ERROR('#2: var obj = {}; obj.join = Array.prototype.join; obj.join(); obj.length === undefined. Actual: ' + (obj.length)); + } +} + +//CHECK#3 +obj.length = undefined; +if (obj.join() !== "") { + $ERROR('#3: var obj = {}; obj.length = undefined; obj.join = Array.prototype.join; obj.join() === ". Actual: ' + (obj.join())); +} + +//CHECK#4 +if (obj.length !== undefined) { + $ERROR('#4: var obj = {}; obj.length = undefined; obj.join = Array.prototype.join; obj.join(); obj.length === undefined. Actual: ' + (obj.length)); +} + +//CHECK#5 +obj.length = null +if (obj.join() !== "") { + $ERROR('#5: var obj = {}; obj.length = null; obj.join = Array.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} + +//CHECK#6 +if (obj.length !== null) { + $ERROR('#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..faeb63a983 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T2.js @@ -0,0 +1,73 @@ +// 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; + +//CHECK#1 +obj.length = NaN; +if (obj.join() !== "") { + $ERROR('#1: var obj = {}; obj.length = NaN; obj.join = Array.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} + +//CHECK#2 +assert.sameValue(obj.length, NaN, "obj.length is NaN"); + +//CHECK#5 +obj.length = Number.NEGATIVE_INFINITY; +if (obj.join() !== "") { + $ERROR('#5: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.join = Array.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} + +//CHECK#6 +if (obj.length !== Number.NEGATIVE_INFINITY) { + $ERROR('#6: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.join = Array.prototype.join; obj.join(); obj.length === Number.NEGATIVE_INFINITY. Actual: ' + (obj.length)); +} + +//CHECK#7 +obj.length = -0; +if (obj.join() !== "") { + $ERROR('#7: var obj = {}; obj.length = -0; obj.join = Array.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} + +//CHECK#8 +if (obj.length !== -0) { + $ERROR('#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) { + $ERROR('#8: var obj = {}; obj.length = -0; obj.join = Array.prototype.join; obj.join(); obj.length === -0. Actual: ' + (obj.length)); + } +} + +//CHECK#9 +obj.length = 0.5; +if (obj.join() !== "") { + $ERROR('#9: var obj = {}; obj.length = 0.5; obj.join = Array.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} + +//CHECK#10 +if (obj.length !== 0.5) { + $ERROR('#10: var obj = {}; obj.length = 0.5; obj.join = Array.prototype.join; obj.join(); obj.length === 0.5. Actual: ' + (obj.length)); +} + +//CHECK#11 +var x = new Number(0); +obj.length = x; +if (obj.join() !== "") { + $ERROR('#11: var x = new Number(0); var obj = {}; obj.length = x; obj.join = Array.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} + +//CHECK#12 +if (obj.length !== x) { + $ERROR('#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..fa2525c57c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T3.js @@ -0,0 +1,57 @@ +// 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; + +//CHECK#1 +obj.length = 4.5; +if (obj.join() !== ",,,") { + $ERROR('#1: var obj = {}; obj.length = 4.5; obj.join = Array.prototype.join; obj.join() === ",,,". Actual: ' + (obj.join())); +} + +//CHECK#2 +obj[0] = undefined; +obj[1] = 1; +obj[2] = null; +if (obj.join() !== ",1,,") { + $ERROR('#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())); +} + +//CHECK#3 +if (obj.length !== 4.5) { + $ERROR('#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; + +//CHECK#4 +var x = new Number(4.5); +obj.length = x; +if (obj.join() !== ",,,") { + $ERROR('#4: var obj = {}; var x = new Number(4.5); obj.length = x; obj.join = Array.prototype.join; obj.join() === ",,,". Actual: ' + (obj.join())); +} + +//CHECK#5 +obj[0] = undefined; +obj[1] = 1; +obj[2] = null; +if (obj.join() !== ",1,,") { + $ERROR('#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())); +} + +//CHECK#6 +if (obj.length !== x) { + $ERROR('#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..ff85b7665e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A2_T4.js @@ -0,0 +1,136 @@ +// 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; + +//CHECK#1 +obj.length = { + valueOf: function() { + return 3 + } +}; +if (obj.join() !== ",,") { + $ERROR('#1: obj.length = {valueOf: function() {return 3}} obj.join() === ",,". Actual: ' + (obj.join())); +} + +//CHECK#2 +obj.length = { + valueOf: function() { + return 3 + }, + toString: function() { + return 2 + } +}; +if (obj.join() !== ",,") { + $ERROR('#2: obj.length = {valueOf: function() {return 3}, toString: function() {return 2}} obj.join() === ",,". Actual: ' + (obj.join())); +} + +//CHECK#3 +obj.length = { + valueOf: function() { + return 3 + }, + toString: function() { + return {} + } +}; +if (obj.join() !== ",,") { + $ERROR('#3: obj.length = {valueOf: function() {return 3}, toString: function() {return {}}} obj.join() === ",,". Actual: ' + (obj.join())); +} + +//CHECK#4 +try { + obj.length = { + valueOf: function() { + return 3 + }, + toString: function() { + throw "error" + } + }; + if (obj.join() !== ",,") { + $ERROR('#4.1: obj.length = {valueOf: function() {return 3}, toString: function() {throw "error"}}; obj.join() === ",". Actual: ' + (obj.join())); + } +} +catch (e) { + if (e === "error") { + $ERROR('#4.2: obj.length = {valueOf: function() {return 3}, toString: function() {throw "error"}}; obj.join() not throw "error"'); + } else { + $ERROR('#4.3: obj.length = {valueOf: function() {return 3}, toString: function() {throw "error"}}; obj.join() not throw Error. Actual: ' + (e)); + } +} + +//CHECK#5 +obj.length = { + toString: function() { + return 2 + } +}; +if (obj.join() !== ",") { + $ERROR('#5: obj.length = {toString: function() {return 2}} obj.join() === ",". Actual: ' + (obj.join())); +} + +//CHECK#6 +obj.length = { + valueOf: function() { + return {} + }, + toString: function() { + return 2 + } +} +if (obj.join() !== ",") { + $ERROR('#6: obj.length = {valueOf: function() {return {}}, toString: function() {return 2}} obj.join() === ",". Actual: ' + (obj.join())); +} + +//CHECK#7 +try { + obj.length = { + valueOf: function() { + throw "error" + }, + toString: function() { + return 2 + } + }; + obj.join(); + $ERROR('#7.1: obj.length = {valueOf: function() {throw "error"}, toString: function() {return 2}}; obj.join() throw "error". Actual: ' + (obj.join())); +} +catch (e) { + if (e !== "error") { + $ERROR('#7.2: obj.length = {valueOf: function() {throw "error"}, toString: function() {return 2}}; obj.join() throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + obj.length = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + obj.join(); + $ERROR('#8.1: obj.length = {valueOf: function() {return {}}, toString: function() {return {}}} obj.join() throw TypeError. Actual: ' + (obj.join())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#8,2: obj.length = {valueOf: function() {return {}}, toString: function() {return {}}} obj.join() throw TypeError. Actual: ' + (e)); + } +} + +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..bd5ddcb9d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.1_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: Operator use ToString from separator +esid: sec-array.prototype.join +description: > + Checking separator in ["", "\\", "&", true, Infinity, null, + undefind, NaN] +---*/ + +//CHECK#0 +var x = new Array(0, 1, 2, 3); +if (x.join("") !== "0123") { + $ERROR('#0: x = new Array(0,1,2,3); x.join("") === "0123". Actual: ' + (x.join(""))); +} + +//CHECK#1 +x = new Array(0, 1, 2, 3); +if (x.join("\\") !== "0\\1\\2\\3") { + $ERROR('#1: x = new Array(0,1,2,3); x.join("\\") === "0\\1\\2\\3". Actual: ' + (x.join("\\"))); +} + +//CHECK#2 +if (x.join("&") !== "0&1&2&3") { + $ERROR('#2: x = new Array(0,1,2,3); x.join("&") === "0&1&2&3". Actual: ' + (x.join("&"))); +} + +//CHECK#3 +if (x.join(true) !== "0true1true2true3") { + $ERROR('#3: x = new Array(0,1,2,3); x.join(true) === "0true1true2true3". Actual: ' + (x.join(true))); +} + +//CHECK#4 +if (x.join(Infinity) !== "0Infinity1Infinity2Infinity3") { + $ERROR('#4: x = new Array(0,1,2,3); x.join(Infinity) === "0Infinity1Infinity2Infinity3". Actual: ' + (x.join(Infinity))); +} + +//CHECK#5 +if (x.join(null) !== "0null1null2null3") { + $ERROR('#3: 5 = new Array(0,1,2,3); x.join(null) === "0null1null2null3". Actual: ' + (x.join(null))); +} + +//CHECK#6 +if (x.join(undefined) !== "0,1,2,3") { + $ERROR('#6: x = new Array(0,1,2,3); x.join(undefined) === "0,1,2,3". Actual: ' + (x.join(undefined))); +} + +//CHECK#7 +if (x.join(NaN) !== "0NaN1NaN2NaN3") { + $ERROR('#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..b30935f887 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.1_T2.js @@ -0,0 +1,148 @@ +// 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); +//CHECK#1 +var object = { + valueOf: function() { + return "+" + } +}; +if (x.join(object) !== "0[object Object]1[object Object]2[object Object]3") { + $ERROR('#1: var object = {valueOf: function() {return "+"}}; x.join(object) === "0[object Object]1[object Object]2[object Object]3". Actual: ' + (x.join(object))); +} + +//CHECK#2 +var object = { + valueOf: function() { + return "+" + }, + toString: function() { + return "*" + } +}; +if (x.join(object) !== "0*1*2*3") { + $ERROR('#2: var object = {valueOf: function() {return "+"}, toString: function() {return "*"}}; x.join(object) === "0*1*2*3". Actual: ' + (x.join(object))); +} + +//CHECK#3 +var object = { + valueOf: function() { + return "+" + }, + toString: function() { + return {} + } +}; +if (x.join(object) !== "0+1+2+3") { + $ERROR('#3: var object = {valueOf: function() {return "+"}, toString: function() {return {}}}; x.join(object) === "0+1+2+3". Actual: ' + (x.join(object))); +} + +//CHECK#4 +try { + var object = { + valueOf: function() { + throw "error" + }, + toString: function() { + return "*" + } + }; + if (x.join(object) !== "0*1*2*3") { + $ERROR('#4.1: var object = {valueOf: function() {throw "error"}, toString: function() {return "*"}}; x.join(object) === "0*1*2*3". Actual: ' + (x.join(object))); + } +} +catch (e) { + if (e === "error") { + $ERROR('#4.2: var object = {valueOf: function() {throw "error"}, toString: function() {return "*"}}; x.join(object) not throw "error"'); + } else { + $ERROR('#4.3: var object = {valueOf: function() {throw "error"}, toString: function() {return "*"}}; x.join(object) not throw Error. Actual: ' + (e)); + } +} + +//CHECK#5 +var object = { + toString: function() { + return "*" + } +}; +if (x.join(object) !== "0*1*2*3") { + $ERROR('#5: var object = {toString: function() {return "*"}}; x.join(object) === "0*1*2*3". Actual: ' + (x.join(object))); +} + +//CHECK#6 +var object = { + valueOf: function() { + return {} + }, + toString: function() { + return "*" + } +} +if (x.join(object) !== "0*1*2*3") { + $ERROR('#6: var object = {valueOf: function() {return {}}, toString: function() {return "*"}}; x.join(object) === "0*1*2*3". Actual: ' + (x.join(object))); +} + +//CHECK#7 +try { + var object = { + valueOf: function() { + return "+" + }, + toString: function() { + throw "error" + } + }; + x.join(object); + $ERROR('#7.1: var object = {valueOf: function() {return "+"}, toString: function() {throw "error"}}; x.join(object) throw "error". Actual: ' + (x.join(object))); +} +catch (e) { + if (e !== "error") { + $ERROR('#7.2: var object = {valueOf: function() {return "+"}, toString: function() {throw "error"}}; x.join(object) throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + var object = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + x.join(object); + $ERROR('#8.1: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; x.join(object) throw TypeError. Actual: ' + (x.join(object))); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#8.2: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; x.join(object) throw TypeError. Actual: ' + (e)); + } +} + +//CHECK#9 +try { + var object = { + toString: function() { + throw "error" + } + }; + [].join(object); + $ERROR('#9.1: var object = {toString: function() {throw "error"}}; [].join(object) throw "error". Actual: ' + ([].join(object))); +} +catch (e) { + if (e !== "error") { + $ERROR('#9.2: var object = {toString: function() {throw "error"}}; [].join(object) throw "error". Actual: ' + (e)); + } +} + +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..e89a582eb0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.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: Operator use ToString from array arguments +esid: sec-array.prototype.join +description: > + Checking arguments and separator in ["", "\\", "&", true, + Infinity, null, undefind, NaN] +---*/ + +//CHECK#0 +var x = new Array("", "", ""); +if (x.join("") !== "") { + $ERROR('#0: var x = new Array("","",""); x.join("") === "". Actual: ' + (x.join(""))); +} + +//CHECK#1 +var x = new Array("\\", "\\", "\\"); +if (x.join("\\") !== "\\\\\\\\\\") { + $ERROR('#1: var x = new Array("\\","\\","\\"); x.join("\\") === "\\\\\\\\\\". Actual: ' + (x.join("\\"))); +} + +//CHECK#2 +var x = new Array("&", "&", "&"); +if (x.join("&") !== "&&&&&") { + $ERROR('#2: var x = new Array("&", "&", "&"); x.join("&") === "&&&&&". Actual: ' + (x.join("&"))); +} + +//CHECK#3 +var x = new Array(true, true, true); +if (x.join() !== "true,true,true") { + $ERROR('#3: var x = new Array(true,true,true); x.join(true,true,true) === "true,true,true". Actual: ' + (x.join(true, true, true))); +} + +//CHECK#4 +var x = new Array(null, null, null); +if (x.join() !== ",,") { + $ERROR('#4: var x = new Array(null,null,null); x.join(null,null,null) === ",,". Actual: ' + (x.join(null, null, null))); +} + +//CHECK#5 +var x = new Array(undefined, undefined, undefined); +if (x.join() !== ",,") { + $ERROR('#5: var x = new Array(undefined,undefined,undefined); x.join(undefined,undefined,undefined) === ",,". Actual: ' + (x.join(undefined, undefined, undefined))); +} + +//CHECK#6 +var x = new Array(Infinity, Infinity, Infinity); +if (x.join() !== "Infinity,Infinity,Infinity") { + $ERROR('#6: var x = new Array(Infinity,Infinity,Infinity); x.join(Infinity,Infinity,Infinity) === "Infinity,Infinity,Infinity". Actual: ' + (x.join(Infinity, Infinity, Infinity))); +} + +//CHECK#7 +var x = new Array(NaN, NaN, NaN); +if (x.join() !== "NaN,NaN,NaN") { + $ERROR('#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..1b00551041 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A3.2_T2.js @@ -0,0 +1,137 @@ +// 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) +---*/ + +//CHECK#1 +var object = { + valueOf: function() { + return "+" + } +}; +var x = new Array(object); +if (x.join() !== "[object Object]") { + $ERROR('#1: var object = {valueOf: function() {return "+"}} var x = new Array(object); x.join() === "[object Object]". Actual: ' + (x.join())); +} + +//CHECK#2 +var object = { + valueOf: function() { + return "+" + }, + toString: function() { + return "*" + } +}; +var x = new Array(object); +if (x.join() !== "*") { + $ERROR('#2: var object = {valueOf: function() {return "+"}, toString: function() {return "*"}} var x = new Array(object); x.join() === "*". Actual: ' + (x.join())); +} + +//CHECK#3 +var object = { + valueOf: function() { + return "+" + }, + toString: function() { + return {} + } +}; +var x = new Array(object); +if (x.join() !== "+") { + $ERROR('#3: var object = {valueOf: function() {return "+"}, toString: function() {return {}}} var x = new Array(object); x.join() === "+". Actual: ' + (x.join())); +} + +//CHECK#4 +try { + var object = { + valueOf: function() { + throw "error" + }, + toString: function() { + return "*" + } + }; + var x = new Array(object); + if (x.join() !== "*") { + $ERROR('#4.1: var object = {valueOf: function() {throw "error"}, toString: function() {return "*"}} var x = new Array(object); x.join() === "*". Actual: ' + (x.join())); + } +} +catch (e) { + if (e === "error") { + $ERROR('#4.2: var object = {valueOf: function() {throw "error"}, toString: function() {return "*"}} var x = new Array(object); x.join() not throw "error"'); + } else { + $ERROR('#4.3: var object = {valueOf: function() {throw "error"}, toString: function() {return "*"}} var x = new Array(object); x.join() not throw Error. Actual: ' + (e)); + } +} + +//CHECK#5 +var object = { + toString: function() { + return "*" + } +}; +var x = new Array(object); +if (x.join() !== "*") { + $ERROR('#5: var object = {toString: function() {return "*"}} var x = new Array(object); x.join() === "*". Actual: ' + (x.join())); +} + +//CHECK#6 +var object = { + valueOf: function() { + return {} + }, + toString: function() { + return "*" + } +} +var x = new Array(object); +if (x.join() !== "*") { + $ERROR('#6: var object = {valueOf: function() {return {}}, toString: function() {return "*"}} var x = new Array(object); x.join() === "*". Actual: ' + (x.join())); +} + +//CHECK#7 +try { + var object = { + valueOf: function() { + return "+" + }, + toString: function() { + throw "error" + } + }; + var x = new Array(object); + x.join(); + $ERROR('#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) { + if (e !== "error") { + $ERROR('#7.2: var object = {valueOf: function() {return "+"}, toString: function() {throw "error"}} var x = new Array(object); x.join() throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + var object = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + var x = new Array(object); + x.join(); + $ERROR('#8.1: var object = {valueOf: function() {return {}}, toString: function() {return {}}} var x = new Array(object); x.join() throw TypeError. Actual: ' + (x.join())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#8.2: var object = {valueOf: function() {return {}}, toString: function() {return {}}} var x = new Array(object); x.join() throw TypeError. Actual: ' + (e)); + } +} + +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..1aae24cff2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A4_T3.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: 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; + +//CHECK#1 +if (obj.join("") !== "") { + $ERROR('#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(""))); +} + +//CHECK#2 +if (obj.length !== -4294967294) { + $ERROR('#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..42ec3ebf83 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A5_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: "[[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 +---*/ + +//CHECK#1 +Array.prototype[1] = 1; +var x = [0]; +x.length = 2; +if (x.join() !== "0,1") { + $ERROR('#1: Array.prototype[1] = 1; x = [0]; x.length = 2; x.join() === "0,1". Actual: ' + (x.join())); +} + +//CHECK#2 +Object.prototype[1] = 1; +Object.prototype.length = 2; +Object.prototype.join = Array.prototype.join; +x = { + 0: 0 +}; +if (x.join() !== "0,1") { + $ERROR('#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..575cfa871d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A6.6.js @@ -0,0 +1,15 @@ +// 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 +---*/ + +//CHECK#1 +if (Array.prototype.join.prototype !== undefined) { + $ERROR('#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/S15.4.4.5_A6.7.js b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A6.7.js new file mode 100644 index 0000000000..5b7c466624 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/join/S15.4.4.5_A6.7.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: The join property of Array can't be used as constructor +esid: sec-array.prototype.join +description: > + If property does not implement the internal [[Construct]] method, + throw a TypeError exception +---*/ + +//CHECK#1 + +try { + new Array.prototype.join(); + $ERROR('#1.1: new Array.prototype.join() throw TypeError. Actual: ' + (new Array.prototype.join())); +} catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: new Array.prototype.join() throw TypeError. Actual: ' + (e)); + } +} + +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/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..7b9b805afb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/map/create-species-non-ctor.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: > + 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. +features: [Symbol.species] +---*/ + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 1; +}; + +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; + +assert.throws(TypeError, 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-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..e69de29bb2 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..5b4235bc42 --- /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] +---*/ + +["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..7de2cca08c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A1.1_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: | + 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 +---*/ + +//CHECK#1 +var x = new Array(); +var pop = x.pop(); +if (pop !== undefined) { + $ERROR('#1: var x = new Array(); x.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#2 +if (x.length !== 0) { + $ERROR('#2: var x = new Array(); x.pop(); x.length === 0. Actual: ' + (x.length)); +} + +//CHECK#3 +var x = Array(1, 2, 3); +x.length = 0; +var pop = x.pop(); +if (pop !== undefined) { + $ERROR('#2: var x = Array(1,2,3); x.length = 0; x.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#4 +if (x.length !== 0) { + $ERROR('#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..4cb4ff23ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A1.2_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: | + 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 [] +---*/ + +//CHECK#1 +var x = new Array(0, 1, 2, 3); +var pop = x.pop(); +if (pop !== 3) { + $ERROR('#1: x = new Array(0,1,2,3); x.pop() === 3. Actual: ' + (pop)); +} + +//CHECK#2 +if (x.length !== 3) { + $ERROR('#2: x = new Array(0,1,2,3); x.pop(); x.length == 3'); +} + +//CHECK#3 +if (x[3] !== undefined) { + $ERROR('#3: x = new Array(0,1,2,3); x.pop(); x[3] == undefined'); +} + +//CHECK#4 +if (x[2] !== 2) { + $ERROR('#4: x = new Array(0,1,2,3); x.pop(); x[2] == 2'); +} + +//CHECK#5 +x = []; +x[0] = 0; +x[3] = 3; +var pop = x.pop(); +if (pop !== 3) { + $ERROR('#5: x = []; x[0] = 0; x[3] = 3; x.pop() === 3. Actual: ' + (pop)); +} + +//CHECK#6 +if (x.length !== 3) { + $ERROR('#6: x = []; x[0] = 0; x[3] = 3; x.pop(); x.length == 3'); +} + +//CHECK#7 +if (x[3] !== undefined) { + $ERROR('#7: x = []; x[0] = 0; x[3] = 3; x.pop(); x[3] == undefined'); +} + +//CHECK#8 +if (x[2] !== undefined) { + $ERROR('#8: x = []; x[0] = 0; x[3] = 3; x.pop(); x[2] == undefined'); +} + +//CHECK#9 +x.length = 1; +var pop = x.pop(); +if (pop !== 0) { + $ERROR('#9: x = []; x[0] = 0; x[3] = 3; x.pop(); x.length = 1; x.pop() === 0. Actual: ' + (pop)); +} + +//CHECK#10 +if (x.length !== 0) { + $ERROR('#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..35c31d1fb0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T1.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 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) { + $ERROR('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + //CHECK#1 + var pop = obj.pop(); + if (pop !== undefined) { + $ERROR('#1: var obj = {}; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); + } + //CHECK#2 + if (obj.length !== 0) { + $ERROR('#2: var obj = {}; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); + } +} + +//CHECK#3 +obj.length = undefined; +var pop = obj.pop(); +if (pop !== undefined) { + $ERROR('#3: var obj = {}; obj.length = undefined; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#4 +if (obj.length !== 0) { + $ERROR('#4: var obj = {}; obj.length = undefined; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} + +//CHECK#5 +obj.length = null +var pop = obj.pop(); +if (pop !== undefined) { + $ERROR('#5: var obj = {}; obj.length = null; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#6 +if (obj.length !== 0) { + $ERROR('#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..d562d5cf60 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T2.js @@ -0,0 +1,93 @@ +// 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; + +//CHECK#1 +obj.length = NaN; +var pop = obj.pop(); +if (pop !== undefined) { + $ERROR('#1: var obj = {}; obj.length = NaN; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#2 +if (obj.length !== 0) { + $ERROR('#2: var obj = {}; obj.length = NaN; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} + +//CHECK#3 +obj.length = Number.POSITIVE_INFINITY; +var pop = obj.pop(); +if (pop !== undefined) { + $ERROR('#3: var obj = {}; obj.length = Number.POSITIVE_INFINITY; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#4 +if (obj.length !== 9007199254740990) { + $ERROR('#4: var obj = {}; obj.length = Number.POSITIVE_INFINITY; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 9007199254740990. Actual: ' + (obj.length)); +} + +//CHECK#5 +obj.length = Number.NEGATIVE_INFINITY; +var pop = obj.pop(); +if (pop !== undefined) { + $ERROR('#5: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#6 +if (obj.length !== 0) { + $ERROR('#6: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} + +//CHECK#7 +obj.length = -0; +var pop = obj.pop(); +if (pop !== undefined) { + $ERROR('#7: var obj = {}; obj.length = -0; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#8 +if (obj.length !== 0) { + $ERROR('#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) { + $ERROR('#8: var obj = {}; obj.length = -0; obj.pop = Array.prototype.pop; obj.pop(); obj.length === +0. Actual: ' + (obj.length)); + } +} + +//CHECK#9 +obj.length = 0.5; +var pop = obj.pop(); +if (pop !== undefined) { + $ERROR('#9: var obj = {}; obj.length = 0.5; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#10 +if (obj.length !== 0) { + $ERROR('#10: var obj = {}; obj.length = 0.5; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} + +//CHECK#11 +obj.length = new Number(0); +var pop = obj.pop(); +if (pop !== undefined) { + $ERROR('#11: var obj = {}; obj.length = new Number(0); obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#12 +if (obj.length !== 0) { + $ERROR('#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..481d16bd19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_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: | + 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; + +//CHECK#1 +obj.length = 2.5; +var pop = obj.pop(); +if (pop !== undefined) { + $ERROR('#1: var obj = {}; obj.length = 2.5; obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#2 +if (obj.length !== 1) { + $ERROR('#2: var obj = {}; obj.length = 2.5; obj.pop = Array.prototype.pop; obj.pop(); obj.length === 1. Actual: ' + (obj.length)); +} + +//CHECK#3 +obj.length = new Number(2); +var pop = obj.pop(); +if (pop !== undefined) { + $ERROR('#11: var obj = {}; obj.length = new Number(2); obj.pop = Array.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#3 +if (obj.length !== 1) { + $ERROR('#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..594911596c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A2_T4.js @@ -0,0 +1,150 @@ +// 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; + +//CHECK#1 +obj[0] = -1; +obj.length = { + valueOf: function() { + return 1 + } +}; +var pop = obj.pop(); +if (pop !== -1) { + $ERROR('#1: obj[0] = -1; obj.length = {valueOf: function() {return 1}} obj.pop() === -1. Actual: ' + (pop)); +} + +//CHECK#2 +obj[0] = -1; +obj.length = { + valueOf: function() { + return 1 + }, + toString: function() { + return 0 + } +}; +var pop = obj.pop(); +if (pop !== -1) { + $ERROR('#0: obj[0] = -1; obj.length = {valueOf: function() {return 1}, toString: function() {return 0}} obj.pop() === -1. Actual: ' + (pop)); +} + +//CHECK#3 +obj[0] = -1; +obj.length = { + valueOf: function() { + return 1 + }, + toString: function() { + return {} + } +}; +var pop = obj.pop(); +if (pop !== -1) { + $ERROR('#3: obj[0] = -1; obj.length = {valueOf: function() {return 1}, toString: function() {return {}}} obj.pop() === -1. Actual: ' + (pop)); +} + +//CHECK#4 +try { + obj[0] = -1; + obj.length = { + valueOf: function() { + return 1 + }, + toString: function() { + throw "error" + } + }; + var pop = obj.pop(); + if (pop !== -1) { + $ERROR('#4.1: obj[0] = -1; obj.length = {valueOf: function() {return 1}, toString: function() {throw "error"}}; obj.pop() === ",". Actual: ' + (pop)); + } +} +catch (e) { + if (e === "error") { + $ERROR('#4.2: obj[0] = -1; obj.length = {valueOf: function() {return 1}, toString: function() {throw "error"}}; obj.pop() not throw "error"'); + } else { + $ERROR('#4.3: obj[0] = -1; obj.length = {valueOf: function() {return 1}, toString: function() {throw "error"}}; obj.pop() not throw Error. Actual: ' + (e)); + } +} + +//CHECK#5 +obj[0] = -1; +obj.length = { + toString: function() { + return 0 + } +}; +var pop = obj.pop(); +if (pop !== undefined) { + $ERROR('#5: obj[0] = -1; obj.length = {toString: function() {return 0}} obj.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#6 +obj[0] = -1; +obj.length = { + valueOf: function() { + return {} + }, + toString: function() { + return 0 + } +} +var pop = obj.pop(); +if (pop !== undefined) { + $ERROR('#6: obj[0] = -1; obj.length = {valueOf: function() {return {}}, toString: function() {return 0}} obj.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#7 +try { + obj[0] = -1; + obj.length = { + valueOf: function() { + throw "error" + }, + toString: function() { + return 0 + } + }; + var pop = obj.pop(); + $ERROR('#7.1: obj[0] = -1; obj.length = {valueOf: function() {throw "error"}, toString: function() {return 0}}; obj.pop() throw "error". Actual: ' + (pop)); +} +catch (e) { + if (e !== "error") { + $ERROR('#7.2: obj[0] = -1; obj.length = {valueOf: function() {throw "error"}, toString: function() {return 0}}; obj.pop() throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + obj[0] = -1; + obj.length = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + var pop = obj.pop(); + $ERROR('#8.1: obj[0] = -1; obj.length = {valueOf: function() {return {}}, toString: function() {return {}}} obj.pop() throw TypeError. Actual: ' + (pop)); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#8.2: obj[0] = -1; obj.length = {valueOf: function() {return {}}, toString: function() {return {}}} obj.pop() throw TypeError. Actual: ' + (e)); + } +} + +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..c0cddeb696 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_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.pop +description: length = 4294967296 +---*/ + +var obj = {}; +obj.pop = Array.prototype.pop; +obj[0] = "x"; +obj[4294967295] = "y"; +obj.length = 4294967296; + +//CHECK#1 +var pop = obj.pop(); +if (pop !== "y") { + $ERROR('#1: var obj = {}; obj.pop = Array.prototype.pop; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; obj.pop() === "y". Actual: ' + (pop)); +} + +//CHECK#2 +if (obj.length !== 4294967295) { + $ERROR('#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)); +} + +//CHECK#3 +if (obj[0] !== "x") { + $ERROR('#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])); +} + +//CHECK#4 +if (obj[4294967295] !== undefined) { + $ERROR('#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..ace04413d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A3_T2.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.pop +description: length = 4294967297 +---*/ + +var obj = {}; +obj.pop = Array.prototype.pop; +obj[0] = "x"; +obj[4294967296] = "y"; +obj.length = 4294967297; + +//CHECK#1 +var pop = obj.pop(); +if (pop !== "y") { + $ERROR('#1: var obj = {}; obj.pop = Array.prototype.pop; obj[0] = "x"; obj[4294967296] = "y"; obj.length = 4294967297; obj.pop() === "y". Actual: ' + (pop)); +} + +//CHECK#2 +if (obj.length !== 4294967296) { + $ERROR('#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)); +} + +//CHECK#3 +if (obj[0] !== "x") { + $ERROR('#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])); +} + +//CHECK#4 +if (obj[4294967296] !== undefined) { + $ERROR('#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..83ed5f502c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A3_T3.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: 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; + +//CHECK#1 +var pop = obj.pop(); +if (pop !== undefined) { + $ERROR('#1: var obj = {}; obj.pop = Array.prototype.pop; obj[4294967294] = "x"; obj.length = -1; obj.pop() === undefined. Actual: ' + (pop)); +} + +//CHECK#2 +if (obj.length !== 0) { + $ERROR('#2: var obj = {}; obj.pop = Array.prototype.pop; obj[4294967294] = "x"; obj.length = -1; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} + +//CHECK#3 +if (obj[4294967294] !== "x") { + $ERROR('#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..c089ded6ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A4_T1.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. + +/*--- +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; + +//CHECK#1 +var pop = x.pop(); +if (pop !== 1) { + $ERROR('#1: Array.prototype[1] = 1; x = [0]; x.length = 2; x.pop() === 1. Actual: ' + (pop)); +} + +//CHECK#2 +if (x[1] !== 1) { + $ERROR('#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 +}; + +//CHECK#3 +var pop = x.pop(); +if (pop !== 1) { + $ERROR('#3: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.pop = Array.prototype.pop; x = {0:0}; x.pop() === 1. Actual: ' + (pop)); +} + +//CHECK#4 +if (x[1] !== 1) { + $ERROR('#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])); +} + +//CHECK#6 +if (x.length !== 1) { + $ERROR('#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)); +} + +//CHECK#7 +delete x.length; +if (x.length !== 2) { + $ERROR('#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..11dfb271cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A4_T2.js @@ -0,0 +1,57 @@ +// 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; + +//CHECK#1 +var pop = x.pop(); +if (pop !== 1) { + $ERROR('#1: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.pop() === 1. Actual: ' + (pop)); +} + +//CHECK#2 +if (x[1] !== -1) { + $ERROR('#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 +}; + +//CHECK#3 +var pop = x.pop(); +if (pop !== 1) { + $ERROR('#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)); +} + +//CHECK#4 +if (x[1] !== -1) { + $ERROR('#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])); +} + +//CHECK#6 +if (x.length !== 1) { + $ERROR('#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)); +} + +//CHECK#7 +delete x.length; +if (x.length !== 2) { + $ERROR('#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/S15.4.4.6_A5.7.js b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A5.7.js new file mode 100644 index 0000000000..778638a6bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/S15.4.4.6_A5.7.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: The pop property of Array can't be used as constructor +esid: sec-array.prototype.pop +description: > + If property does not implement the internal [[Construct]] method, + throw a TypeError exception +---*/ + +//CHECK#1 + +try { + new Array.prototype.pop(); + $ERROR('#1.1: new Array.prototype.pop() throw TypeError. Actual: ' + (new Array.prototype.pop())); +} catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: new Array.prototype.pop() throw TypeError. Actual: ' + (e)); + } +} + +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..cce11abf14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/clamps-to-integer-limit.js @@ -0,0 +1,37 @@ +// 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). + ... +---*/ + +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..7986b5f677 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/length-near-integer-limit.js @@ -0,0 +1,45 @@ +// 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. +---*/ + +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/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..4d29c8e109 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A1_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: | + 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 +---*/ + +//CHECK#1 +var x = new Array(); +var push = x.push(1); +if (push !== 1) { + $ERROR('#1: x = new Array(); x.push(1) === 1. Actual: ' + (push)); +} + +//CHECK#2 +if (x[0] !== 1) { + $ERROR('#2: x = new Array(); x.push(1); x[0] === 1. Actual: ' + (x[0])); +} + +//CHECK#3 +var push = x.push(); +if (push !== 1) { + $ERROR('#3: x = new Array(); x.push(1); x.push() === 1. Actual: ' + (push)); +} + +//CHECK#4 +if (x[1] !== undefined) { + $ERROR('#4: x = new Array(); x.push(1); x.push(); x[1] === unedfined. Actual: ' + (x[1])); +} + +//CHECK#5 +var push = x.push(-1); +if (push !== 2) { + $ERROR('#5: x = new Array(); x.push(1); x.push(); x.push(-1) === 2. Actual: ' + (push)); +} + +//CHECK#6 +if (x[1] !== -1) { + $ERROR('#6: x = new Array(); x.push(1); x.push(-1); x[1] === -1. Actual: ' + (x[1])); +} + +//CHECK#7 +if (x.length !== 2) { + $ERROR('#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..b0cbcc5830 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A1_T2.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 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 +---*/ + +//CHECK#1 +var x = []; +if (x.length !== 0) { + $ERROR('#1: x = []; x.length === 0. Actual: ' + (x.length)); +} + +//CHECK#2 +x[0] = 0; +var push = x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); +if (push !== 6) { + $ERROR('#2: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1) === 6. Actual: ' + (push)); +} + +//CHECK#3 +if (x[0] !== 0) { + $ERROR('#3: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== true) { + $ERROR('#4: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[1] === true. Actual: ' + (x[1])); +} + +//CHECK#5 +if (x[2] !== Number.POSITIVE_INFINITY) { + $ERROR('#5: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[2] === Number.POSITIVE_INFINITY. Actual: ' + (x[2])); +} + +//CHECK#6 +if (x[3] !== "NaN") { + $ERROR('#6: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[3] === "NaN". Actual: ' + (x[3])); +} + +//CHECK#7 +if (x[4] !== "1") { + $ERROR('#7: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[4] === "1". Actual: ' + (x[4])); +} + +//CHECK#8 +if (x[5] !== -1) { + $ERROR('#8: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[5] === -1. Actual: ' + (x[5])); +} + +//CHECK#9 +if (x.length !== 6) { + $ERROR('#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..b7b32ae788 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_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: | + 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) { + $ERROR('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + //CHECK#1 + var push = obj.push(-1); + if (push !== 1) { + $ERROR('#1: var obj = {}; obj.push = Array.prototype.push; obj.push(-1) === 1. Actual: ' + (push)); + } + //CHECK#2 + if (obj.length !== 1) { + $ERROR('#2: var obj = {}; obj.push = Array.prototype.push; obj.push(-1); obj.length === 1. Actual: ' + (obj.length)); + } + //CHECK#3 + if (obj["0"] !== -1) { + $ERROR('#3: var obj = {}; obj.push = Array.prototype.push; obj.push(-1); obj["0"] === -1. Actual: ' + (obj["0"])); + } +} + +//CHECK#4 +obj.length = undefined; +var push = obj.push(-4); +if (push !== 1) { + $ERROR('#4: var obj = {}; obj.length = undefined; obj.push = Array.prototype.push; obj.push(-4) === 1. Actual: ' + (push)); +} + +//CHECK#5 +if (obj.length !== 1) { + $ERROR('#5: var obj = {}; obj.length = undefined; obj.push = Array.prototype.push; obj.push(-4); obj.length === 1. Actual: ' + (obj.length)); +} + +//CHECK#6 +if (obj["0"] !== -4) { + $ERROR('#6: var obj = {}; obj.length = undefined; obj.push = Array.prototype.push; obj.push(-4); obj["0"] === -4. Actual: ' + (obj["0"])); +} + +//CHECK#7 +obj.length = null +var push = obj.push(-7); +if (push !== 1) { + $ERROR('#7: var obj = {}; obj.length = null; obj.push = Array.prototype.push; obj.push(-7) === 1. Actual: ' + (push)); +} + +//CHECK#8 +if (obj.length !== 1) { + $ERROR('#8: var obj = {}; obj.length = null; obj.push = Array.prototype.push; obj.push(-7); obj.length === 1. Actual: ' + (obj.length)); +} + +//CHECK#9 +if (obj["0"] !== -7) { + $ERROR('#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..c888d5750b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_T2.js @@ -0,0 +1,119 @@ +// 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; + +//CHECK#1 +obj.length = NaN; +var push = obj.push(-1); +if (push !== 1) { + $ERROR('#1: var obj = {}; obj.length = NaN; obj.push = Array.prototype.push; obj.push(-1) === 1. Actual: ' + (push)); +} + +//CHECK#2 +if (obj.length !== 1) { + $ERROR('#2: var obj = {}; obj.length = NaN; obj.push = Array.prototype.push; obj.push(-1); obj.length === 1. Actual: ' + (obj.length)); +} + +//CHECK#3 +if (obj["0"] !== -1) { + $ERROR('#3: var obj = {}; obj.length = NaN; obj.push = Array.prototype.push; obj.push(-1); obj["0"] === -1. Actual: ' + (obj["0"])); +} + +//CHECK#4 +obj.length = Number.POSITIVE_INFINITY; +assert.throws(TypeError, function() { + obj.push(-4); +}); + +//CHECK#5 +if (obj.length !== Number.POSITIVE_INFINITY) { + $ERROR('#6: var obj = {}; obj.length = Number.POSITIVE_INFINITY; obj.push = Array.prototype.push; obj.push(-4); obj.length === Number.POSITIVE_INFINITY. Actual: ' + (obj.length)); +} + +//CHECK#6 +if (obj[9007199254740991] !== undefined) { + $ERROR('#6: var obj = {}; obj.length = Number.POSITIVE_INFINITY; obj.push = Array.prototype.push; obj.push(-4); obj[9007199254740991] === undefined. Actual: ' + (obj["9007199254740991"])); +} + +//CHECK#7 +obj.length = Number.NEGATIVE_INFINITY; +var push = obj.push(-7); +if (push !== 1) { + $ERROR('#7: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.push = Array.prototype.push; obj.push(-7) === 1. Actual: ' + (push)); +} + +//CHECK#8 +if (obj.length !== 1) { + $ERROR('#8: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.push = Array.prototype.push; obj.push(-7); obj.length === 1. Actual: ' + (obj.length)); +} + +//CHECK#9 +if (obj["0"] !== -7) { + $ERROR('#9: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.push = Array.prototype.push; obj.push(-7); obj["0"] === -7. Actual: ' + (obj["0"])); +} + +//CHECK#10 +obj.length = 0.5; +var push = obj.push(-10); +if (push !== 1) { + $ERROR('#10: var obj = {}; obj.length = 0.5; obj.push = Array.prototype.push; obj.push(-10) === 1. Actual: ' + (push)); +} + +//CHECK#11 +if (obj.length !== 1) { + $ERROR('#11: var obj = {}; obj.length = 0.5; obj.push = Array.prototype.push; obj.push(-10); obj.length === 1. Actual: ' + (obj.length)); +} + +//CHECK#12 +if (obj["0"] !== -10) { + $ERROR('#12: var obj = {}; obj.length = 0.5; obj.push = Array.prototype.push; obj.push(-10); obj["0"] === -10. Actual: ' + (obj["0"])); +} + +//CHECK#13 +obj.length = 1.5; +var push = obj.push(-13); +if (push !== 2) { + $ERROR('#13: var obj = {}; obj.length = 1.5; obj.push = Array.prototype.push; obj.push(-13) === 2. Actual: ' + (push)); +} + +//CHECK#14 +if (obj.length !== 2) { + $ERROR('#14: var obj = {}; obj.length = 1.5; obj.push = Array.prototype.push; obj.push(-13); obj.length === 2. Actual: ' + (obj.length)); +} + +//CHECK#15 +if (obj["1"] !== -13) { + $ERROR('#15: var obj = {}; obj.length = 1.5; obj.push = Array.prototype.push; obj.push(-13); obj["1"] === -13. Actual: ' + (obj["1"])); +} + +//CHECK#16 +obj.length = new Number(0); +var push = obj.push(-16); +if (push !== 1) { + $ERROR('#16: var obj = {}; obj.length = new Number(0); obj.push = Array.prototype.push; obj.push(-16) === 1. Actual: ' + (push)); +} + +//CHECK#17 +if (obj.length !== 1) { + $ERROR('#17: var obj = {}; obj.length = new Number(0); obj.push = Array.prototype.push; obj.push(-16); obj.length === 1. Actual: ' + (obj.length)); +} + +//CHECK#18 +if (obj["0"] !== -16) { + $ERROR('#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..9941a650d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A2_T3.js @@ -0,0 +1,145 @@ +// 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; + +//CHECK#1 +obj.length = { + valueOf: function() { + return 3 + } +}; +var push = obj.push(); +if (push !== 3) { + $ERROR('#1: obj.length = {valueOf: function() {return 3}} obj.push() === 3. Actual: ' + (push)); +} + +//CHECK#2 +obj.length = { + valueOf: function() { + return 3 + }, + toString: function() { + return 1 + } +}; +var push = obj.push(); +if (push !== 3) { + $ERROR('#0: obj.length = {valueOf: function() {return 3}, toString: function() {return 1}} obj.push() === 3. Actual: ' + (push)); +} + +//CHECK#3 +obj.length = { + valueOf: function() { + return 3 + }, + toString: function() { + return {} + } +}; +var push = obj.push(); +if (push !== 3) { + $ERROR('#1: obj.length = {valueOf: function() {return 3}, toString: function() {return {}}} obj.push() === 3. Actual: ' + (push)); +} + +//CHECK#4 +try { + + obj.length = { + valueOf: function() { + return 3 + }, + toString: function() { + throw "error" + } + }; + var push = obj.push(); + if (push !== 3) { + $ERROR('#4.1: obj.length = {valueOf: function() {return 3}, toString: function() {throw "error"}}; obj.push() === ",". Actual: ' + (push)); + } +} +catch (e) { + if (e === "error") { + $ERROR('#4.2: obj.length = {valueOf: function() {return 3}, toString: function() {throw "error"}}; obj.push() not throw "error"'); + } else { + $ERROR('#4.3: obj.length = {valueOf: function() {return 3}, toString: function() {throw "error"}}; obj.push() not throw Error. Actual: ' + (e)); + } +} + +//CHECK#5 +obj.length = { + toString: function() { + return 1 + } +}; +var push = obj.push(); +if (push !== 1) { + $ERROR('#5: obj.length = {toString: function() {return 1}} obj.push() === 1. Actual: ' + (push)); +} + +//CHECK#6 +obj.length = { + valueOf: function() { + return {} + }, + toString: function() { + return 1 + } +} +var push = obj.push(); +if (push !== 1) { + $ERROR('#6: obj.length = {valueOf: function() {return {}}, toString: function() {return 1}} obj.push() === 1. Actual: ' + (push)); +} + +//CHECK#7 +try { + + obj.length = { + valueOf: function() { + throw "error" + }, + toString: function() { + return 1 + } + }; + var push = obj.push(); + $ERROR('#7.1: obj.length = {valueOf: function() {throw "error"}, toString: function() {return 1}}; obj.push() throw "error". Actual: ' + (push)); +} +catch (e) { + if (e !== "error") { + $ERROR('#7.2: obj.length = {valueOf: function() {throw "error"}, toString: function() {return 1}}; obj.push() throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + + obj.length = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + var push = obj.push(); + $ERROR('#8.1: obj.length = {valueOf: function() {return {}}, toString: function() {return {}}} obj.push() throw TypeError. Actual: ' + (push)); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#8.2: obj.length = {valueOf: function() {return {}}, toString: function() {return {}}} obj.push() throw TypeError. Actual: ' + (e)); + } +} + +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..efca0b947b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A3.js @@ -0,0 +1,39 @@ +// 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; + +//CHECK#1 +var push = x.push(); +if (push !== 4294967295) { + $ERROR('#1: x = []; x.length = 4294967295; x.push() === 4294967295. Actual: ' + (push)); +} + +//CHECK#2 +try { + x.push("x"); + $ERROR('#2.1: x = []; x.length = 4294967295; x.push("x") throw RangeError. Actual: ' + (push)); +} catch (e) { + if ((e instanceof RangeError) !== true) { + $ERROR('#2.2: x = []; x.length = 4294967295; x.push("x") throw RangeError. Actual: ' + (e)); + } +} + +//CHECK#3 +if (x[4294967295] !== "x") { + $ERROR('#3: x = []; x.length = 4294967295; try {x.push("x")}catch(e){}; x[4294967295] === "x". Actual: ' + (x[4294967295])); +} + +//CHECK#4 +if (x.length !== 4294967295) { + $ERROR('#4: x = []; x.length = 4294967295; try {x.push("x")}catch(e){}; x.length === 4294967295. Actual: ' + (x.length)); +} + +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..c93dda7e10 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_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: 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; + +//CHECK#1 +var push = obj.push("x", "y", "z"); +if (push !== 4294967299) { + $ERROR('#1: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z") === 4294967299. Actual: ' + (push)); +} + +//CHECK#2 +if (obj.length !== 4294967299) { + $ERROR('#2: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj.length === 4294967299. Actual: ' + (obj.length)); +} + +//CHECK#3 +if (obj[0] !== undefined) { + $ERROR('#3: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[0] === undefined. Actual: ' + (obj[0])); +} + +//CHECK#4 +if (obj[1] !== undefined) { + $ERROR('#4: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[1] === undefined. Actual: ' + (obj[1])); +} + +//CHECK#5 +if (obj[2] !== undefined) { + $ERROR('#5: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[2] === undefined. Actual: ' + (obj[2])); +} + +//CHECK#6 +if (obj[4294967296] !== "x") { + $ERROR('#6: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[4294967296] === "x". Actual: ' + (obj[4294967296])); +} + +//CHECK#7 +if (obj[4294967297] !== "y") { + $ERROR('#7: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[4294967297] === "y". Actual: ' + (obj[4294967297])); +} + +//CHECK#8 +if (obj[4294967298] !== "z") { + $ERROR('#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; + +//CHECK#9 +var push = obj.push(); +if (push !== 4294967296) { + $ERROR('#9: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push() === 4294967296. Actual: ' + (push)); +} + +//CHECK#10 +if (obj.length !== 4294967296) { + $ERROR('#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..a4e4856420 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A4_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.push +description: length = 4294967295 +---*/ + +var obj = {}; +obj.push = Array.prototype.push; +obj.length = 4294967295; + +//CHECK#1 +var push = obj.push("x", "y", "z"); +if (push !== 4294967298) { + $ERROR('#1: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z") === 4294967298. Actual: ' + (push)); +} + +//CHECK#2 +if (obj.length !== 4294967298) { + $ERROR('#2: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z"); obj.length === 4294967298. Actual: ' + (obj.length)); +} + +//CHECK#3 +if (obj[4294967295] !== "x") { + $ERROR('#3: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z"); obj[4294967295] === "x". Actual: ' + (obj[4294967295])); +} + +//CHECK#4 +if (obj[4294967296] !== "y") { + $ERROR('#4: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z"); obj[4294967296] === "y". Actual: ' + (obj[4294967296])); +} + +//CHECK#5 +if (obj[4294967297] !== "z") { + $ERROR('#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..b5bdc8ba42 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A4_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: 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; + +//CHECK#1 +var push = obj.push("x", "y", "z"); +if (push !== 3) { + $ERROR('#1: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z") === 3. Actual: ' + (push)); +} + +//CHECK#2 +if (obj.length !== 3) { + $ERROR('#2: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj.length === 3. Actual: ' + (obj.length)); +} + +//CHECK#3 +if (obj[4294967295] !== undefined) { + $ERROR('#3: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[4294967295] === undefined. Actual: ' + (obj[4294967295])); +} + +//CHECK#4 +if (obj[4294967296] !== undefined) { + $ERROR('#4: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[4294967296] === undefined. Actual: ' + (obj[4294967296])); +} + +//CHECK#5 +if (obj[4294967297] !== undefined) { + $ERROR('#5: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[4294967297] === undefined. Actual: ' + (obj[4294967297])); +} + +//CHECK#6 +if (obj[0] !== "x") { + $ERROR('#3: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[0] === "x". Actual: ' + (obj[0])); +} + +//CHECK#7 +if (obj[1] !== "y") { + $ERROR('#4: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[1] === "y". Actual: ' + (obj[1])); +} + +//CHECK#8 +if (obj[2] !== "z") { + $ERROR('#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..975850f38f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A5_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. + +/*--- +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 +}; + +//CHECK#1 +var push = x.push(1); +if (push !== 2) { + $ERROR('#1: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; x.push(1) === 2. Actual: ' + (push)); +} + +//CHECK#2 +if (x.length !== 2) { + $ERROR('#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)); +} + +//CHECK#3 +if (x[1] !== 1) { + $ERROR('#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])); +} + +//CHECK#4 +delete x[1]; +if (x[1] !== -1) { + $ERROR('#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])); +} + +//CHECK#5 +delete x.length; +if (x.length !== 1) { + $ERROR('#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/S15.4.4.7_A6.7.js b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A6.7.js new file mode 100644 index 0000000000..0626c8c215 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A6.7.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: The push property of Array can't be used as constructor +esid: sec-array.prototype.push +description: > + If property does not implement the internal [[Construct]] method, + throw a TypeError exception +---*/ + +//CHECK#1 + +try { + new Array.prototype.push(); + $ERROR('#1.1: new Array.prototype.push() throw TypeError. Actual: ' + (new Array.prototype.push())); +} catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: new Array.prototype.push() throw TypeError. Actual: ' + (e)); + } +} + +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..75d848a51a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/clamps-to-integer-limit.js @@ -0,0 +1,37 @@ +// 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). + ... +---*/ + +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..b9f5f92567 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/length-near-integer-limit.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 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). + ... +---*/ + +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/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..530d4d41ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/push/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.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. + ... +---*/ + +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..fe64670a6d --- /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, function() {}, "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/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..e69de29bb2 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..c1d94d4870 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/15.4.4.22-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.reduceright +description: > + Array.prototype.reduceRight - no observable effects occur if 'len' + is 0 +---*/ + +var accessed = false; + +function callbackfn() { + accessed = true; +} + +var obj = { + length: 0 +}; + +Object.defineProperty(obj, "5", { + get: function() { + accessed = true; + return 10; + }, + configurable: true +}); + +Array.prototype.reduceRight.call(obj, function() {}, "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-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/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..3edaa5dfbc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/length-near-integer-limit.js @@ -0,0 +1,51 @@ +// 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); + assert.compareArray(acc[0], [1, Number.MAX_SAFE_INTEGER - 1]); + assert.compareArray(acc[1], [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..e69de29bb2 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..f92ab21897 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_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 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 +---*/ + +//CHECK#1 +var x = []; +var reverse = x.reverse(); +if (reverse !== x) { + $ERROR('#1: x = []; x.reverse() === x. Actual: ' + (reverse)); +} + +//CHECK#2 +x = []; +x[0] = 1; +var reverse = x.reverse(); +if (reverse !== x) { + $ERROR('#2: x = []; x[0] = 1; x.reverse() === x. Actual: ' + (reverse)); +} + +//CHECK#3 +x = new Array(1, 2); +var reverse = x.reverse(); +if (reverse !== x) { + $ERROR('#3: x = new Array(1,2); x.reverse() === x. Actual: ' + (reverse)); +} + +//CHECK#4 +if (x[0] !== 2) { + $ERROR('#4: x = new Array(1,2); x.reverse(); x[0] === 2. Actual: ' + (x[0])); +} + +//CHECK#5 +if (x[1] !== 1) { + $ERROR('#5: x = new Array(1,2); x.reverse(); x[1] === 1. Actual: ' + (x[1])); +} + +//CHECK#6 +if (x.length !== 2) { + $ERROR('#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..568bcf55fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A1_T2.js @@ -0,0 +1,128 @@ +// 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 +---*/ + +//CHECK#1 +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) { + $ERROR('#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)); +} + +//CHECK#2 +if (x[0] !== "-1") { + $ERROR('#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])); +} + +//CHECK#3 +if (x[1] !== "NaN") { + $ERROR('#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])); +} + +//CHECK#4 +if (x[2] !== undefined) { + $ERROR('#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])); +} + +//CHECK#5 +if (x[3] !== undefined) { + $ERROR('#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])); +} + +//CHECK#6 +if (x[4] !== undefined) { + $ERROR('#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])); +} + +//CHECK#7 +if (x[5] !== undefined) { + $ERROR('#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])); +} + +//CHECK#8 +if (x[6] !== undefined) { + $ERROR('#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])); +} + +//CHECK#9 +if (x[7] !== Infinity) { + $ERROR('#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])); +} + +//CHECK#10 +if (x[8] !== undefined) { + $ERROR('#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])); +} + +//CHECK#11 +if (x[9] !== true) { + $ERROR('#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) { + $ERROR('#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)); +} + +//CHECK#12 +if (x[0] !== undefined) { + $ERROR('#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])); +} + +//CHECK#13 +if (x[1] !== Infinity) { + $ERROR('#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])); +} + +//CHECK#14 +if (x[2] !== undefined) { + $ERROR('#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])); +} + +//CHECK#15 +if (x[3] !== undefined) { + $ERROR('#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])); +} + +//CHECK#16 +if (x[4] !== undefined) { + $ERROR('#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])); +} + +//CHECK#17 +if (x[5] !== undefined) { + $ERROR('#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])); +} + +//CHECK#18 +if (x[6] !== undefined) { + $ERROR('#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])); +} + +//CHECK#19 +if (x[7] !== "NaN") { + $ERROR('#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])); +} + +//CHECK#20 +if (x[8] !== "-1") { + $ERROR('#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..23b51aac45 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T1.js @@ -0,0 +1,133 @@ +// 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 +---*/ + +//CHECK#1 +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) { + $ERROR('#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)); +} + +//CHECK#2 +if (obj[0] !== "-1") { + $ERROR('#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])); +} + +//CHECK#3 +if (obj[1] !== "NaN") { + $ERROR('#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])); +} + +//CHECK#4 +if (obj[2] !== undefined) { + $ERROR('#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])); +} + +//CHECK#5 +if (obj[3] !== undefined) { + $ERROR('#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])); +} + +//CHECK#6 +if (obj[4] !== undefined) { + $ERROR('#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])); +} + +//CHECK#7 +if (obj[5] !== undefined) { + $ERROR('#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])); +} + +//CHECK#8 +if (obj[6] !== undefined) { + $ERROR('#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])); +} + +//CHECK#9 +if (obj[7] !== Infinity) { + $ERROR('#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])); +} + +//CHECK#10 +if (obj[8] !== undefined) { + $ERROR('#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])); +} + +//CHECK#11 +if (obj[9] !== true) { + $ERROR('#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) { + $ERROR('#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)); +} + +//CHECK#12 +if (obj[0] !== undefined) { + $ERROR('#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])); +} + +//CHECK#13 +if (obj[1] !== Infinity) { + $ERROR('#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])); +} + +//CHECK#14 +if (obj[2] !== undefined) { + $ERROR('#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])); +} + +//CHECK#15 +if (obj[3] !== undefined) { + $ERROR('#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])); +} + +//CHECK#16 +if (obj[4] !== undefined) { + $ERROR('#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])); +} + +//CHECK#17 +if (obj[5] !== undefined) { + $ERROR('#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])); +} + +//CHECK#18 +if (obj[6] !== undefined) { + $ERROR('#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])); +} + +//CHECK#19 +if (obj[7] !== "NaN") { + $ERROR('#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])); +} + +//CHECK#20 +if (obj[8] !== "-1") { + $ERROR('#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..9c49ef2088 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T2.js @@ -0,0 +1,133 @@ +// 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 +---*/ + +//CHECK#1 +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) { + $ERROR('#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)); +} + +//CHECK#2 +if (obj[0] !== "-1") { + $ERROR('#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])); +} + +//CHECK#3 +if (obj[1] !== "NaN") { + $ERROR('#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])); +} + +//CHECK#4 +if (obj[2] !== undefined) { + $ERROR('#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])); +} + +//CHECK#5 +if (obj[3] !== undefined) { + $ERROR('#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])); +} + +//CHECK#6 +if (obj[4] !== undefined) { + $ERROR('#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])); +} + +//CHECK#7 +if (obj[5] !== undefined) { + $ERROR('#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])); +} + +//CHECK#8 +if (obj[6] !== undefined) { + $ERROR('#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])); +} + +//CHECK#9 +if (obj[7] !== Infinity) { + $ERROR('#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])); +} + +//CHECK#10 +if (obj[8] !== undefined) { + $ERROR('#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])); +} + +//CHECK#11 +if (obj[9] !== true) { + $ERROR('#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) { + $ERROR('#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)); +} + +//CHECK#12 +if (obj[0] !== undefined) { + $ERROR('#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])); +} + +//CHECK#13 +if (obj[1] !== Infinity) { + $ERROR('#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])); +} + +//CHECK#14 +if (obj[2] !== undefined) { + $ERROR('#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])); +} + +//CHECK#15 +if (obj[3] !== undefined) { + $ERROR('#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])); +} + +//CHECK#16 +if (obj[4] !== undefined) { + $ERROR('#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])); +} + +//CHECK#17 +if (obj[5] !== undefined) { + $ERROR('#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])); +} + +//CHECK#18 +if (obj[6] !== undefined) { + $ERROR('#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])); +} + +//CHECK#19 +if (obj[7] !== "NaN") { + $ERROR('#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])); +} + +//CHECK#20 +if (obj[8] !== "-1") { + $ERROR('#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..b68ca0a6fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A2_T3.js @@ -0,0 +1,133 @@ +// 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 +---*/ + +//CHECK#1 +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) { + $ERROR('#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)); +} + +//CHECK#2 +if (obj[0] !== "-1") { + $ERROR('#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])); +} + +//CHECK#3 +if (obj[1] !== "NaN") { + $ERROR('#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])); +} + +//CHECK#4 +if (obj[2] !== undefined) { + $ERROR('#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])); +} + +//CHECK#5 +if (obj[3] !== undefined) { + $ERROR('#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])); +} + +//CHECK#6 +if (obj[4] !== undefined) { + $ERROR('#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])); +} + +//CHECK#7 +if (obj[5] !== undefined) { + $ERROR('#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])); +} + +//CHECK#8 +if (obj[6] !== undefined) { + $ERROR('#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])); +} + +//CHECK#9 +if (obj[7] !== Infinity) { + $ERROR('#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])); +} + +//CHECK#10 +if (obj[8] !== undefined) { + $ERROR('#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])); +} + +//CHECK#11 +if (obj[9] !== true) { + $ERROR('#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) { + $ERROR('#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)); +} + +//CHECK#12 +if (obj[0] !== undefined) { + $ERROR('#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])); +} + +//CHECK#13 +if (obj[1] !== Infinity) { + $ERROR('#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])); +} + +//CHECK#14 +if (obj[2] !== undefined) { + $ERROR('#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])); +} + +//CHECK#15 +if (obj[3] !== undefined) { + $ERROR('#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])); +} + +//CHECK#16 +if (obj[4] !== undefined) { + $ERROR('#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])); +} + +//CHECK#17 +if (obj[5] !== undefined) { + $ERROR('#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])); +} + +//CHECK#18 +if (obj[6] !== undefined) { + $ERROR('#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])); +} + +//CHECK#19 +if (obj[7] !== "NaN") { + $ERROR('#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])); +} + +//CHECK#20 +if (obj[8] !== "-1") { + $ERROR('#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..c7ce14249a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A3_T3.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: 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; + +//CHECK#1 +var reverse = obj.reverse(); +if (reverse !== obj) { + $ERROR('#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)); +} + +//CHECK#2 +if (obj.length !== -4294967294) { + $ERROR('#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)); +} + +//CHECK#3 +if (obj[0] !== "x") { + $ERROR('#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])); +} + +//CHECK#4 +if (obj[1] !== "y") { + $ERROR('#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])); +} + +//CHECK#5 +if (obj[2] !== "z") { + $ERROR('#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..eb94ce8718 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_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.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(); + +//CHECK#1 +if (x[0] !== 1) { + $ERROR('#1: Array.prototype[1] = 1; x = [0]; x.length = 2; x.reverse(); x[0] === 1. Actual: ' + (x[0])); +} + +//CHECK#2 +if (x[1] !== 0) { + $ERROR('#2: Array.prototype[1] = 1; x = [0]; x.length = 2; x.reverse(); x[1] === 0. Actual: ' + (x[1])); +} + +x.length = 0; + +//CHECK#3 +if (x[0] !== undefined) { + $ERROR('#3: Array.prototype[1] = 1; x = [0]; x.length = 2; x.reverse(); x.length = 0; x[0] === undefined. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== 1) { + $ERROR('#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(); + +//CHECK#5 +if (x[0] !== 1) { + $ERROR('#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])); +} + +//CHECK#6 +if (x[1] !== 0) { + $ERROR('#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]; + +//CHECK#7 +if (x[0] !== undefined) { + $ERROR('#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])); +} + +//CHECK#8 +if (x[1] !== 1) { + $ERROR('#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..42873ee4ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A4_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: "[[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(); + +//CHECK#1 +if (x[0] !== 1) { + $ERROR('#1: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.reverse(); x[0] === 1. Actual: ' + (x[0])); +} + +//CHECK#2 +if (x[1] !== 0) { + $ERROR('#2: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.reverse(); x[1] === 0. Actual: ' + (x[1])); +} + +x.length = 0; + +//CHECK#3 +if (x[0] !== undefined) { + $ERROR('#3: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.reverse(); x.length = 0; x[0] === undefined. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== -1) { + $ERROR('#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(); + +//CHECK#5 +if (x[0] !== 1) { + $ERROR('#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])); +} + +//CHECK#6 +if (x[1] !== 0) { + $ERROR('#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]; + +//CHECK#7 +if (x[0] !== undefined) { + $ERROR('#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])); +} + +//CHECK#8 +if (x[1] !== -1) { + $ERROR('#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/S15.4.4.8_A5.7.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A5.7.js new file mode 100644 index 0000000000..2e8e838068 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/S15.4.4.8_A5.7.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: The reverse property of Array can't be used as constructor +esid: sec-array.prototype.reverse +description: > + If property does not implement the internal [[Construct]] method, + throw a TypeError exception +---*/ + +//CHECK#1 + +try { + new Array.prototype.reverse(); + $ERROR('#1.1: new Array.prototype.reverse() throw TypeError. Actual: ' + (new Array.prototype.reverse())); +} catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: new Array.prototype.reverse() throw TypeError. Actual: ' + (e)); + } +} + +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..eae9b5be7b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-object.js @@ -0,0 +1,34 @@ +// 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")). + ... +---*/ + +function StopReverse() {} + +// Object with large "length" property and no indexed properties in the uint32 range. +var arrayLike = { + get "9007199254740990" () { + throw new StopReverse(); + }, + get "9007199254740991" () { + $ERROR("Get 9007199254740991"); + }, + get "9007199254740992" () { + $ERROR("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..1f7f5883b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-proxy.js @@ -0,0 +1,121 @@ +// 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] +---*/ + +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); +}); + +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", +]); + +assert.sameValue(arrayLike.length, 2 ** 53 + 2, "Length property is not modified"); + +assert.sameValue(arrayLike[0], "2**53-2", "Property at index 0"); +assert.sameValue(1 in arrayLike, false, "Property at index 1"); +assert.sameValue(2 in arrayLike, false, "Property at index 2"); +assert.sameValue(arrayLike[3], "2**53-5", "Property at index 3"); + +assert.sameValue(9007199254740987 in arrayLike, false, "Property at index 2**53-5"); +assert.sameValue(arrayLike[9007199254740988], "two", "Property at index 2**53-4"); +assert.sameValue(9007199254740989 in arrayLike, false, "Property at index 2**53-3"); +assert.sameValue(arrayLike[9007199254740990], "zero", "Property at index 2**53-2"); + +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..f95f4961f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A1.1_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: | + 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 +---*/ + +//CHECK#1 +var x = new Array(); +var shift = x.shift(); +if (shift !== undefined) { + $ERROR('#1: var x = new Array(); x.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#2 +if (x.length !== 0) { + $ERROR('#2: var x = new Array(); x.shift(); x.length === 0. Actual: ' + (x.length)); +} + +//CHECK#3 +var x = Array(1, 2, 3); +x.length = 0; +var shift = x.shift(); +if (shift !== undefined) { + $ERROR('#2: var x = Array(1,2,3); x.length = 0; x.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#4 +if (x.length !== 0) { + $ERROR('#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..a7287497da --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A1.2_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: | + 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 [] +---*/ + +//CHECK#1 +var x = new Array(0, 1, 2, 3); +var shift = x.shift(); +if (shift !== 0) { + $ERROR('#1: x = new Array(0,1,2,3); x.shift() === 0. Actual: ' + (shift)); +} + +//CHECK#2 +if (x.length !== 3) { + $ERROR('#2: x = new Array(0,1,2,3); x.shift(); x.length == 3'); +} + +//CHECK#3 +if (x[0] !== 1) { + $ERROR('#3: x = new Array(0,1,2,3); x.shift(); x[0] == 1'); +} + +//CHECK#4 +if (x[1] !== 2) { + $ERROR('#4: x = new Array(0,1,2,3); x.shift(); x[1] == 2'); +} + +//CHECK#5 +x = []; +x[0] = 0; +x[3] = 3; +var shift = x.shift(); +if (shift !== 0) { + $ERROR('#5: x = []; x[0] = 0; x[3] = 3; x.shift() === 0. Actual: ' + (shift)); +} + +//CHECK#6 +if (x.length !== 3) { + $ERROR('#6: x = []; x[0] = 0; x[3] = 3; x.shift(); x.length == 3'); +} + +//CHECK#7 +if (x[0] !== undefined) { + $ERROR('#7: x = []; x[0] = 0; x[3] = 3; x.shift(); x[0] == undefined'); +} + +//CHECK#8 +if (x[12] !== undefined) { + $ERROR('#8: x = []; x[0] = 0; x[3] = 3; x.shift(); x[1] == undefined'); +} + +//CHECK#9 +x.length = 1; +var shift = x.shift(); +if (shift !== undefined) { + $ERROR('#9: x = []; x[0] = 0; x[3] = 3; x.shift(); x.length = 1; x.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#10 +if (x.length !== 0) { + $ERROR('#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..5c4771fa82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T1.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 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) { + $ERROR('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + //CHECK#1 + var shift = obj.shift(); + if (shift !== undefined) { + $ERROR('#1: var obj = {}; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); + } + //CHECK#2 + if (obj.length !== 0) { + $ERROR('#2: var obj = {}; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); + } +} + +//CHECK#3 +obj.length = undefined; +var shift = obj.shift(); +if (shift !== undefined) { + $ERROR('#3: var obj = {}; obj.length = undefined; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#4 +if (obj.length !== 0) { + $ERROR('#4: var obj = {}; obj.length = undefined; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} + +//CHECK#5 +obj.length = null +var shift = obj.shift(); +if (shift !== undefined) { + $ERROR('#5: var obj = {}; obj.length = null; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#6 +if (obj.length !== 0) { + $ERROR('#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..c085a1c24b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_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 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; + +//CHECK#1 +obj.length = NaN; +var shift = obj.shift(); +if (shift !== undefined) { + $ERROR('#1: var obj = {}; obj.length = NaN; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#2 +if (obj.length !== 0) { + $ERROR('#2: var obj = {}; obj.length = NaN; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} + +//CHECK#5 +obj.length = Number.NEGATIVE_INFINITY; +var shift = obj.shift(); +if (shift !== undefined) { + $ERROR('#5: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#6 +if (obj.length !== 0) { + $ERROR('#6: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} + +//CHECK#7 +obj.length = -0; +var shift = obj.shift(); +if (shift !== undefined) { + $ERROR('#7: var obj = {}; obj.length = -0; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#8 +if (obj.length !== 0) { + $ERROR('#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) { + $ERROR('#8: var obj = {}; obj.length = -0; obj.shift = Array.prototype.shift; obj.shift(); obj.length === +0. Actual: ' + (obj.length)); + } +} + +//CHECK#9 +obj.length = 0.5; +var shift = obj.shift(); +if (shift !== undefined) { + $ERROR('#9: var obj = {}; obj.length = 0.5; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#10 +if (obj.length !== 0) { + $ERROR('#10: var obj = {}; obj.length = 0.5; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} + +//CHECK#11 +obj.length = new Number(0); +var shift = obj.shift(); +if (shift !== undefined) { + $ERROR('#11: var obj = {}; obj.length = new Number(0); obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#12 +if (obj.length !== 0) { + $ERROR('#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..094f472fd9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_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: | + 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; + +//CHECK#1 +obj.length = 2.5; +var shift = obj.shift(); +if (shift !== undefined) { + $ERROR('#1: var obj = {}; obj.length = 2.5; obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#2 +if (obj.length !== 1) { + $ERROR('#2: var obj = {}; obj.length = 2.5; obj.shift = Array.prototype.shift; obj.shift(); obj.length === 1. Actual: ' + (obj.length)); +} + +//CHECK#3 +obj.length = new Number(2); +var shift = obj.shift(); +if (shift !== undefined) { + $ERROR('#11: var obj = {}; obj.length = new Number(2); obj.shift = Array.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#3 +if (obj.length !== 1) { + $ERROR('#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..41ac0b2c0c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T4.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 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; + +//CHECK#1 +obj.length = 4; +var shift = obj.shift(); +if (shift !== 0) { + $ERROR('#1: var obj = {}; obj["0"] = 0; obj["3"] = 3; obj.length = 4; obj.shift = Array.prototype.shift; obj.shift() === 0. Actual: ' + (shift)); +} + +//CHECK#2 +if (obj.length !== 3) { + $ERROR('#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)); +} + +//CHECK#3 +var shift = obj.shift(); +if (shift !== undefined) { + $ERROR('#3: var obj = {}; obj["0"] = 0; obj["3"] = 3; obj.length = 4; obj.shift = Array.prototype.shift; obj.shift(); obj.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#4 +if (obj.length !== 2) { + $ERROR('#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)); +} + +//CHECK#5 +obj.length = 1; +var shift = obj.shift(); +if (shift !== undefined) { + $ERROR('#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)); +} + +//CHECK#6 +if (obj.length !== 0) { + $ERROR('#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..a632d90e5a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A2_T5.js @@ -0,0 +1,150 @@ +// 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; + +//CHECK#1 +obj[0] = -1; +obj.length = { + valueOf: function() { + return 1 + } +}; +var shift = obj.shift(); +if (shift !== -1) { + $ERROR('#1: obj[0] = -1; obj.length = {valueOf: function() {return 1}} obj.shift() === -1. Actual: ' + (shift)); +} + +//CHECK#2 +obj[0] = -1; +obj.length = { + valueOf: function() { + return 1 + }, + toString: function() { + return 0 + } +}; +var shift = obj.shift(); +if (shift !== -1) { + $ERROR('#0: obj[0] = -1; obj.length = {valueOf: function() {return 1}, toString: function() {return 0}} obj.shift() === -1. Actual: ' + (shift)); +} + +//CHECK#3 +obj[0] = -1; +obj.length = { + valueOf: function() { + return 1 + }, + toString: function() { + return {} + } +}; +var shift = obj.shift(); +if (shift !== -1) { + $ERROR('#3: obj[0] = -1; obj.length = {valueOf: function() {return 1}, toString: function() {return {}}} obj.shift() === -1. Actual: ' + (shift)); +} + +//CHECK#4 +try { + obj[0] = -1; + obj.length = { + valueOf: function() { + return 1 + }, + toString: function() { + throw "error" + } + }; + var shift = obj.shift(); + if (shift !== -1) { + $ERROR('#4.1: obj[0] = -1; obj.length = {valueOf: function() {return 1}, toString: function() {throw "error"}}; obj.shift() === ",". Actual: ' + (shift)); + } +} +catch (e) { + if (e === "error") { + $ERROR('#4.2: obj[0] = -1; obj.length = {valueOf: function() {return 1}, toString: function() {throw "error"}}; obj.shift() not throw "error"'); + } else { + $ERROR('#4.3: obj[0] = -1; obj.length = {valueOf: function() {return 1}, toString: function() {throw "error"}}; obj.shift() not throw Error. Actual: ' + (e)); + } +} + +//CHECK#5 +obj[0] = -1; +obj.length = { + toString: function() { + return 0 + } +}; +var shift = obj.shift(); +if (shift !== undefined) { + $ERROR('#5: obj[0] = -1; obj.length = {toString: function() {return 0}} obj.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#6 +obj[0] = -1; +obj.length = { + valueOf: function() { + return {} + }, + toString: function() { + return 0 + } +} +var shift = obj.shift(); +if (shift !== undefined) { + $ERROR('#6: obj[0] = -1; obj.length = {valueOf: function() {return {}}, toString: function() {return 0}} obj.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#7 +try { + obj[0] = -1; + obj.length = { + valueOf: function() { + throw "error" + }, + toString: function() { + return 0 + } + }; + var shift = obj.shift(); + $ERROR('#7.1: obj[0] = -1; obj.length = {valueOf: function() {throw "error"}, toString: function() {return 0}}; obj.shift() throw "error". Actual: ' + (shift)); +} +catch (e) { + if (e !== "error") { + $ERROR('#7.2: obj[0] = -1; obj.length = {valueOf: function() {throw "error"}, toString: function() {return 0}}; obj.shift() throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + obj[0] = -1; + obj.length = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + var shift = obj.shift(); + $ERROR('#8.1: obj[0] = -1; obj.length = {valueOf: function() {return {}}, toString: function() {return {}}} obj.shift() throw TypeError. Actual: ' + (shift)); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#8.2: obj[0] = -1; obj.length = {valueOf: function() {return {}}, toString: function() {return {}}} obj.shift() throw TypeError. Actual: ' + (e)); + } +} + +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..bb1bb6b37a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A3_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.shift +description: length is arbitrarily +---*/ + +var obj = {}; +obj.shift = Array.prototype.shift; +obj[0] = "x"; +obj[1] = "y"; +obj.length = -4294967294; + +//CHECK#1 +var shift = obj.shift(); +if (shift !== undefined) { + $ERROR('#1: var obj = {}; obj.shift = Array.prototype.shift; obj[0] = "x"; obj[1] = "y"; obj.length = -4294967294; obj.shift() === undefined. Actual: ' + (shift)); +} + +//CHECK#2 +if (obj.length !== 0) { + $ERROR('#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)); +} + +//CHECK#3 +if (obj[0] !== "x") { + $ERROR('#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])); +} + +//CHECK#4 +if (obj[1] !== "y") { + $ERROR('#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..ca61fa9381 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A4_T1.js @@ -0,0 +1,66 @@ +// 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; + +//CHECK#1 +var shift = x.shift(); +if (shift !== 0) { + $ERROR('#1: Array.prototype[1] = 1; x = [0]; x.length = 2; x.shift() === 0. Actual: ' + (shift)); +} + +//CHECK#2 +if (x[0] !== 1) { + $ERROR('#2: Array.prototype[1] = 1; x = [0]; x.length = 2; x.shift(); x[0] === 1. Actual: ' + (x[0])); +} + +//CHECK#3 +if (x[1] !== 1) { + $ERROR('#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 +}; + +//CHECK#4 +var shift = x.shift(); +if (shift !== 0) { + $ERROR('#4: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.shift = Array.prototype.shift; x = {0:0}; x.shift() === 0. Actual: ' + (shift)); +} + +//CHECK#5 +if (x[0] !== 1) { + $ERROR('#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])); +} + +//CHECK#6 +if (x[1] !== 1) { + $ERROR('#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])); +} + +//CHECK#7 +if (x.length !== 1) { + $ERROR('#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)); +} + +//CHECK#8 +delete x.length; +if (x.length !== 2) { + $ERROR('#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..33d37cef91 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A4_T2.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]], [[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; + +//CHECK#1 +var shift = x.shift(); +if (shift !== 0) { + $ERROR('#1: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.shift() === 0. Actual: ' + (shift)); +} + +//CHECK#2 +if (x[0] !== 1) { + $ERROR('#2: Array.prototype[1] = -1; x = [0,1]; x.length = 2; x.shift(); x[0] === 1. Actual: ' + (x[0])); +} + +//CHECK#3 +if (x[1] !== -1) { + $ERROR('#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 +}; + +//CHECK#4 +var shift = x.shift(); +if (shift !== 0) { + $ERROR('#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)); +} + +//CHECK#5 +if (x[0] !== 1) { + $ERROR('#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])); +} + +//CHECK#6 +if (x[1] !== -1) { + $ERROR('#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])); +} + +//CHECK#7 +if (x.length !== 1) { + $ERROR('#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)); +} + +//CHECK#8 +delete x.length; +if (x.length !== 2) { + $ERROR('#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/S15.4.4.9_A5.7.js b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A5.7.js new file mode 100644 index 0000000000..9e00d829d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/S15.4.4.9_A5.7.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: The shift property of Array can't be used as constructor +esid: sec-array.prototype.shift +description: > + If property does not implement the internal [[Construct]] method, + throw a TypeError exception +---*/ + +//CHECK#1 + +try { + new Array.prototype.shift(); + $ERROR('#1.1: new Array.prototype.shift() throw TypeError. Actual: ' + (new Array.prototype.shift())); +} catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: new Array.prototype.shift() throw TypeError. Actual: ' + (e)); + } +} + +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/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..75c91f0226 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (arr[3] !== undefined) { + $ERROR('#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..25d8c22a06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(3,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 0) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(3,3); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== undefined) { + $ERROR('#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..18472b29a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T3.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(4,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 0) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(4,3); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== undefined) { + $ERROR('#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..2d9e6956cb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T4.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(5,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 0) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(5,5); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== undefined) { + $ERROR('#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..3d257f7fb1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T5.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(3,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 2) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(3,5); arr.length === 2. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 3) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(3,5); arr[0] === 3. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 4) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(3,5); arr[1] === 4. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[3] !== undefined) { + $ERROR('#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..085deb057c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T6.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(2,4); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 2) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(2,4); arr.length === 2. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 2) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(2,4); arr[0] === 2. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 3) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(2,4); arr[1] === 3. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[3] !== undefined) { + $ERROR('#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..d8e7a953e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.1_T7.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(3,6); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 2) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(3,6); arr.length === 2. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 3) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(3,6); arr[0] === 3. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 4) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(3,6); arr[1] === 4. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[3] !== undefined) { + $ERROR('#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..56f8f5a691 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_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 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(-3,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 1) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(-3,3); arr.length === 1. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 2) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(-3,3); arr[0] === 2. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== undefined) { + $ERROR('#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..79aa77459c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_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 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(-1,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 1) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(-1,5); arr.length === 1. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 4) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(-1,5); arr[0] === 4. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== undefined) { + $ERROR('#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..de652117f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_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 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(-5,1); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 1) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(-5,1); arr.length === 1. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(-5,1); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== undefined) { + $ERROR('#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..2ee61bbf20 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.2_T4.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. + +/*--- +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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 5) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr.length === 5. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (arr[3] !== 3) { + $ERROR('#6: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[3] === 3. Actual: ' + (arr[3])); +} + +//CHECK#7 +if (arr[4] !== 4) { + $ERROR('#7: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[4] === 4. Actual: ' + (arr[4])); +} + +//CHECK#8 +if (arr[5] !== undefined) { + $ERROR('#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..4289f38773 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (arr[3] !== undefined) { + $ERROR('#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..c6ff223382 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(1,-4); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 0) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(1,-4); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== undefined) { + $ERROR('#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..485581f89d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T3.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,-5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 0) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,-5); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== undefined) { + $ERROR('#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..2c29f3342d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.3_T4.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(4,-9); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 0) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(4,-9); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== undefined) { + $ERROR('#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..667f7b7cfa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (arr[3] !== undefined) { + $ERROR('#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..e438a42ae2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T2.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(-3,-1); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 2) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(-3,-1); arr.length === 2. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 2) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(-3,-1); arr[0] === 2. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 3) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(-3,-1); arr[1] === 3. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== undefined) { + $ERROR('#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..3c5b2eb22a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 4) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr.length === 4. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (arr[3] !== 3) { + $ERROR('#6: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr[3] === 3. Actual: ' + (arr[3])); +} + +//CHECK#7 +if (arr[4] !== undefined) { + $ERROR('#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..7b207ec6df --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.4_T4.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(-6,-6); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 0) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(-6,-6); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== undefined) { + $ERROR('#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..8d6d1c08e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.5_T1.js @@ -0,0 +1,39 @@ +// 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(3, undefined); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 2) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(3, undefined); arr.length === 2. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 3) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(3, undefined); arr[0] === 3. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 4) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(3, undefined); arr[1] === 4. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== undefined) { + $ERROR('#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..f57d676c20 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A1.5_T2.js @@ -0,0 +1,39 @@ +// 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(-2); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 2) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(-2); arr.length === 2. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 3) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(-2); arr[0] === 3. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 4) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(-2); arr[1] === 4. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== undefined) { + $ERROR('#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..a767d4abab --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T1.js @@ -0,0 +1,39 @@ +// 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(2.5,4); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 2) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(2.5,4); arr.length === 2. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 2) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(2.5,4); arr[0] === 2. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 3) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(2.5,4); arr[1] === 3. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[3] !== undefined) { + $ERROR('#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..96a1977a32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T2.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: 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (arr[3] !== undefined) { + $ERROR('#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..12b0d48d66 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T3.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: 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(Number.POSITIVE_INFINITY,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 0) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(Number.POSITIVE_INFINITY,3); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== undefined) { + $ERROR('#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..010e52b33d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_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: 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (arr[3] !== undefined) { + $ERROR('#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..ae8db2071a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.1_T5.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: 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#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())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#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)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#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])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#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])); +} + +//CHECK#6 +if (arr[3] !== undefined) { + $ERROR('#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..3772cf14f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T1.js @@ -0,0 +1,39 @@ +// 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(2,4.5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 2) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(2,4.5); arr.length === 2. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 2) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(2,4.5); arr[0] === 2. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 3) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(2,4.5); arr[1] === 3. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[3] !== undefined) { + $ERROR('#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..3879203f1e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T2.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: 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,NaN); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 0) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,NaN); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== undefined) { + $ERROR('#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..82c5bf05ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T3.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: 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 5) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr.length === 5. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (arr[3] !== 3) { + $ERROR('#6: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[3] === 3. Actual: ' + (arr[3])); +} + +//CHECK#7 +if (arr[4] !== 4) { + $ERROR('#7: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[4] === 4. Actual: ' + (arr[4])); +} + +//CHECK#8 +if (arr[5] !== undefined) { + $ERROR('#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..2b03ce700d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T4.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: 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.NEGATIVE_INFINITY); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 0) { + $ERROR('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.NEGATIVE_INFINITY); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== undefined) { + $ERROR('#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..18433bb4e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T5.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: 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 + } +}); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#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())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#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)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#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])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#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])); +} + +//CHECK#6 +if (arr[3] !== undefined) { + $ERROR('#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..04a2f0bb92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T1.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 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#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())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#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)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#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])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#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])); +} + +//CHECK#6 +if (arr[3] !== undefined) { + $ERROR('#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..9a5e1a26e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_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 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#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())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#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)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#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])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#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])); +} + +//CHECK#6 +if (arr[3] !== undefined) { + $ERROR('#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..09526273fb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_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 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#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())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#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)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#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])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#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])); +} + +//CHECK#6 +if (arr[3] !== undefined) { + $ERROR('#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..b3e22bb5cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T4.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 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#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())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#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)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#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])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#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])); +} + +//CHECK#6 +if (arr[3] !== undefined) { + $ERROR('#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..b2da39221c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T5.js @@ -0,0 +1,53 @@ +// 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#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())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#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)); +} + +//CHECK#3 +if (arr[0] !== 2) { + $ERROR('#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])); +} + +//CHECK#4 +if (arr[1] !== 3) { + $ERROR('#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])); +} + +//CHECK#5 +if (arr[2] !== 4) { + $ERROR('#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])); +} + +//CHECK#6 +if (arr[3] !== undefined) { + $ERROR('#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..20e014814e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A2_T6.js @@ -0,0 +1,53 @@ +// 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#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())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#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)); +} + +//CHECK#3 +if (arr[0] !== 2) { + $ERROR('#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])); +} + +//CHECK#4 +if (arr[1] !== 3) { + $ERROR('#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])); +} + +//CHECK#5 +if (arr[2] !== 4) { + $ERROR('#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])); +} + +//CHECK#6 +if (arr[3] !== undefined) { + $ERROR('#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..9093187e84 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_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. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.slice +description: length = 4294967296 +---*/ + +var obj = {}; +obj.slice = Array.prototype.slice; +obj[0] = "x"; +obj[4294967295] = "y"; +obj.length = 4294967296; + +try { + var arr = obj.slice(0, 4294967296); + $ERROR('#1: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; var arr = obj.slice(0,4294967296); lead to throwing exception.'); +} catch (e) { + if (!(e instanceof RangeError)) { + $ERROR('#1.1: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; var arr = obj.slice(0,4294967296); lead to throwing exception. Exception is instance of RangeError. Actual: exception is ' + e); + } +} + +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..d0368020fb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A3_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. + +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.slice +description: length = 4294967297 +---*/ + +var obj = {}; +obj.slice = Array.prototype.slice; +obj[0] = "x"; +obj[4294967296] = "y"; +obj.length = 4294967297; + +try { + var arr = obj.slice(0, 4294967297); + $ERROR('#1: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = "x"; obj[4294967296] = "y"; obj.length = 4294967297; var arr = obj.slice(0,4294967297); lead to throwing exception.'); +} catch (e) { + if (!(e instanceof RangeError)) { + $ERROR('#1.1: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = "x"; obj[4294967296] = "y"; obj.length = 4294967297; var arr = obj.slice(0,4294967297); lead to throwing exception. Exception is instance of RangeError. Actual: exception is ' + e); + } +} + +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..e0b54d1a80 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A3_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: 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); + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#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)); +} + +//CHECK#3 +if (arr[0] !== undefined) { + $ERROR('#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..71d3c86b8c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A4_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. + +/*--- +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(); + +//CHECK#1 +if (arr[0] !== 0) { + $ERROR('#1: Array.prototype[1] = 1; x = [0]; x.length = 2; var arr = x.slice(); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#2 +if (arr[1] !== 1) { + $ERROR('#2: Array.prototype[1] = 1; x = [0]; x.length = 2; var arr = x.slice(); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#3 +if (arr.hasOwnProperty('1') !== true) { + $ERROR('#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/S15.4.4.10_A5.7.js b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A5.7.js new file mode 100644 index 0000000000..55eb58e2cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/S15.4.4.10_A5.7.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: The slice property of Array can't be used as constructor +esid: sec-array.prototype.slice +description: > + If property does not implement the internal [[Construct]] method, + throw a TypeError exception +---*/ + +//CHECK#1 + +try { + new Array.prototype.slice(); + $ERROR('#1.1: new Array.prototype.slice() throw TypeError. Actual: ' + (new Array.prototype.slice())); +} catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: new Array.prototype.slice() throw TypeError. Actual: ' + (e)); + } +} + +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..a964b21749 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/create-species-non-ctor.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: > + 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. +features: [Symbol.species] +---*/ + +var a = []; + +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; + +assert.throws(TypeError, function() { + a.slice(); +}); + +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..3b10b86821 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/length-exceeding-integer-limit-proxied-array.js @@ -0,0 +1,58 @@ +// 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] +---*/ + +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"], + "slice(9007199254740989)"); + +var result = Array.prototype.slice.call(proxy, 9007199254740989, 9007199254740990); +assert.compareArray(result, ["9007199254740989"], + "slice(9007199254740989, 9007199254740990)"); + +var result = Array.prototype.slice.call(proxy, 9007199254740989, 9007199254740996); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + "slice(9007199254740989, 9007199254740996)"); + +var result = Array.prototype.slice.call(proxy, -2); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + "slice(-2)"); + +var result = Array.prototype.slice.call(proxy, -2, -1); +assert.compareArray(result, ["9007199254740989"], + "slice(-2, -1)"); + +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..f3e7789d37 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/length-exceeding-integer-limit.js @@ -0,0 +1,49 @@ +// 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] +---*/ + +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"], + "slice(9007199254740989)"); + +var result = Array.prototype.slice.call(arrayLike, 9007199254740989, 9007199254740990); +assert.compareArray(result, ["9007199254740989"], + "slice(9007199254740989, 9007199254740990)"); + +var result = Array.prototype.slice.call(arrayLike, 9007199254740989, 9007199254740996); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + "slice(9007199254740989, 9007199254740996)"); + +var result = Array.prototype.slice.call(arrayLike, -2); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + "slice(-2)"); + +var result = Array.prototype.slice.call(arrayLike, -2, -1); +assert.compareArray(result, ["9007199254740989"], + "slice(-2, -1)"); + +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/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..e69de29bb2 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..9e9a4867fa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.1_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. + +/*--- +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(); + +//CHECK#1 +if (x.length !== 2) { + $ERROR('#1: var x = new Array(2); x.sort(); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#2 +if (x[0] !== undefined) { + $ERROR('#2: var x = new Array(2); x.sort(); x[0] === undefined. Actual: ' + (x[0])); +} + +//CHECK#3 +if (x[1] !== undefined) { + $ERROR('#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..de5e7c7d4a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.2_T1.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 undefined, use SortCompare operator +---*/ + +var x = new Array(2); +x[1] = 1; +x.sort(); + +//CHECK#1 +if (x.length !== 2) { + $ERROR('#1: var x = new Array(2); x[1] = 1; x.sort(); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#2 +if (x[0] !== 1) { + $ERROR('#2: var x = new Array(2); x[1] = 1; x.sort(); x[0] === 1. Actual: ' + (x[0])); +} + +//CHECK#3 +if (x[1] !== undefined) { + $ERROR('#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(); + +//CHECK#4 +if (x.length !== 2) { + $ERROR('#4: var x = new Array(2); x[0] = 1; x.sort(); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#5 +if (x[0] !== 1) { + $ERROR('#5: var x = new Array(2); x[0] = 1; x.sort(); x[0] === 1. Actual: ' + (x[0])); +} + +//CHECK#6 +if (x[1] !== undefined) { + $ERROR('#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..a8db98d5b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.2_T2.js @@ -0,0 +1,57 @@ +// 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); + +//CHECK#1 +if (x.length !== 2) { + $ERROR('#1: var x = new Array(2); x[1] = 1; x.sort(myComparefn); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#2 +if (x[0] !== 1) { + $ERROR('#2: var x = new Array(2); x[1] = 1; x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0])); +} + +//CHECK#3 +if (x[1] !== undefined) { + $ERROR('#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); + +//CHECK#4 +if (x.length !== 2) { + $ERROR('#4: var x = new Array(2); x[0] = 1; x.sort(myComparefn); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#5 +if (x[0] !== 1) { + $ERROR('#5: var x = new Array(2); x[0] = 1; x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0])); +} + +//CHECK#6 +if (x[1] !== undefined) { + $ERROR('#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..b9415a86a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.3_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. + +/*--- +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(); + +//CHECK#1 +if (x.length !== 2) { + $ERROR('#1: var x = new Array(undefined, undefined); x.sort(); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#2 +if (x[0] !== undefined) { + $ERROR('#2: var x = new Array(undefined, undefined); x.sort(); x[0] === undefined. Actual: ' + (x[0])); +} + +//CHECK#3 +if (x[1] !== undefined) { + $ERROR('#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..2ca6675331 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.4_T1.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 undefined, use SortCompare operator +---*/ + +var x = new Array(undefined, 1); +x.sort(); + +//CHECK#1 +if (x.length !== 2) { + $ERROR('#1: var x = new Array(undefined, 1); x.sort(); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#2 +if (x[0] !== 1) { + $ERROR('#2: var x = new Array(undefined, 1); x.sort(); x[0] === 1. Actual: ' + (x[0])); +} + +//CHECK#3 +if (x[1] !== undefined) { + $ERROR('#3: var x = new Array(undefined, 1); x.sort(); x[1] === undefined. Actual: ' + (x[1])); +} + +var x = new Array(1, undefined); +x.sort(); + +//CHECK#4 +if (x.length !== 2) { + $ERROR('#4: var x = new Array(1, undefined); x.sort(); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#5 +if (x[0] !== 1) { + $ERROR('#5: var x = new Array(1, undefined); x.sort(); x[0] === 1. Actual: ' + (x[0])); +} + +//CHECK#6 +if (x[1] !== undefined) { + $ERROR('#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..e529e959a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.4_T2.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: | + 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); + +//CHECK#1 +if (x.length !== 2) { + $ERROR('#1: var x = new Array(undefined, 1); x.sort(myComparefn); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#2 +if (x[0] !== 1) { + $ERROR('#2: var x = new Array(undefined, 1); x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0])); +} + +//CHECK#3 +if (x[1] !== undefined) { + $ERROR('#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); + +//CHECK#4 +if (x.length !== 2) { + $ERROR('#4: var x = new Array(1, undefined); x.sort(myComparefn); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#5 +if (x[0] !== 1) { + $ERROR('#5: var x = new Array(1, undefined); x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0])); +} + +//CHECK#6 +if (x[1] !== undefined) { + $ERROR('#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..db22baac35 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A1.5_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: 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(); + +//CHECK#1 +if (x.length !== 2) { + $ERROR('#1: var x = new Array(1,0); x.sort(); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#2 +if (x[0] !== 0) { + $ERROR('#2: var x = new Array(1,0); x.sort(); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#3 +if (x[1] !== 1) { + $ERROR('#3: var x = new Array(1,0); x.sort(); x[1] === 1. Actual: ' + (x[1])); +} + +var x = new Array(1, 0); +x.sort(undefined); + +//CHECK#4 +if (x.length !== 2) { + $ERROR('#4: var x = new Array(1,0); x.sort(undefined); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#5 +if (x[0] !== 0) { + $ERROR('#5: var x = new Array(1,0); x.sort(undefined); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#6 +if (x[1] !== 1) { + $ERROR('#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..9cb833c3c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_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 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"]; + +//CHECK#1 +alphabetR.sort(); +var result = true; +for (var i = 0; i < 26; i++) { + if (alphabetR[i] !== alphabet[i]) result = false; +} + +if (result !== true) { + $ERROR('#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..a93ba9337b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T2.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 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 = ["А", "Б", "В", "Г", "Д", "Е", "Ж", "З", "И", "Й", "К", "Л", "М", "Н", "О", "П", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", "ь", "э", "ю", "я", "ё"]; + +//CHECK#1 +alphabetR.sort(); +var result = true; +for (var i = 0; i < 26; i++) { + if (alphabetR[i] !== alphabet[i]) result = false; +} + +if (result !== true) { + $ERROR('#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..67ed2ba4ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.1_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: | + 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]; + +//CHECK#1 +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) { + $ERROR('#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..ffd509d672 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.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: 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; +} + +//CHECK#1 +alphabet.sort(myComparefn); +var result = true; +for (var i = 0; i < 26; i++) { + if (alphabetR[i] !== alphabet[i]) result = false; +} + +if (result !== true) { + $ERROR('#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..0adb07d8b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A2.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: 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; +} + +//CHECK#1 +alphabet.sort(myComparefn); +var result = true; +for (var i = 0; i < 26; i++) { + if (alphabetR[i] !== alphabet[i]) result = false; +} + +if (result !== true) { + $ERROR('#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..cad096663b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_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: 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; +} + +//CHECK#1 +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) { + $ERROR('#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..ba7d22a940 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A3_T1.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. + +/*--- +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(); + +//CHECK#0 +alphabetR.getClass = Object.prototype.toString; +if (alphabetR.getClass() !== "[object " + "Object" + "]") { + $ERROR('#0: alphabetR.sort() is Object object, not Array object'); +} + +//CHECK#1 +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) { + $ERROR('#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..c10a2df44d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A3_T2.js @@ -0,0 +1,64 @@ +// 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); + +//CHECK#0 +alphabetR.getClass = Object.prototype.toString; +if (alphabetR.getClass() !== "[object " + "Object" + "]") { + $ERROR('#0: alphabetR.sort() is Object object, not Array object'); +} + +//CHECK#1 +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) { + $ERROR('#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..09d92fcf7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A4_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: 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; + +//CHECK#1 +if (obj.sort() !== obj) { + $ERROR('#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())); +} + +//CHECK#2 +if (obj.length !== -4294967294) { + $ERROR('#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)); +} + +//CHECK#3 +if (obj[0] !== "z") { + $ERROR('#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])); +} + +//CHECK#4 +if (obj[1] !== "y") { + $ERROR('#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])); +} + +//CHECK#5 +if (obj[2] !== "x") { + $ERROR('#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..5b108e73f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A5_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: Array.sort should not eat exceptions +esid: sec-array.prototype.sort +description: comparefn function throw "error" +---*/ + +//CHECK#1 +var myComparefn = function(x, y) { + throw "error"; +} +var x = [1, 0]; +try { + x.sort(myComparefn) + $ERROR('#1.1: Array.sort should not eat exceptions'); +} catch (e) { + if (e !== "error") { + $ERROR('#1.2: Array.sort should not eat exceptions'); + } +} + +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..690e077515 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A6_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: "[[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(); + +//CHECK#1 +if (x[0] !== 0) { + $ERROR('#1: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#2 +if (x[1] !== 1) { + $ERROR('#2: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x[1] === 1. Actual: ' + (x[1])); +} + +x.length = 0; + +//CHECK#3 +if (x[0] !== undefined) { + $ERROR('#3: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x.length = 0; x[0] === undefined. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== -1) { + $ERROR('#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(); + +//CHECK#5 +if (x[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#6 +if (x[1] !== 1) { + $ERROR('#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]; + +//CHECK#7 +if (x[0] !== undefined) { + $ERROR('#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])); +} + +//CHECK#8 +if (x[1] !== -1) { + $ERROR('#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_A7.7.js b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A7.7.js new file mode 100644 index 0000000000..dd97a40c64 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/S15.4.4.11_A7.7.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: The sort property of Array can't be used as constructor +esid: sec-array.prototype.sort +description: > + If property does not implement the internal [[Construct]] method, + throw a TypeError exception +---*/ + +//CHECK#1 + +try { + new Array.prototype.sort(); + $ERROR('#1.1: new Array.prototype.sort() throw TypeError. Actual: ' + (new Array.prototype.sort())); +} catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: new Array.prototype.sort() throw TypeError. Actual: ' + (e)); + } +} + +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..505b41483b --- /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) { + $ERROR('#1: Sort leaks global'); + } + if (this !== undefined) { + $ERROR('#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..d665564476 --- /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 + $ERROR('#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..376894f095 --- /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) { + $ERROR('#1: array.length !== 3. Actual: ' + (array.length)) +} + +//CHECK#2 +if (array.hasOwnProperty('0') !== true) { + $ERROR("#2: array.hasOwnProperty('0'). Actual: " + array.hasOwnProperty('0')); +} + +//CHECK#3 +if (array.hasOwnProperty('1') !== false) { + $ERROR("#3: array.hasOwnProperty('1'). Actual: " + array.hasOwnProperty('1')); +} + +//CHECK#4 +if (array.hasOwnProperty('2') !== true) { + $ERROR("#4: array.hasOwnProperty('2'). Actual: " + array.hasOwnProperty('2')); +} + +array.sort(); + +//CHECK#5 +if (array.length !== 3) { + $ERROR('#5: array.length !== 3. Actual: ' + (array.length)) +} + +//CHECK#6 +if (array.hasOwnProperty('0') !== true) { + $ERROR("#6: array.hasOwnProperty('0'). Actual: " + array.hasOwnProperty('0')); +} + +//CHECK#7 +if (array.hasOwnProperty('1') !== true) { + $ERROR("#7: array.hasOwnProperty('1'). Actual: " + array.hasOwnProperty('1')); +} + +//CHECK#8 +if (array.hasOwnProperty('2') !== false) { + $ERROR("#8: array.hasOwnProperty('2'). Actual: " + array.hasOwnProperty('2')); +} + +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/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..85d880aa3d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T1.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 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(0,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(0,3); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(0,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(0,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(0,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (x.length !== 1) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(0,3); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#7 +if (x[0] !== 3) { + $ERROR('#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..9d304e8af0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T2.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (x.length !== 3) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); x.length === 3. Actual: ' + (x.length)); +} + +//CHECK#7 +if (x[0] !== 4) { + $ERROR('#7: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); x[0] === 4. Actual: ' + (x[0])); +} + +//CHECK#8 +if (x[1] !== 5) { + $ERROR('#8: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); x[1] === 5. Actual: ' + (x[1])); +} + +//CHECK#9 +if (x[2] !== 3) { + $ERROR('#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..887c949452 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(0,4); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 4) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(0,4); arr.length === 4. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(0,4); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(0,4); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(0,4); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (arr[3] !== 3) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(0,4); arr[3] === 3. Actual: ' + (arr[3])); +} + +//CHECK#7 +if (x.length !== 0) { + $ERROR('#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..0f15d40b97 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T4.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 1) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr[0] === 1. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 2) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr[1] === 2. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 3) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr[2] === 3. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (x.length !== 3) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); x.length === 3. Actual: ' + (x.length)); +} + +//CHECK#7 +if (x[0] !== 0) { + $ERROR('#7: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#8 +if (x[1] !== 4) { + $ERROR('#8: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); x[1] === 4. Actual: ' + (x[1])); +} + +//CHECK#9 +if (x[2] !== 5) { + $ERROR('#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..bd2b9fb617 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T5.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 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(0,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 4) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(0,5); arr.length === 4. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(0,5); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(0,5); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(0,5); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (arr[3] !== 3) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(0,5); arr[3] === 3. Actual: ' + (arr[3])); +} + +//CHECK#7 +if (x.length !== 0) { + $ERROR('#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..2b988392bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.1_T6.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 1) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr[0] === 1. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 2) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr[1] === 2. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 3) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr[2] === 3. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (x.length !== 3) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); x.length === 3. Actual: ' + (x.length)); +} + +//CHECK#7 +if (x[0] !== 0) { + $ERROR('#7: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#8 +if (x[1] !== 4) { + $ERROR('#8: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); x[1] === 4. Actual: ' + (x[1])); +} + +//CHECK#9 +if (x[2] !== 5) { + $ERROR('#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..5611c79d5e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T1.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: | + 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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [0,1]; var arr = x.splice(-2,-1); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#1: var x = [0,1]; var arr = x.splice(-2,-1); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (x.length !== 2) { + $ERROR('#2: var x = [0,1]; var arr = x.splice(-2,-1); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#3 +if (x[0] !== 0) { + $ERROR('#3: var x = [0,1]; var arr = x.splice(-2,-1); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== 1) { + $ERROR('#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..17cb48fbdc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T2.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: | + 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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [0,1]; var arr = x.splice(-1,-1); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#1: var x = [0,1]; var arr = x.splice(-1,-1); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (x.length !== 2) { + $ERROR('#2: var x = [0,1]; var arr = x.splice(-1,-1); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#3 +if (x[0] !== 0) { + $ERROR('#3: var x = [0,1]; var arr = x.splice(-1,-1); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== 1) { + $ERROR('#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..f676d1e229 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_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: | + 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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [0,1]; var arr = x.splice(-2,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#1: var x = [0,1]; var arr = x.splice(-2,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (x.length !== 4) { + $ERROR('#2: var x = [0,1]; var arr = x.splice(-2,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} + +//CHECK#3 +if (x[0] !== 2) { + $ERROR('#3: var x = [0,1]; var arr = x.splice(-2,-1,2,3); x[0] === 2. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== 3) { + $ERROR('#4: var x = [0,1]; var arr = x.splice(-2,-1,2,3); x[1] === 3. Actual: ' + (x[1])); +} + +//CHECK#5 +if (x[2] !== 0) { + $ERROR('#5: var x = [0,1]; var arr = x.splice(-2,-1,2,3); x[2] === 0. Actual: ' + (x[2])); +} + +//CHECK#6 +if (x[3] !== 1) { + $ERROR('#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..a74c8dd405 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T4.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 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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [0,1]; var arr = x.splice(-1,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#1: var x = [0,1]; var arr = x.splice(-1,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (x.length !== 4) { + $ERROR('#2: var x = [0,1]; var arr = x.splice(-1,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} + +//CHECK#3 +if (x[0] !== 0) { + $ERROR('#3: var x = [0,1]; var arr = x.splice(-1,-1,2,3); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== 2) { + $ERROR('#4: var x = [0,1]; var arr = x.splice(-1,-1,2,3); x[1] === 2. Actual: ' + (x[1])); +} + +//CHECK#5 +if (x[2] !== 3) { + $ERROR('#5: var x = [0,1]; var arr = x.splice(-1,-1,2,3); x[2] === 3. Actual: ' + (x[2])); +} + +//CHECK#6 +if (x[3] !== 1) { + $ERROR('#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..0d39887d40 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T5.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 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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [0,1]; var arr = x.splice(-3,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#1: var x = [0,1]; var arr = x.splice(-3,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (x.length !== 4) { + $ERROR('#2: var x = [0,1]; var arr = x.splice(-3,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} + +//CHECK#3 +if (x[0] !== 2) { + $ERROR('#3: var x = [0,1]; var arr = x.splice(-3,-1,2,3); x[0] === 2. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== 3) { + $ERROR('#4: var x = [0,1]; var arr = x.splice(-3,-1,2,3); x[1] === 3. Actual: ' + (x[1])); +} + +//CHECK#5 +if (x[2] !== 0) { + $ERROR('#5: var x = [0,1]; var arr = x.splice(-3,-1,2,3); x[2] === 0. Actual: ' + (x[2])); +} + +//CHECK#6 +if (x[3] !== 1) { + $ERROR('#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..4c7622cc5b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T1.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: | + 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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [0,1]; var arr = x.splice(0,-1); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#1: var x = [0,1]; var arr = x.splice(0,-1); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (x.length !== 2) { + $ERROR('#2: var x = [0,1]; var arr = x.splice(0,-1); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#3 +if (x[0] !== 0) { + $ERROR('#3: var x = [0,1]; var arr = x.splice(0,-1); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== 1) { + $ERROR('#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..13e1ce6e2d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T2.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: | + 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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [0,1]; var arr = x.splice(2,-1); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#1: var x = [0,1]; var arr = x.splice(2,-1); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (x.length !== 2) { + $ERROR('#2: var x = [0,1]; var arr = x.splice(2,-1); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#3 +if (x[0] !== 0) { + $ERROR('#3: var x = [0,1]; var arr = x.splice(2,-1); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== 1) { + $ERROR('#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..6f8458ec65 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_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: | + 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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [0,1]; var arr = x.splice(0,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#1: var x = [0,1]; var arr = x.splice(0,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (x.length !== 4) { + $ERROR('#2: var x = [0,1]; var arr = x.splice(0,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} + +//CHECK#3 +if (x[0] !== 2) { + $ERROR('#3: var x = [0,1]; var arr = x.splice(0,-1,2,3); x[0] === 2. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== 3) { + $ERROR('#4: var x = [0,1]; var arr = x.splice(0,-1,2,3); x[1] === 3. Actual: ' + (x[1])); +} + +//CHECK#5 +if (x[2] !== 0) { + $ERROR('#5: var x = [0,1]; var arr = x.splice(0,-1,2,3); x[2] === 0. Actual: ' + (x[2])); +} + +//CHECK#6 +if (x[3] !== 1) { + $ERROR('#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..3144336ebc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T4.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 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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [0,1]; var arr = x.splice(2,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#1: var x = [0,1]; var arr = x.splice(2,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (x.length !== 4) { + $ERROR('#2: var x = [0,1]; var arr = x.splice(2,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} + +//CHECK#3 +if (x[0] !== 0) { + $ERROR('#3: var x = [0,1]; var arr = x.splice(2,-1,2,3); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== 1) { + $ERROR('#4: var x = [0,1]; var arr = x.splice(2,-1,2,3); x[1] === 1. Actual: ' + (x[1])); +} + +//CHECK#5 +if (x[2] !== 2) { + $ERROR('#5: var x = [0,1]; var arr = x.splice(2,-1,2,3); x[2] === 2. Actual: ' + (x[2])); +} + +//CHECK#6 +if (x[3] !== 3) { + $ERROR('#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..e98ed5701a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T5.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 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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [0,1]; var arr = x.splice(3,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#1: var x = [0,1]; var arr = x.splice(3,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (x.length !== 4) { + $ERROR('#2: var x = [0,1]; var arr = x.splice(3,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} + +//CHECK#3 +if (x[0] !== 0) { + $ERROR('#3: var x = [0,1]; var arr = x.splice(3,-1,2,3); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== 1) { + $ERROR('#4: var x = [0,1]; var arr = x.splice(3,-1,2,3); x[1] === 1. Actual: ' + (x[1])); +} + +//CHECK#5 +if (x[2] !== 2) { + $ERROR('#5: var x = [0,1]; var arr = x.splice(3,-1,2,3); x[2] === 2. Actual: ' + (x[2])); +} + +//CHECK#6 +if (x[3] !== 3) { + $ERROR('#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..4fb9271c7b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T1.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 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (x.length !== 1) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(-4,3); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#7 +if (x[0] !== 3) { + $ERROR('#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..8fe026e05c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T2.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (x.length !== 3) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); x.length === 3. Actual: ' + (x.length)); +} + +//CHECK#7 +if (x[0] !== 4) { + $ERROR('#7: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); x[0] === 4. Actual: ' + (x[0])); +} + +//CHECK#8 +if (x[1] !== 5) { + $ERROR('#8: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); x[1] === 5. Actual: ' + (x[1])); +} + +//CHECK#9 +if (x[2] !== 3) { + $ERROR('#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..d95ce37bc8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 4) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr.length === 4. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (arr[3] !== 3) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr[3] === 3. Actual: ' + (arr[3])); +} + +//CHECK#7 +if (x.length !== 0) { + $ERROR('#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..422145a5a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T4.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 1) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr[0] === 1. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 2) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr[1] === 2. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 3) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr[2] === 3. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (x.length !== 3) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); x.length === 3. Actual: ' + (x.length)); +} + +//CHECK#7 +if (x[0] !== 0) { + $ERROR('#7: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#8 +if (x[1] !== 4) { + $ERROR('#8: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); x[1] === 4. Actual: ' + (x[1])); +} + +//CHECK#9 +if (x[2] !== 5) { + $ERROR('#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..0b53c02656 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T5.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 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 4) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr.length === 4. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (arr[3] !== 3) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr[3] === 3. Actual: ' + (arr[3])); +} + +//CHECK#7 +if (x.length !== 0) { + $ERROR('#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..b35df35647 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.4_T6.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: | + 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 1) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr[0] === 1. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 2) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr[1] === 2. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 3) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr[2] === 3. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (x.length !== 3) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); x.length === 3. Actual: ' + (x.length)); +} + +//CHECK#7 +if (x[0] !== 0) { + $ERROR('#7: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#8 +if (x[1] !== 4) { + $ERROR('#8: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); x[1] === 4. Actual: ' + (x[1])); +} + +//CHECK#9 +if (x[2] !== 5) { + $ERROR('#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..2d191f0e7f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.5_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: 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 0) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (x.length !== 4) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); x.length === 4. Actual: ' + (x.length)); +} + +//CHECK#4 +if (x[0] !== 0) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#5 +if (x[1] !== 1) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); x[1] === 1. Actual: ' + (x[1])); +} + +//CHECK#6 +if (x[2] !== 2) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); x[2] === 2. Actual: ' + (x[2])); +} + +//CHECK#7 +if (x[3] !== 3) { + $ERROR('#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..a496501234 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A1.5_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: Splice with undefined arguments +esid: sec-array.prototype.splice +description: end === undefined +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(1, undefined); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(1,undefined); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 0) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(1,undefined); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (x.length !== 4) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(1,undefined); x.length === 4. Actual: ' + (x.length)); +} + +//CHECK#4 +if (x[0] !== 0) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(1,undefined); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#5 +if (x[1] !== 1) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(1,undefined); x[1] === 1. Actual: ' + (x[1])); +} + +//CHECK#6 +if (x[2] !== 2) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(1,undefined); x[2] === 2. Actual: ' + (x[2])); +} + +//CHECK#7 +if (x[3] !== 3) { + $ERROR('#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..39bffabc54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_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: 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 1) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr[0] === 1. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 2) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr[1] === 2. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 3) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr[2] === 3. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (x.length !== 1) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(1.5,3); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#7 +if (x[0] !== 0) { + $ERROR('#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..4eef8e91b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_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: 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (x.length !== 1) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(NaN,3); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#7 +if (x[0] !== 3) { + $ERROR('#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..56df0b11d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.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: 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(Number.POSITIVE_INFINITY,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 0) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(Number.POSITIVE_INFINITY,3); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (x[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3]; var x = x.splice(Number.POSITIVE_INFINITY,3); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3]; var x = x.splice(Number.POSITIVE_INFINITY,3); x[1] === 1. Actual: ' + (x[1])); +} + +//CHECK#5 +if (x[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3]; var x = x.splice(Number.POSITIVE_INFINITY,3); x[2] === 2. Actual: ' + (x[2])); +} + +//CHECK#6 +if (x[3] !== 3) { + $ERROR('#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..b9009cb181 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_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: 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (x.length !== 1) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#7 +if (x[0] !== 3) { + $ERROR('#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..a417982b43 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.1_T5.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. + +/*--- +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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#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())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#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)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#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])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#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])); +} + +//CHECK#6 +if (x.length !== 1) { + $ERROR('#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)); +} + +//CHECK#7 +if (x[0] !== 3) { + $ERROR('#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..247d791e49 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_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: 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr.length === 3. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 1) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr[0] === 1. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 2) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr[1] === 2. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 3) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr[2] === 3. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (x.length !== 1) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(1,3.5); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#7 +if (x[0] !== 0) { + $ERROR('#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..87cc7a55d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T2.js @@ -0,0 +1,39 @@ +// 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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [0,1]; var arr = x.splice(0,NaN); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#1: var x = [0,1]; var arr = x.splice(0,NaN); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (x.length !== 2) { + $ERROR('#2: var x = [0,1]; var arr = x.splice(0,NaN); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#3 +if (x[0] !== 0) { + $ERROR('#3: var x = [0,1]; var arr = x.splice(0,NaN); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== 1) { + $ERROR('#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..c7ca396c9f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_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: 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#1: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#2 +if (arr.length !== 4) { + $ERROR('#2: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr.length === 4. Actual: ' + (arr.length)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#3: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr[0] === 0. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#4: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr[1] === 1. Actual: ' + (arr[1])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#5: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr[2] === 2. Actual: ' + (arr[2])); +} + +//CHECK#6 +if (arr[3] !== 3) { + $ERROR('#6: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr[3] === 3. Actual: ' + (arr[3])); +} + +//CHECK#7 +if (x.length !== 0) { + $ERROR('#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..9b7ce85fd8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T4.js @@ -0,0 +1,39 @@ +// 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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#0: var x = [0,1]; var arr = x.splice(0,Number.NEGATIVE_INFINITY); arr is Array object. Actual: ' + (arr.getClass())); +} + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#1: var x = [0,1]; var arr = x.splice(0,Number.NEGATIVE_INFINITY); arr.length === 0. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (x.length !== 2) { + $ERROR('#2: var x = [0,1]; var arr = x.splice(0,Number.NEGATIVE_INFINITY); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#3 +if (x[0] !== 0) { + $ERROR('#3: var x = [0,1]; var arr = x.splice(0,Number.NEGATIVE_INFINITY); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#4 +if (x[1] !== 1) { + $ERROR('#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..67a1e82f32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T5.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. + +/*--- +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 + } +}); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#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())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#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)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#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])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#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])); +} + +//CHECK#6 +if (x.length !== 1) { + $ERROR('#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)); +} + +//CHECK#7 +if (x[0] !== 3) { + $ERROR('#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..88e085681a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T1.js @@ -0,0 +1,75 @@ +// 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#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())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#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)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#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])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#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])); +} + +//CHECK#6 +if (obj.length !== 3) { + $ERROR('#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)); +} + +//CHECK#7 +if (obj[0] !== 4) { + $ERROR('#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])); +} + +//CHECK#8 +if (obj[1] !== 5) { + $ERROR('#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])); +} + +//CHECK#9 +if (obj[2] !== 3) { + $ERROR('#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])); +} + +//CHECK#10 +if (obj[3] !== undefined) { + $ERROR('#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..29f1f7c66c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_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 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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#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())); +} + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#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)); +} + +//CHECK#2 +if (obj.length !== 4) { + $ERROR('#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)); +} + +//CHECK#3 +if (obj[0] !== 2) { + $ERROR('#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])); +} + +//CHECK#4 +if (obj[1] !== 3) { + $ERROR('#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])); +} + +//CHECK#5 +if (obj[2] !== 0) { + $ERROR('#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])); +} + +//CHECK#6 +if (obj[3] !== 1) { + $ERROR('#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])); +} + +//CHECK#7 +if (obj[4] !== undefined) { + $ERROR('#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..5919a39591 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T3.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 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); + +//CHECK#0 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#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())); +} + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#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)); +} + +//CHECK#2 +if (obj.length !== 4) { + $ERROR('#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)); +} + +//CHECK#3 +if (obj[0] !== 2) { + $ERROR('#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])); +} + +//CHECK#4 +if (obj[1] !== 3) { + $ERROR('#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])); +} + +//CHECK#5 +if (obj[2] !== 0) { + $ERROR('#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])); +} + +//CHECK#6 +if (obj[3] !== 1) { + $ERROR('#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])); +} + +//CHECK#7 +if (obj[4] !== undefined) { + $ERROR('#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..ee8eb3632a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A2_T4.js @@ -0,0 +1,75 @@ +// 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); + +//CHECK#1 +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + $ERROR('#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())); +} + +//CHECK#2 +if (arr.length !== 3) { + $ERROR('#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)); +} + +//CHECK#3 +if (arr[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#4 +if (arr[1] !== 1) { + $ERROR('#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])); +} + +//CHECK#5 +if (arr[2] !== 2) { + $ERROR('#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])); +} + +//CHECK#6 +if (obj.length !== 3) { + $ERROR('#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)); +} + +//CHECK#7 +if (obj[0] !== 4) { + $ERROR('#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])); +} + +//CHECK#8 +if (obj[1] !== 5) { + $ERROR('#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])); +} + +//CHECK#9 +if (obj[2] !== 3) { + $ERROR('#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])); +} + +//CHECK#10 +if (obj[3] !== undefined) { + $ERROR('#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..eb9baaf6ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A3_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: 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); + +//CHECK#1 +if (arr.length !== 1) { + $ERROR('#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)); +} + +//CHECK#2 +if (obj.length !== 4294967295) { + $ERROR('#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)); +} + +//CHECK#3 +if (obj[0] !== "x") { + $ERROR('#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])); +} + +//CHECK#4 +if (obj[4294967295] !== undefined) { + $ERROR('#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])); +} + +//CHECK#5 +if (arr[0] !== "y") { + $ERROR('#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..76c52cad96 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A3_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: 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); + +//CHECK#1 +if (arr.length !== 0) { + $ERROR('#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)); +} + +//CHECK#2 +if (arr[0] !== undefined) { + $ERROR('#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])); +} + +//CHECK#3 +if (obj.length !== 0) { + $ERROR('#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)); +} + +//CHECK#4 +if (obj[4294967294] !== "x") { + $ERROR('#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..38de826cdd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T1.js @@ -0,0 +1,86 @@ +// 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); + +//CHECK#1 +if (arr.length !== 1) { + $ERROR('#1: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); arr.length === 1. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (arr[0] !== 1) { + $ERROR('#2: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); arr[0] === 1. Actual: ' + (arr[0])); +} + +//CHECK#3 +if (arr[1] !== -1) { + $ERROR('#3: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); arr[1] === -1. Actual: ' + (arr[1])); +} + +//CHECK#4 +if (x.length !== 1) { + $ERROR('#4: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); x.length === 1. Actual: ' + (x.length)); +} + +//CHECK#5 +if (x[0] !== 0) { + $ERROR('#5: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#6 +if (x[1] !== -1) { + $ERROR('#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); + +//CHECK#7 +if (arr.length !== 1) { + $ERROR('#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)); +} + +//CHECK#8 +if (arr[0] !== 1) { + $ERROR('#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])); +} + +//CHECK#9 +if (arr[1] !== -1) { + $ERROR('#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])); +} + +//CHECK#10 +if (x.length !== 1) { + $ERROR('#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)); +} + +//CHECK#11 +if (x[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#12 +if (x[1] !== -1) { + $ERROR('#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..c96f7c69e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T2.js @@ -0,0 +1,86 @@ +// 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); + +//CHECK#1 +if (arr.length !== 1) { + $ERROR('#1: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); arr.length === 1. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (arr[0] !== 1) { + $ERROR('#2: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); arr[0] === 1. Actual: ' + (arr[0])); +} + +//CHECK#3 +if (arr[1] !== -1) { + $ERROR('#3: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); arr[1] === -1. Actual: ' + (arr[1])); +} + +//CHECK#4 +if (x.length !== 2) { + $ERROR('#4: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); x.length === 2. Actual: ' + (x.length)); +} + +//CHECK#5 +if (x[0] !== 0) { + $ERROR('#5: Array.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#6 +if (x[1] !== 2) { + $ERROR('#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); + +//CHECK#7 +if (arr.length !== 1) { + $ERROR('#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)); +} + +//CHECK#8 +if (arr[0] !== 1) { + $ERROR('#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])); +} + +//CHECK#9 +if (arr[1] !== -1) { + $ERROR('#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])); +} + +//CHECK#10 +if (x.length !== 2) { + $ERROR('#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)); +} + +//CHECK#11 +if (x[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#12 +if (x[1] !== 2) { + $ERROR('#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..683cde74f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A4_T3.js @@ -0,0 +1,77 @@ +// 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); + +//CHECK#1 +if (arr.length !== 1) { + $ERROR('#1: Array.prototype[0] = -1; x = []; x.length = 1; var arr = x.splice(0,1); arr.length === 1. Actual: ' + (arr.length)); +} + +//CHECK#2 +if (arr[0] !== -1) { + $ERROR('#2: Array.prototype[0] = -1; x = []; x.length = 1; var arr = x.splice(0,1); arr[0] === -1. Actual: ' + (arr[0])); +} + +delete arr[0]; + +//CHECK#3 +if (arr[0] !== -1) { + $ERROR('#3: Array.prototype[0] = -1; x = []; x.length = 1; var arr = x.splice(0,1); delete arr[0]; arr[0] === -1. Actual: ' + (arr[0])); +} + +//CHECK#4 +if (x.length !== 0) { + $ERROR('#4: Array.prototype[0] = -1; x = []; x.length = 1; var arr = x.splice(0,1); x.length === 0. Actual: ' + (x.length)); +} + +//CHECK#5 +if (x[0] !== -1) { + $ERROR('#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); + +//CHECK#6 +if (arr.length !== 1) { + $ERROR('#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)); +} + +//CHECK#7 +if (arr[0] !== -1) { + $ERROR('#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]; + +//CHECK#8 +if (arr[0] !== -1) { + $ERROR('#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])); +} + +//CHECK#9 +if (x.length !== 0) { + $ERROR('#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)); +} + +//CHECK#10 +if (x[0] !== -1) { + $ERROR('#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_A5.7.js b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A5.7.js new file mode 100644 index 0000000000..83ea0df0cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/S15.4.4.12_A5.7.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: The splice property of Array can't be used as constructor +esid: sec-array.prototype.splice +description: > + If property does not implement the internal [[Construct]] method, + throw a TypeError exception +---*/ + +//CHECK#1 + +try { + new Array.prototype.splice(); + $ERROR('#1.1: new Array.prototype.splice() throw TypeError. Actual: ' + (new Array.prototype.splice())); +} catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: new Array.prototype.splice() throw TypeError. Actual: ' + (e)); + } +} + +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..8fa426441c --- /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) { + $ERROR("Expected a.length === 2, actually " + a.length); +} + +if (a[0] !== 0) { + $ERROR("Expected a[0] === 0, actually " + a[0]); +} + +if (a[1] !== 4) { + $ERROR("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..ca26838c38 --- /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); + $ERROR("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..b9ee105e55 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/clamps-length-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.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). + ... +---*/ + +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..3cfbff052d --- /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] +---*/ + +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); +}); + +assert.sameValue(targetLength, 2 ** 53 - 1, + "length and deleteCount were correctly clamped to 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", +]); + +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..d922992276 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/create-species-non-ctor.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: > + 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. +features: [Symbol.species] +---*/ + +var a = []; + +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; + +assert.throws(TypeError, function() { + a.splice(); +}); + +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..a2ed1f4723 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/length-and-deleteCount-exceeding-integer-limit.js @@ -0,0 +1,56 @@ +// 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] +---*/ + +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"], + "arrayLike['9007199254740989'] and arrayLike['9007199254740990'] are removed"); + +assert.sameValue(arrayLike.length, 2 ** 53 - 3, + "New length is 2**53 - 3"); + +assert.sameValue(arrayLike["9007199254740988"], "9007199254740988", + "arrayLike['9007199254740988'] is unchanged"); + +assert.sameValue("9007199254740989" in arrayLike, false, + "arrayLike['9007199254740989'] is removed"); + +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/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..142baa26b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/length-exceeding-integer-limit-shrink-array.js @@ -0,0 +1,66 @@ +// 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] +---*/ + +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"], + "arrayLike['9007199254740987'] is removed"); + +assert.sameValue(arrayLike.length, 2 ** 53 - 2, + "New length is 2**53 - 2"); + +assert.sameValue(arrayLike["9007199254740986"], "9007199254740986", + "arrayLike['9007199254740986'] is unchanged"); + +assert.sameValue(arrayLike["9007199254740987"], "9007199254740988", + "arrayLike['9007199254740988'] is moved to arrayLike['9007199254740987']"); + +assert.sameValue("9007199254740988" in arrayLike, false, + "arrayLike['9007199254740990'] is removed"); + +assert.sameValue(arrayLike["9007199254740989"], "9007199254740990", + "arrayLike['9007199254740990'] is moved to arrayLike['9007199254740989']"); + +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/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..da344bd65d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/length-near-integer-limit-grow-array.js @@ -0,0 +1,64 @@ +// 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] +---*/ + +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, [], "No elements are removed"); + +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "New length is 2**53 - 1"); + +assert.sameValue(arrayLike["9007199254740985"], "9007199254740985", + "arrayLike['9007199254740985'] is unchanged"); + +assert.sameValue(arrayLike["9007199254740986"], "new-value", + "arrayLike['9007199254740986'] contains the inserted value"); + +assert.sameValue(arrayLike["9007199254740987"], "9007199254740986", + "arrayLike['9007199254740986'] is moved to arrayLike['9007199254740987']"); + +assert.sameValue(arrayLike["9007199254740988"], "9007199254740987", + "arrayLike['9007199254740987'] is moved to arrayLike['9007199254740988']"); + +assert.sameValue("9007199254740989" in arrayLike, false, + "arrayLike['9007199254740989'] is removed"); + +assert.sameValue(arrayLike["9007199254740990"], "9007199254740989", + "arrayLike['9007199254740989'] is moved to arrayLike['9007199254740990']"); + +assert.sameValue(arrayLike["9007199254740991"], "9007199254740991", + "arrayLike['9007199254740991'] is unchanged"); + +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..75e501f6c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/throws-if-integer-limit-exceeded.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.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. + ... +---*/ + +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..af5ea7d782 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/S15.4.4.3_A1_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. + +/*--- +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(); + +//CHECK#1 +if (n !== 3) { + $ERROR('#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..dbef747e18 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/S15.4.4.3_A3_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. + +/*--- +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" +---*/ + +//CHECK#1 +var n = 0; +var obj = { + toLocaleString: function() { + n++ + } +}; +Array.prototype[1] = obj; +var x = [obj]; +x.length = 2; +x.toLocaleString(); +if (n !== 2) { + $ERROR('#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/S15.4.4.3_A4.7.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/S15.4.4.3_A4.7.js new file mode 100644 index 0000000000..449ddbc556 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/S15.4.4.3_A4.7.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.tolocalestring +info: The toLocaleString property of Array can't be used as constructor +es5id: 15.4.4.3_A4.7 +description: > + If property does not implement the internal [[Construct]] method, + throw a TypeError exception +---*/ + +//CHECK#1 + +try { + new Array.prototype.toLocaleString(); + $ERROR('#1.1: new Array.prototype.toLocaleString() throw TypeError. Actual: ' + (new Array.prototype.toLocaleString())); +} catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: new Array.prototype.toLocaleString() throw TypeError. Actual: ' + (e)); + } +} + +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/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/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..fb4513263b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_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.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 +---*/ + +//CHECK#1 +var x = new Array(); +if (x.toString() !== x.join()) { + $ERROR('#1.1: x = new Array(); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "") { + $ERROR('#1.2: x = new Array(); x.toString() === "". Actual: ' + (x.toString())); + } +} + +//CHECK#2 +x = []; +x[0] = 1; +x.length = 0; +if (x.toString() !== x.join()) { + $ERROR('#2.1: x = []; x[0] = 1; x.length = 0; x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "") { + $ERROR('#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..d9044ac399 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T2.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. + +/*--- +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 +---*/ + +//CHECK#1 +var x = new Array(0, 1, 2, 3); +if (x.toString() !== x.join()) { + $ERROR('#1.1: x = new Array(0,1,2,3); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "0,1,2,3") { + $ERROR('#1.2: x = new Array(0,1,2,3); x.toString() === "0,1,2,3". Actual: ' + (x.toString())); + } +} + +//CHECK#2 +x = []; +x[0] = 0; +x[3] = 3; +if (x.toString() !== x.join()) { + $ERROR('#2.1: x = []; x[0] = 0; x[3] = 3; x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "0,,,3") { + $ERROR('#2.2: x = []; x[0] = 0; x[3] = 3; x.toString() === "0,,,3". Actual: ' + (x.toString())); + } +} + +//CHECK#3 +x = Array(undefined, 1, null, 3); +if (x.toString() !== x.join()) { + $ERROR('#3.1: x = Array(undefined,1,null,3); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== ",1,,3") { + $ERROR('#3.2: x = Array(undefined,1,null,3); x.toString() === ",1,,3". Actual: ' + (x.toString())); + } +} + +//CHECK#4 +x = []; +x[0] = 0; +if (x.toString() !== x.join()) { + $ERROR('#4.1: x = []; x[0] = 0; x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "0") { + $ERROR('#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..11e69bf7e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T3.js @@ -0,0 +1,93 @@ +// 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 +---*/ + +//CHECK#0 +var x = new Array("", "", ""); +if (x.toString() !== x.join()) { + $ERROR('#0.1: var x = new Array("","",""); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== ",,") { + $ERROR('#0.2: var x = new Array("","",""); x.toString() === ",,". Actual: ' + (x.toString())); + } +} + +//CHECK#1 +var x = new Array("\\", "\\", "\\"); +if (x.toString() !== x.join()) { + $ERROR('#1.1: var x = new Array("\\","\\","\\"); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "\\,\\,\\") { + $ERROR('#1.2: var x = new Array("\\","\\","\\"); x.toString() === "\\,\\,\\". Actual: ' + (x.toString())); + } +} + +//CHECK#2 +var x = new Array("&", "&", "&"); +if (x.toString() !== x.join()) { + $ERROR('#2.1: var x = new Array("&", "&", "&"); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "&,&,&") { + $ERROR('#2.2: var x = new Array("&", "&", "&"); x.toString() === "&,&,&". Actual: ' + (x.toString())); + } +} + +//CHECK#3 +var x = new Array(true, true, true); +if (x.toString() !== x.join()) { + $ERROR('#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") { + $ERROR('#3.2: var x = new Array(true,true,true); x.toString(true,true,true) === "true,true,true". Actual: ' + (x.toString(true, true, true))); + } +} + +//CHECK#4 +var x = new Array(null, null, null); +if (x.toString() !== x.join()) { + $ERROR('#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() !== ",,") { + $ERROR('#4.2: var x = new Array(null,null,null); x.toString(null,null,null) === ",,". Actual: ' + (x.toString(null, null, null))); + } +} + +//CHECK#5 +var x = new Array(undefined, undefined, undefined); +if (x.toString() !== x.join()) { + $ERROR('#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() !== ",,") { + $ERROR('#5.2: var x = new Array(undefined,undefined,undefined); x.toString(undefined,undefined,undefined) === ",,". Actual: ' + (x.toString(undefined, undefined, undefined))); + } +} + +//CHECK#6 +var x = new Array(Infinity, Infinity, Infinity); +if (x.toString() !== x.join()) { + $ERROR('#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") { + $ERROR('#6.2: var x = new Array(Infinity,Infinity,Infinity); x.toString(Infinity,Infinity,Infinity) === "Infinity,Infinity,Infinity". Actual: ' + (x.toString(Infinity, Infinity, Infinity))); + } +} + +//CHECK#7 +var x = new Array(NaN, NaN, NaN); +if (x.toString() !== x.join()) { + $ERROR('#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") { + $ERROR('#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..51e57779ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T4.js @@ -0,0 +1,164 @@ +// 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) +---*/ + +//CHECK#1 +var object = { + valueOf: function() { + return "+" + } +}; +var x = new Array(object); +if (x.toString() !== x.join()) { + $ERROR('#1.1: var object = {valueOf: function() {return "+"}} var x = new Array(object); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "[object Object]") { + $ERROR('#1.2: var object = {valueOf: function() {return "+"}} var x = new Array(object); x.toString() === "[object Object]". Actual: ' + (x.toString())); + } +} + +//CHECK#2 +var object = { + valueOf: function() { + return "+" + }, + toString: function() { + return "*" + } +}; +var x = new Array(object); +if (x.toString() !== x.join()) { + $ERROR('#2.1: var object = {valueOf: function() {return "+"}, toString: function() {return x.join()}} var x = new Array(object); x.toString() === "*". Actual: ' + (x.toString())); +} else { + if (x.toString() !== "*") { + $ERROR('#2.2: var object = {valueOf: function() {return "+"}, toString: function() {return "*"}} var x = new Array(object); x.toString() === "*". Actual: ' + (x.toString())); + } +} + +//CHECK#3 +var object = { + valueOf: function() { + return "+" + }, + toString: function() { + return {} + } +}; +var x = new Array(object); +if (x.toString() !== x.join()) { + $ERROR('#3.1: var object = {valueOf: function() {return x.join()}, toString: function() {return {}}} var x = new Array(object); x.toString() === "+". Actual: ' + (x.toString())); +} else { + if (x.toString() !== "+") { + $ERROR('#3.2: var object = {valueOf: function() {return "+"}, toString: function() {return {}}} var x = new Array(object); x.toString() === "+". Actual: ' + (x.toString())); + } +} + +//CHECK#4 +try { + var object = { + valueOf: function() { + throw "error" + }, + toString: function() { + return "*" + } + }; + var x = new Array(object); + if (x.toString() !== x.join()) { + $ERROR('#4.1: var object = {valueOf: function() {throw "error"}, toString: function() {return x.join()}} var x = new Array(object); x.toString() === "*". Actual: ' + (x.toString())); + } else { + if (x.toString() !== "*") { + $ERROR('#4.2: var object = {valueOf: function() {throw "error"}, toString: function() {return "*"}} var x = new Array(object); x.toString() === "*". Actual: ' + (x.toString())); + } + } +} +catch (e) { + if (e === "error") { + $ERROR('#4.3: var object = {valueOf: function() {throw "error"}, toString: function() {return "*"}} var x = new Array(object); x.toString() not throw "error"'); + } else { + $ERROR('#4.4: var object = {valueOf: function() {throw "error"}, toString: function() {return "*"}} var x = new Array(object); x.toString() not throw Error. Actual: ' + (e)); + } +} + +//CHECK#5 +var object = { + toString: function() { + return "*" + } +}; +var x = new Array(object); +if (x.toString() !== x.join()) { + $ERROR('#5.1: var object = {toString: function() {return x.join()}} var x = new Array(object); x.toString() === "*". Actual: ' + (x.toString())); +} else { + if (x.toString() !== "*") { + $ERROR('#5.2: var object = {toString: function() {return "*"}} var x = new Array(object); x.toString() === "*". Actual: ' + (x.toString())); + } +} + +//CHECK#6 +var object = { + valueOf: function() { + return {} + }, + toString: function() { + return "*" + } +} +var x = new Array(object); +if (x.toString() !== x.join()) { + $ERROR('#6.1: var object = {valueOf: function() {return {}}, toString: function() {return x.join()}} var x = new Array(object); x.toString() === "*". Actual: ' + (x.toString())); +} else { + if (x.toString() !== "*") { + $ERROR('#6.2: var object = {valueOf: function() {return {}}, toString: function() {return "*"}} var x = new Array(object); x.toString() === "*". Actual: ' + (x.toString())); + } +} + +//CHECK#7 +try { + var object = { + valueOf: function() { + return "+" + }, + toString: function() { + throw "error" + } + }; + var x = new Array(object); + x.toString(); + $ERROR('#7.1: var object = {valueOf: function() {return "+"}, toString: function() {throw "error"}} var x = new Array(object); x.toString() throw "error". Actual: ' + (x.toString())); +} +catch (e) { + if (e !== "error") { + $ERROR('#7.2: var object = {valueOf: function() {return "+"}, toString: function() {throw "error"}} var x = new Array(object); x.toString() throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + var object = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + var x = new Array(object); + x.toString(); + $ERROR('#8.1: var object = {valueOf: function() {return {}}, toString: function() {return {}}} var x = new Array(object); x.toString() throw TypeError. Actual: ' + (x.toString())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#8.2: var object = {valueOf: function() {return {}}, toString: function() {return {}}} var x = new Array(object); x.toString() throw TypeError. Actual: ' + (e)); + } +} + +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..b26af068f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_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. + +/*--- +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" +---*/ + +//CHECK#1 +Array.prototype[1] = 1; +var x = [0]; +x.length = 2; +if (x.toString() !== "0,1") { + $ERROR('#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/S15.4.4.2_A4.7.js b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A4.7.js new file mode 100644 index 0000000000..2daa6b7325 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A4.7.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.tostring +info: The toString property of Array can't be used as constructor +es5id: 15.4.4.2_A4.7 +description: > + If property does not implement the internal [[Construct]] method, + throw a TypeError exception +---*/ + +//CHECK#1 + +try { + new Array.prototype.toString(); + $ERROR('#1.1: new Array.prototype.toString() throw TypeError. Actual: ' + (new Array.prototype.toString())); +} catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: new Array.prototype.toString() throw TypeError. Actual: ' + (e)); + } +} + +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/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..13a39f99a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A1_T1.js @@ -0,0 +1,57 @@ +// 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 +---*/ + +//CHECK#1 +var x = new Array(); +var unshift = x.unshift(1); +if (unshift !== 1) { + $ERROR('#1: x = new Array(); x.unshift(1) === 1. Actual: ' + (unshift)); +} + +//CHECK#2 +if (x[0] !== 1) { + $ERROR('#2: x = new Array(); x.unshift(1); x[0] === 1. Actual: ' + (x[0])); +} + +//CHECK#3 +var unshift = x.unshift(); +if (unshift !== 1) { + $ERROR('#3: x = new Array(); x.unshift(1); x.unshift() === 1. Actual: ' + (unshift)); +} + +//CHECK#4 +if (x[1] !== undefined) { + $ERROR('#4: x = new Array(); x.unshift(1); x.unshift(); x[1] === unedfined. Actual: ' + (x[1])); +} + +//CHECK#5 +var unshift = x.unshift(-1); +if (unshift !== 2) { + $ERROR('#5: x = new Array(); x.unshift(1); x.unshift(); x.unshift(-1) === 2. Actual: ' + (unshift)); +} + +//CHECK#6 +if (x[0] !== -1) { + $ERROR('#6: x = new Array(); x.unshift(1); x.unshift(-1); x[0] === -1. Actual: ' + (x[0])); +} + +//CHECK#7 +if (x[1] !== 1) { + $ERROR('#7: x = new Array(); x.unshift(1); x.unshift(-1); x[1] === 1. Actual: ' + (x[1])); +} + +//CHECK#8 +if (x.length !== 2) { + $ERROR('#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..c8ca86c43b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A1_T2.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 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 +---*/ + +//CHECK#1 +var x = []; +if (x.length !== 0) { + $ERROR('#1: x = []; x.length === 0. Actual: ' + (x.length)); +} + +//CHECK#2 +x[0] = 0; +var unshift = x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); +if (unshift !== 6) { + $ERROR('#2: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1) === 6. Actual: ' + (unshift)); +} + +//CHECK#3 +if (x[5] !== 0) { + $ERROR('#3: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[5] === 0. Actual: ' + (x[5])); +} + +//CHECK#4 +if (x[0] !== true) { + $ERROR('#4: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[0] === true. Actual: ' + (x[0])); +} + +//CHECK#5 +if (x[1] !== Number.POSITIVE_INFINITY) { + $ERROR('#5: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[1] === Number.POSITIVE_INFINITY. Actual: ' + (x[1])); +} + +//CHECK#6 +if (x[2] !== "NaN") { + $ERROR('#6: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[2] === "NaN". Actual: ' + (x[2])); +} + +//CHECK#7 +if (x[3] !== "1") { + $ERROR('#7: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[3] === "1". Actual: ' + (x[3])); +} + +//CHECK#8 +if (x[4] !== -1) { + $ERROR('#8: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[4] === -1. Actual: ' + (x[4])); +} + +//CHECK#9 +if (x.length !== 6) { + $ERROR('#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..d36cd91d58 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_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: | + 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) { + $ERROR('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + //CHECK#1 + var unshift = obj.unshift(-1); + if (unshift !== 1) { + $ERROR('#1: var obj = {}; obj.unshift = Array.prototype.unshift; obj.unshift(-1) === 1. Actual: ' + (unshift)); + } + //CHECK#2 + if (obj.length !== 1) { + $ERROR('#2: var obj = {}; obj.unshift = Array.prototype.unshift; obj.unshift(-1); obj.length === 1. Actual: ' + (obj.length)); + } + //CHECK#3 + if (obj["0"] !== -1) { + $ERROR('#3: var obj = {}; obj.unshift = Array.prototype.unshift; obj.unshift(-1); obj["0"] === -1. Actual: ' + (obj["0"])); + } +} + +//CHECK#4 +obj.length = undefined; +var unshift = obj.unshift(-4); +if (unshift !== 1) { + $ERROR('#4: var obj = {}; obj.length = undefined; obj.unshift = Array.prototype.unshift; obj.unshift(-4) === 1. Actual: ' + (unshift)); +} + +//CHECK#5 +if (obj.length !== 1) { + $ERROR('#5: var obj = {}; obj.length = undefined; obj.unshift = Array.prototype.unshift; obj.unshift(-4); obj.length === 1. Actual: ' + (obj.length)); +} + +//CHECK#6 +if (obj["0"] !== -4) { + $ERROR('#6: var obj = {}; obj.length = undefined; obj.unshift = Array.prototype.unshift; obj.unshift(-4); obj["0"] === -4. Actual: ' + (obj["0"])); +} + +//CHECK#7 +obj.length = null +var unshift = obj.unshift(-7); +if (unshift !== 1) { + $ERROR('#7: var obj = {}; obj.length = null; obj.unshift = Array.prototype.unshift; obj.unshift(-7) === 1. Actual: ' + (unshift)); +} + +//CHECK#8 +if (obj.length !== 1) { + $ERROR('#8: var obj = {}; obj.length = null; obj.unshift = Array.prototype.unshift; obj.unshift(-7); obj.length === 1. Actual: ' + (obj.length)); +} + +//CHECK#9 +if (obj["0"] !== -7) { + $ERROR('#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..76386d8825 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_T2.js @@ -0,0 +1,103 @@ +// 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; + +//CHECK#1 +obj.length = NaN; +var unshift = obj.unshift(-1); +if (unshift !== 1) { + $ERROR('#1: var obj = {}; obj.length = NaN; obj.unshift = Array.prototype.unshift; obj.unshift(-1) === 1. Actual: ' + (unshift)); +} + +//CHECK#2 +if (obj.length !== 1) { + $ERROR('#2: var obj = {}; obj.length = NaN; obj.unshift = Array.prototype.unshift; obj.unshift(-1); obj.length === 1. Actual: ' + (obj.length)); +} + +//CHECK#3 +if (obj["0"] !== -1) { + $ERROR('#3: var obj = {}; obj.length = NaN; obj.unshift = Array.prototype.unshift; obj.unshift(-1); obj["0"] === -1. Actual: ' + (obj["0"])); +} + +//CHECK#7 +obj.length = Number.NEGATIVE_INFINITY; +var unshift = obj.unshift(-7); +if (unshift !== 1) { + $ERROR('#7: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.unshift = Array.prototype.unshift; obj.unshift(-7) === 1. Actual: ' + (unshift)); +} + +//CHECK#8 +if (obj.length !== 1) { + $ERROR('#8: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.unshift = Array.prototype.unshift; obj.unshift(-7); obj.length === 1. Actual: ' + (obj.length)); +} + +//CHECK#9 +if (obj["0"] !== -7) { + $ERROR('#9: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.unshift = Array.prototype.unshift; obj.unshift(-7); obj["0"] === -7. Actual: ' + (obj["0"])); +} + +//CHECK#10 +obj.length = 0.5; +var unshift = obj.unshift(-10); +if (unshift !== 1) { + $ERROR('#10: var obj = {}; obj.length = 0.5; obj.unshift = Array.prototype.unshift; obj.unshift(-10) === 1. Actual: ' + (unshift)); +} + +//CHECK#11 +if (obj.length !== 1) { + $ERROR('#11: var obj = {}; obj.length = 0.5; obj.unshift = Array.prototype.unshift; obj.unshift(-10); obj.length === 1. Actual: ' + (obj.length)); +} + +//CHECK#12 +if (obj["0"] !== -10) { + $ERROR('#12: var obj = {}; obj.length = 0.5; obj.unshift = Array.prototype.unshift; obj.unshift(-10); obj["0"] === -10. Actual: ' + (obj["0"])); +} + +//CHECK#13 +obj.length = 1.5; +var unshift = obj.unshift(-13); +if (unshift !== 2) { + $ERROR('#13: var obj = {}; obj.length = 1.5; obj.unshift = Array.prototype.unshift; obj.unshift(-13) === 2. Actual: ' + (unshift)); +} + +//CHECK#14 +if (obj.length !== 2) { + $ERROR('#14: var obj = {}; obj.length = 1.5; obj.unshift = Array.prototype.unshift; obj.unshift(-13); obj.length === 2. Actual: ' + (obj.length)); +} + +//CHECK#15 +if (obj["0"] !== -13) { + $ERROR('#15: var obj = {}; obj.length = 1.5; obj.unshift = Array.prototype.unshift; obj.unshift(-13); obj["0"] === -13. Actual: ' + (obj["0"])); +} + +//CHECK#16 +obj.length = new Number(0); +var unshift = obj.unshift(-16); +if (unshift !== 1) { + $ERROR('#16: var obj = {}; obj.length = new Number(0); obj.unshift = Array.prototype.unshift; obj.unshift(-16) === 1. Actual: ' + (unshift)); +} + +//CHECK#17 +if (obj.length !== 1) { + $ERROR('#17: var obj = {}; obj.length = new Number(0); obj.unshift = Array.prototype.unshift; obj.unshift(-16); obj.length === 1. Actual: ' + (obj.length)); +} + +//CHECK#18 +if (obj["0"] !== -16) { + $ERROR('#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..3daec28737 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A2_T3.js @@ -0,0 +1,144 @@ +// 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; + +//CHECK#1 +obj.length = { + valueOf: function() { + return 3 + } +}; +var unshift = obj.unshift(); +if (unshift !== 3) { + $ERROR('#1: obj.length = {valueOf: function() {return 3}} obj.unshift() === 3. Actual: ' + (unshift)); +} + +//CHECK#2 +obj.length = { + valueOf: function() { + return 3 + }, + toString: function() { + return 1 + } +}; +var unshift = obj.unshift(); +if (unshift !== 3) { + $ERROR('#0: obj.length = {valueOf: function() {return 3}, toString: function() {return 1}} obj.unshift() === 3. Actual: ' + (unshift)); +} + +//CHECK#3 +obj.length = { + valueOf: function() { + return 3 + }, + toString: function() { + return {} + } +}; +var unshift = obj.unshift(); +if (unshift !== 3) { + $ERROR('#1: obj.length = {valueOf: function() {return 3}, toString: function() {return {}}} obj.unshift() === 3. Actual: ' + (unshift)); +} + +//CHECK#4 +try { + obj.length = { + valueOf: function() { + return 3 + }, + toString: function() { + throw "error" + } + }; + var unshift = obj.unshift(); + if (unshift !== 3) { + $ERROR('#4.1: obj.length = {valueOf: function() {return 3}, toString: function() {throw "error"}}; obj.unshift() === ",". Actual: ' + (unshift)); + } +} +catch (e) { + if (e === "error") { + $ERROR('#4.2: obj.length = {valueOf: function() {return 3}, toString: function() {throw "error"}}; obj.unshift() not throw "error"'); + } else { + $ERROR('#4.3: obj.length = {valueOf: function() {return 3}, toString: function() {throw "error"}}; obj.unshift() not throw Error. Actual: ' + (e)); + } +} + +//CHECK#5 +obj.length = { + toString: function() { + return 1 + } +}; +var unshift = obj.unshift(); +if (unshift !== 1) { + $ERROR('#5: obj.length = {toString: function() {return 1}} obj.unshift() === 1. Actual: ' + (unshift)); +} + +//CHECK#6 +obj.length = { + valueOf: function() { + return {} + }, + toString: function() { + return 1 + } +} +var unshift = obj.unshift(); +if (unshift !== 1) { + $ERROR('#6: obj.length = {valueOf: function() {return {}}, toString: function() {return 1}} obj.unshift() === 1. Actual: ' + (unshift)); +} + +//CHECK#7 +try { + + obj.length = { + valueOf: function() { + throw "error" + }, + toString: function() { + return 1 + } + }; + var unshift = obj.unshift(); + $ERROR('#7.1: obj.length = {valueOf: function() {throw "error"}, toString: function() {return 1}}; obj.unshift() throw "error". Actual: ' + (unshift)); +} +catch (e) { + if (e !== "error") { + $ERROR('#7.2: obj.length = {valueOf: function() {throw "error"}, toString: function() {return 1}}; obj.unshift() throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + + obj.length = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + var unshift = obj.unshift(); + $ERROR('#8.1: obj.length = {valueOf: function() {return {}}, toString: function() {return {}}} obj.unshift() throw TypeError. Actual: ' + (unshift)); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#8.2: obj.length = {valueOf: function() {return {}}, toString: function() {return {}}} obj.unshift() throw TypeError. Actual: ' + (e)); + } +} + +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..3fd0921d1f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A3_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. + +/*--- +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; + +//CHECK#1 +var unshift = obj.unshift("x", "y", "z"); +if (unshift !== 3) { + $ERROR('#1: var obj = {}; obj.unshift = Array.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z") === 3. Actual: ' + (unshift)); +} + +//CHECK#2 +if (obj.length !== 3) { + $ERROR('#2: var obj = {}; obj.unshift = Array.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z"); obj.length === 3. Actual: ' + (obj.length)); +} + +//CHECK#3 +if (obj[0] !== "x") { + $ERROR('#3: var obj = {}; obj.unshift = Array.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z"); obj[0] === "x". Actual: ' + (obj[0])); +} + +//CHECK#4 +if (obj[1] !== "y") { + $ERROR('#4: var obj = {}; obj.unshift = Array.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z"); obj[1] === "y". Actual: ' + (obj[1])); +} + +//CHECK#5 +if (obj[2] !== "z") { + $ERROR('#5: var obj = {}; obj.unshift = Array.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z"); obj[2] === "z". Actual: ' + (obj[2])); +} + +//CHECK#6 +if (obj[3] !== undefined) { + $ERROR('#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..240a9db7e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A4_T1.js @@ -0,0 +1,80 @@ +// 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; + +//CHECK#1 +var unshift = x.unshift(0); +if (unshift !== 2) { + $ERROR('#1: Array.prototype[0] = -1; x = [1]; x.length = 1; x.unshift(0) === 2. Actual: ' + (unshift)); +} + +//CHECK#2 +if (x[0] !== 0) { + $ERROR('#2: Array.prototype[0] = -1; x = [1]; x.length = 1; x.unshift(0); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#3 +if (x[1] !== 1) { + $ERROR('#3: Array.prototype[0] = -1; x = [1]; x.length = 1; x.unshift(0); x[1] === 1. Actual: ' + (x[1])); +} + +delete x[0]; + +//CHECK#4 +if (x[0] !== -1) { + $ERROR('#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 +}; + +//CHECK#5 +var unshift = x.unshift(0); +if (unshift !== 2) { + $ERROR('#5: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.unshift = Array.prototype.unshift; x = {0:0}; x.unshift(0) === 2. Actual: ' + (unshift)); +} + +//CHECK#6 +if (x[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#7 +if (x[1] !== 1) { + $ERROR('#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]; + +//CHECK#8 +if (x[0] !== -1) { + $ERROR('#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])); +} + +//CHECK#9 +if (x.length !== 2) { + $ERROR('#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)); +} + +//CHECK#10 +delete x.length; +if (x.length !== 1) { + $ERROR('#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..049139f837 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A4_T2.js @@ -0,0 +1,78 @@ +// 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; + +//CHECK#1 +var unshift = x.unshift(0); +if (unshift !== 2) { + $ERROR('#1: Array.prototype[0] = 1; x = []; x.length = 1; x.unshift(0) === 2. Actual: ' + (unshift)); +} + +//CHECK#2 +if (x[0] !== 0) { + $ERROR('#2: Array.prototype[0] = 1; x = []; x.length = 1; x.unshift(0); x[0] === 0. Actual: ' + (x[0])); +} + +//CHECK#3 +if (x[1] !== 1) { + $ERROR('#3: Array.prototype[0] = 1; x = []; x.length = 1; x.unshift(0); x[1] === 1. Actual: ' + (x[1])); +} + +delete x[0]; + +//CHECK#4 +if (x[0] !== 1) { + $ERROR('#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 = {}; + +//CHECK#5 +var unshift = x.unshift(0); +if (unshift !== 2) { + $ERROR('#5: Object.prototype[0] = 1; Object.prototype.length = 1; Object.prototype.unshift = Array.prototype.unshift; x = {}; x.unshift(0) === 2. Actual: ' + (unshift)); +} + +//CHECK#6 +if (x[0] !== 0) { + $ERROR('#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])); +} + +//CHECK#7 +if (x[1] !== 1) { + $ERROR('#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]; + +//CHECK#8 +if (x[0] !== 1) { + $ERROR('#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])); +} + +//CHECK#9 +if (x.length !== 2) { + $ERROR('#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)); +} + +//CHECK#10 +delete x.length; +if (x.length !== 1) { + $ERROR('#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/S15.4.4.13_A5.7.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A5.7.js new file mode 100644 index 0000000000..8ca015ad63 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/S15.4.4.13_A5.7.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: The unshift property of Array can't be used as constructor +esid: sec-array.prototype.unshift +description: > + If property does not implement the internal [[Construct]] method, + throw a TypeError exception +---*/ + +//CHECK#1 + +try { + new Array.prototype.unshift(); + $ERROR('#1.1: new Array.prototype.unshift() throw TypeError. Actual: ' + (new Array.prototype.unshift())); +} catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: new Array.prototype.unshift() throw TypeError. Actual: ' + (e)); + } +} + +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..bd8c4eef43 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/clamps-to-integer-limit.js @@ -0,0 +1,34 @@ +// 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). +---*/ + +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..78b284d860 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/length-near-integer-limit.js @@ -0,0 +1,62 @@ +// 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. +---*/ + +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/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..0433a7969f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/throws-if-integer-limit-exceeded.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.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. ... +---*/ + +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/shell.js b/js/src/tests/test262/built-ins/Array/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/shell.js @@ -0,0 +1,19 @@ +// 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] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} -- cgit v1.2.3