From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../statements/function/13.0-12-s-strict.js | 20 +++ .../language/statements/function/13.0-13-s.js | 21 ++++ .../language/statements/function/13.0-14-s.js | 22 ++++ .../language/statements/function/13.0-15-s.js | 22 ++++ .../language/statements/function/13.0-16-s.js | 22 ++++ .../language/statements/function/13.0-17-s.js | 18 +++ .../language/statements/function/13.0-7-s.js | 22 ++++ .../statements/function/13.0-8-s-strict.js | 22 ++++ .../statements/function/13.0_4-17gs-strict.js | 15 +++ .../statements/function/13.0_4-5gs-strict.js | 19 +++ .../statements/function/13.1-13gs-strict.js | 19 +++ .../language/statements/function/13.1-19-s.js | 22 ++++ .../statements/function/13.1-1gs-strict.js | 20 +++ .../statements/function/13.1-2-s-strict.js | 23 ++++ .../language/statements/function/13.1-21-s.js | 22 ++++ .../language/statements/function/13.1-22-s.js | 22 ++++ .../language/statements/function/13.1-23-s.js | 22 ++++ .../language/statements/function/13.1-25-s.js | 23 ++++ .../language/statements/function/13.1-27-s.js | 22 ++++ .../language/statements/function/13.1-29-s.js | 22 ++++ .../language/statements/function/13.1-31-s.js | 23 ++++ .../language/statements/function/13.1-33-s.js | 22 ++++ .../language/statements/function/13.1-39-s.js | 17 +++ .../statements/function/13.1-4-s-strict.js | 23 ++++ .../language/statements/function/13.1-41-s.js | 17 +++ .../statements/function/13.1-4gs-strict.js | 20 +++ .../statements/function/13.1-5gs-strict.js | 19 +++ .../statements/function/13.1-8gs-strict.js | 19 +++ .../language/statements/function/13.2-1-s.js | 18 +++ .../language/statements/function/13.2-10-s.js | 16 +++ .../language/statements/function/13.2-11-s.js | 17 +++ .../language/statements/function/13.2-12-s.js | 14 +++ .../language/statements/function/13.2-13-s.js | 16 +++ .../language/statements/function/13.2-14-s.js | 16 +++ .../language/statements/function/13.2-15-1.js | 21 ++++ .../language/statements/function/13.2-15-s.js | 17 +++ .../language/statements/function/13.2-16-s.js | 14 +++ .../language/statements/function/13.2-17-1.js | 55 +++++++++ .../language/statements/function/13.2-17-s.js | 16 +++ .../language/statements/function/13.2-18-1.js | 42 +++++++ .../language/statements/function/13.2-18-s.js | 16 +++ .../statements/function/13.2-19-b-3gs-strict.js | 19 +++ .../language/statements/function/13.2-19-s.js | 17 +++ .../statements/function/13.2-2-s-strict.js | 20 +++ .../language/statements/function/13.2-20-s.js | 15 +++ .../language/statements/function/13.2-21-s.js | 17 +++ .../language/statements/function/13.2-22-s.js | 17 +++ .../language/statements/function/13.2-23-s.js | 17 +++ .../language/statements/function/13.2-24-s.js | 21 ++++ .../language/statements/function/13.2-25-s.js | 17 +++ .../language/statements/function/13.2-26-s.js | 17 +++ .../language/statements/function/13.2-27-s.js | 18 +++ .../language/statements/function/13.2-28-s.js | 20 +++ .../language/statements/function/13.2-3-s.js | 18 +++ .../language/statements/function/13.2-30-s.js | 34 ++++++ .../statements/function/13.2-4-s-strict.js | 20 +++ .../language/statements/function/13.2-5-s.js | 17 +++ .../language/statements/function/13.2-6-s.js | 17 +++ .../language/statements/function/13.2-7-s.js | 18 +++ .../language/statements/function/13.2-8-s.js | 15 +++ .../language/statements/function/13.2-9-s.js | 17 +++ .../language/statements/function/S10.1.1_A1_T1.js | 19 +++ .../language/statements/function/S13.2.1_A1_T1.js | 74 ++++++++++++ .../language/statements/function/S13.2.1_A4_T1.js | 29 +++++ .../language/statements/function/S13.2.1_A4_T2.js | 29 +++++ .../language/statements/function/S13.2.1_A4_T3.js | 29 +++++ .../language/statements/function/S13.2.1_A4_T4.js | 29 +++++ .../language/statements/function/S13.2.1_A5_T1.js | 30 +++++ .../language/statements/function/S13.2.1_A5_T2.js | 28 +++++ .../language/statements/function/S13.2.1_A6_T1.js | 32 +++++ .../language/statements/function/S13.2.1_A6_T2.js | 32 +++++ .../language/statements/function/S13.2.1_A6_T3.js | 33 +++++ .../language/statements/function/S13.2.1_A6_T4.js | 33 +++++ .../language/statements/function/S13.2.1_A7_T1.js | 28 +++++ .../language/statements/function/S13.2.1_A7_T2.js | 30 +++++ .../language/statements/function/S13.2.1_A7_T3.js | 56 +++++++++ .../language/statements/function/S13.2.1_A7_T4.js | 58 +++++++++ .../language/statements/function/S13.2.1_A8_T1.js | 30 +++++ .../language/statements/function/S13.2.1_A8_T2.js | 32 +++++ .../statements/function/S13.2.1_A9.1_T1.js | 36 ++++++ .../statements/function/S13.2.1_A9.1_T2.js | 36 ++++++ .../language/statements/function/S13.2.1_A9_T1.js | 37 ++++++ .../language/statements/function/S13.2.1_A9_T2.js | 37 ++++++ .../language/statements/function/S13.2.2_A10.js | 40 ++++++ .../language/statements/function/S13.2.2_A11.js | 35 ++++++ .../language/statements/function/S13.2.2_A12.js | 42 +++++++ .../language/statements/function/S13.2.2_A13.js | 33 +++++ .../language/statements/function/S13.2.2_A14.js | 33 +++++ .../language/statements/function/S13.2.2_A15_T1.js | 48 ++++++++ .../language/statements/function/S13.2.2_A15_T2.js | 50 ++++++++ .../language/statements/function/S13.2.2_A15_T3.js | 50 ++++++++ .../language/statements/function/S13.2.2_A15_T4.js | 50 ++++++++ .../language/statements/function/S13.2.2_A16_T1.js | 38 ++++++ .../language/statements/function/S13.2.2_A16_T2.js | 38 ++++++ .../language/statements/function/S13.2.2_A16_T3.js | 46 +++++++ .../language/statements/function/S13.2.2_A17_T2.js | 72 +++++++++++ .../language/statements/function/S13.2.2_A17_T3.js | 71 +++++++++++ .../language/statements/function/S13.2.2_A18_T1.js | 57 +++++++++ .../language/statements/function/S13.2.2_A18_T2.js | 60 +++++++++ .../language/statements/function/S13.2.2_A19_T1.js | 30 +++++ .../language/statements/function/S13.2.2_A19_T2.js | 28 +++++ .../language/statements/function/S13.2.2_A19_T3.js | 37 ++++++ .../language/statements/function/S13.2.2_A19_T4.js | 39 ++++++ .../language/statements/function/S13.2.2_A19_T5.js | 43 +++++++ .../language/statements/function/S13.2.2_A19_T6.js | 44 +++++++ .../language/statements/function/S13.2.2_A19_T7.js | 55 +++++++++ .../language/statements/function/S13.2.2_A19_T8.js | 75 ++++++++++++ .../language/statements/function/S13.2.2_A1_T1.js | 46 +++++++ .../language/statements/function/S13.2.2_A1_T2.js | 46 +++++++ .../language/statements/function/S13.2.2_A2.js | 43 +++++++ .../language/statements/function/S13.2.2_A3_T1.js | 36 ++++++ .../language/statements/function/S13.2.2_A3_T2.js | 36 ++++++ .../language/statements/function/S13.2.2_A4_T1.js | 39 ++++++ .../language/statements/function/S13.2.2_A4_T2.js | 41 +++++++ .../language/statements/function/S13.2.2_A5_T1.js | 83 +++++++++++++ .../language/statements/function/S13.2.2_A5_T2.js | 83 +++++++++++++ .../language/statements/function/S13.2.2_A6_T1.js | 44 +++++++ .../language/statements/function/S13.2.2_A6_T2.js | 42 +++++++ .../language/statements/function/S13.2.2_A7_T1.js | 43 +++++++ .../language/statements/function/S13.2.2_A7_T2.js | 45 +++++++ .../language/statements/function/S13.2.2_A8_T1.js | 56 +++++++++ .../language/statements/function/S13.2.2_A8_T2.js | 54 +++++++++ .../language/statements/function/S13.2.2_A8_T3.js | 54 +++++++++ .../language/statements/function/S13.2.2_A9.js | 33 +++++ .../language/statements/function/S13.2_A1_T1.js | 20 +++ .../language/statements/function/S13.2_A1_T2.js | 20 +++ .../language/statements/function/S13.2_A2_T1.js | 28 +++++ .../language/statements/function/S13.2_A2_T2.js | 30 +++++ .../language/statements/function/S13.2_A3.js | 34 ++++++ .../language/statements/function/S13.2_A4_T1.js | 50 ++++++++ .../language/statements/function/S13.2_A4_T2.js | 50 ++++++++ .../language/statements/function/S13.2_A5.js | 33 +++++ .../statements/function/S13.2_A6_T1-strict.js | 13 ++ .../statements/function/S13.2_A6_T2-strict.js | 15 +++ .../statements/function/S13.2_A7_T1-strict.js | 13 ++ .../statements/function/S13.2_A7_T2-strict.js | 13 ++ .../statements/function/S13.2_A8_T1-strict.js | 13 ++ .../statements/function/S13.2_A8_T2-strict.js | 13 ++ .../test262/language/statements/function/S13_A1.js | 33 +++++ .../language/statements/function/S13_A10.js | 32 +++++ .../language/statements/function/S13_A11_T1.js | 23 ++++ .../language/statements/function/S13_A11_T2.js | 28 +++++ .../language/statements/function/S13_A11_T3.js | 27 +++++ .../language/statements/function/S13_A11_T4.js | 30 +++++ .../language/statements/function/S13_A12_T1.js | 35 ++++++ .../language/statements/function/S13_A12_T2.js | 40 ++++++ .../language/statements/function/S13_A13_T1.js | 26 ++++ .../language/statements/function/S13_A13_T2.js | 27 +++++ .../language/statements/function/S13_A13_T3.js | 33 +++++ .../language/statements/function/S13_A14_T1.js | 21 ++++ .../language/statements/function/S13_A15_T1.js | 23 ++++ .../language/statements/function/S13_A15_T2.js | 26 ++++ .../language/statements/function/S13_A15_T3.js | 36 ++++++ .../language/statements/function/S13_A15_T4.js | 28 +++++ .../language/statements/function/S13_A15_T5.js | 35 ++++++ .../language/statements/function/S13_A17_T1.js | 47 ++++++++ .../language/statements/function/S13_A17_T2.js | 50 ++++++++ .../language/statements/function/S13_A18.js | 32 +++++ .../language/statements/function/S13_A19_T1.js | 34 ++++++ .../language/statements/function/S13_A19_T2.js | 37 ++++++ .../language/statements/function/S13_A2_T1.js | 29 +++++ .../language/statements/function/S13_A2_T2.js | 29 +++++ .../language/statements/function/S13_A2_T3.js | 31 +++++ .../language/statements/function/S13_A3_T1.js | 33 +++++ .../language/statements/function/S13_A3_T2.js | 33 +++++ .../language/statements/function/S13_A3_T3.js | 31 +++++ .../language/statements/function/S13_A4_T1.js | 31 +++++ .../language/statements/function/S13_A4_T2.js | 33 +++++ .../language/statements/function/S13_A4_T3.js | 33 +++++ .../language/statements/function/S13_A4_T4.js | 51 ++++++++ .../language/statements/function/S13_A6_T1.js | 38 ++++++ .../language/statements/function/S13_A6_T2.js | 38 ++++++ .../language/statements/function/S13_A7_T1.js | 73 +++++++++++ .../language/statements/function/S13_A7_T3.js | 16 +++ .../language/statements/function/S13_A8_T1.js | 33 +++++ .../language/statements/function/S13_A8_T2.js | 40 ++++++ .../test262/language/statements/function/S13_A9.js | 21 ++++ .../test262/language/statements/function/S14_A2.js | 31 +++++ .../test262/language/statements/function/S14_A3.js | 32 +++++ .../language/statements/function/S14_A5_T1.js | 26 ++++ .../language/statements/function/S14_A5_T2.js | 25 ++++ .../function/arguments-with-arguments-fn.js | 32 +++++ .../function/arguments-with-arguments-lex.js | 32 +++++ .../array-destructuring-param-strict-body.js | 134 +++++++++++++++++++++ .../language/statements/function/browser.js | 0 .../language/statements/function/cptn-decl.js | 15 +++ .../statements/function/dflt-params-abrupt.js | 63 ++++++++++ .../function/dflt-params-arg-val-not-undefined.js | 87 +++++++++++++ .../function/dflt-params-arg-val-undefined.js | 70 +++++++++++ .../statements/function/dflt-params-duplicates.js | 63 ++++++++++ .../statements/function/dflt-params-ref-later.js | 64 ++++++++++ .../statements/function/dflt-params-ref-prior.js | 67 +++++++++++ .../statements/function/dflt-params-ref-self.js | 64 ++++++++++ .../statements/function/dflt-params-rest.js | 67 +++++++++++ .../function/dflt-params-trailing-comma.js | 61 ++++++++++ .../function/dstr/ary-init-iter-close.js | 73 +++++++++++ .../dstr/ary-init-iter-get-err-array-prototype.js | 66 ++++++++++ .../function/dstr/ary-init-iter-get-err.js | 60 +++++++++ .../function/dstr/ary-init-iter-no-close.js | 73 +++++++++++ .../statements/function/dstr/ary-name-iter-val.js | 72 +++++++++++ .../function/dstr/ary-ptrn-elem-ary-elem-init.js | 64 ++++++++++ .../function/dstr/ary-ptrn-elem-ary-elem-iter.js | 65 ++++++++++ .../dstr/ary-ptrn-elem-ary-elision-init.js | 71 +++++++++++ .../dstr/ary-ptrn-elem-ary-elision-iter.js | 68 +++++++++++ .../function/dstr/ary-ptrn-elem-ary-empty-init.js | 67 +++++++++++ .../function/dstr/ary-ptrn-elem-ary-empty-iter.js | 64 ++++++++++ .../function/dstr/ary-ptrn-elem-ary-rest-init.js | 68 +++++++++++ .../function/dstr/ary-ptrn-elem-ary-rest-iter.js | 71 +++++++++++ .../function/dstr/ary-ptrn-elem-ary-val-null.js | 67 +++++++++++ .../dstr/ary-ptrn-elem-id-init-exhausted.js | 63 ++++++++++ .../dstr/ary-ptrn-elem-id-init-fn-name-arrow.js | 64 ++++++++++ .../dstr/ary-ptrn-elem-id-init-fn-name-class.js | 66 ++++++++++ .../dstr/ary-ptrn-elem-id-init-fn-name-cover.js | 65 ++++++++++ .../dstr/ary-ptrn-elem-id-init-fn-name-fn.js | 65 ++++++++++ .../dstr/ary-ptrn-elem-id-init-fn-name-gen.js | 66 ++++++++++ .../function/dstr/ary-ptrn-elem-id-init-hole.js | 59 +++++++++ .../function/dstr/ary-ptrn-elem-id-init-skipped.js | 68 +++++++++++ .../function/dstr/ary-ptrn-elem-id-init-throws.js | 58 +++++++++ .../function/dstr/ary-ptrn-elem-id-init-undef.js | 62 ++++++++++ .../dstr/ary-ptrn-elem-id-init-unresolvable.js | 65 ++++++++++ .../dstr/ary-ptrn-elem-id-iter-complete.js | 66 ++++++++++ .../function/dstr/ary-ptrn-elem-id-iter-done.js | 61 ++++++++++ .../dstr/ary-ptrn-elem-id-iter-step-err.js | 67 +++++++++++ .../ary-ptrn-elem-id-iter-val-array-prototype.js | 82 +++++++++++++ .../function/dstr/ary-ptrn-elem-id-iter-val-err.js | 78 ++++++++++++ .../function/dstr/ary-ptrn-elem-id-iter-val.js | 72 +++++++++++ .../function/dstr/ary-ptrn-elem-obj-id-init.js | 64 ++++++++++ .../function/dstr/ary-ptrn-elem-obj-id.js | 64 ++++++++++ .../dstr/ary-ptrn-elem-obj-prop-id-init.js | 74 ++++++++++++ .../function/dstr/ary-ptrn-elem-obj-prop-id.js | 74 ++++++++++++ .../function/dstr/ary-ptrn-elem-obj-val-null.js | 67 +++++++++++ .../function/dstr/ary-ptrn-elem-obj-val-undef.js | 67 +++++++++++ .../function/dstr/ary-ptrn-elision-exhausted.js | 69 +++++++++++ .../function/dstr/ary-ptrn-elision-step-err.js | 74 ++++++++++++ .../statements/function/dstr/ary-ptrn-elision.js | 78 ++++++++++++ .../statements/function/dstr/ary-ptrn-empty.js | 61 ++++++++++ .../function/dstr/ary-ptrn-rest-ary-elem.js | 85 +++++++++++++ .../function/dstr/ary-ptrn-rest-ary-elision.js | 91 ++++++++++++++ .../function/dstr/ary-ptrn-rest-ary-empty.js | 74 ++++++++++++ .../function/dstr/ary-ptrn-rest-ary-rest.js | 70 +++++++++++ .../function/dstr/ary-ptrn-rest-id-direct.js | 65 ++++++++++ .../dstr/ary-ptrn-rest-id-elision-next-err.js | 60 +++++++++ .../function/dstr/ary-ptrn-rest-id-elision.js | 66 ++++++++++ .../function/dstr/ary-ptrn-rest-id-exhausted.js | 62 ++++++++++ .../dstr/ary-ptrn-rest-id-iter-step-err.js | 71 +++++++++++ .../function/dstr/ary-ptrn-rest-id-iter-val-err.js | 73 +++++++++++ .../statements/function/dstr/ary-ptrn-rest-id.js | 63 ++++++++++ .../function/dstr/ary-ptrn-rest-init-ary.js | 59 +++++++++ .../function/dstr/ary-ptrn-rest-init-id.js | 59 +++++++++ .../function/dstr/ary-ptrn-rest-init-obj.js | 59 +++++++++ .../function/dstr/ary-ptrn-rest-not-final-ary.js | 59 +++++++++ .../function/dstr/ary-ptrn-rest-not-final-id.js | 59 +++++++++ .../function/dstr/ary-ptrn-rest-not-final-obj.js | 59 +++++++++ .../function/dstr/ary-ptrn-rest-obj-id.js | 63 ++++++++++ .../function/dstr/ary-ptrn-rest-obj-prop-id.js | 70 +++++++++++ .../language/statements/function/dstr/browser.js | 0 .../function/dstr/dflt-ary-init-iter-close.js | 73 +++++++++++ .../dflt-ary-init-iter-get-err-array-prototype.js | 66 ++++++++++ .../function/dstr/dflt-ary-init-iter-get-err.js | 60 +++++++++ .../function/dstr/dflt-ary-init-iter-no-close.js | 73 +++++++++++ .../function/dstr/dflt-ary-name-iter-val.js | 72 +++++++++++ .../dstr/dflt-ary-ptrn-elem-ary-elem-init.js | 64 ++++++++++ .../dstr/dflt-ary-ptrn-elem-ary-elem-iter.js | 65 ++++++++++ .../dstr/dflt-ary-ptrn-elem-ary-elision-init.js | 71 +++++++++++ .../dstr/dflt-ary-ptrn-elem-ary-elision-iter.js | 68 +++++++++++ .../dstr/dflt-ary-ptrn-elem-ary-empty-init.js | 67 +++++++++++ .../dstr/dflt-ary-ptrn-elem-ary-empty-iter.js | 64 ++++++++++ .../dstr/dflt-ary-ptrn-elem-ary-rest-init.js | 68 +++++++++++ .../dstr/dflt-ary-ptrn-elem-ary-rest-iter.js | 71 +++++++++++ .../dstr/dflt-ary-ptrn-elem-ary-val-null.js | 67 +++++++++++ .../dstr/dflt-ary-ptrn-elem-id-init-exhausted.js | 63 ++++++++++ .../dflt-ary-ptrn-elem-id-init-fn-name-arrow.js | 64 ++++++++++ .../dflt-ary-ptrn-elem-id-init-fn-name-class.js | 66 ++++++++++ .../dflt-ary-ptrn-elem-id-init-fn-name-cover.js | 65 ++++++++++ .../dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 65 ++++++++++ .../dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 66 ++++++++++ .../dstr/dflt-ary-ptrn-elem-id-init-hole.js | 59 +++++++++ .../dstr/dflt-ary-ptrn-elem-id-init-skipped.js | 68 +++++++++++ .../dstr/dflt-ary-ptrn-elem-id-init-throws.js | 58 +++++++++ .../dstr/dflt-ary-ptrn-elem-id-init-undef.js | 62 ++++++++++ .../dflt-ary-ptrn-elem-id-init-unresolvable.js | 65 ++++++++++ .../dstr/dflt-ary-ptrn-elem-id-iter-complete.js | 66 ++++++++++ .../dstr/dflt-ary-ptrn-elem-id-iter-done.js | 61 ++++++++++ .../dstr/dflt-ary-ptrn-elem-id-iter-step-err.js | 67 +++++++++++ ...lt-ary-ptrn-elem-id-iter-val-array-prototype.js | 82 +++++++++++++ .../dstr/dflt-ary-ptrn-elem-id-iter-val-err.js | 78 ++++++++++++ .../dstr/dflt-ary-ptrn-elem-id-iter-val.js | 72 +++++++++++ .../dstr/dflt-ary-ptrn-elem-obj-id-init.js | 64 ++++++++++ .../function/dstr/dflt-ary-ptrn-elem-obj-id.js | 64 ++++++++++ .../dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js | 74 ++++++++++++ .../dstr/dflt-ary-ptrn-elem-obj-prop-id.js | 74 ++++++++++++ .../dstr/dflt-ary-ptrn-elem-obj-val-null.js | 67 +++++++++++ .../dstr/dflt-ary-ptrn-elem-obj-val-undef.js | 67 +++++++++++ .../dstr/dflt-ary-ptrn-elision-exhausted.js | 69 +++++++++++ .../dstr/dflt-ary-ptrn-elision-step-err.js | 74 ++++++++++++ .../function/dstr/dflt-ary-ptrn-elision.js | 78 ++++++++++++ .../function/dstr/dflt-ary-ptrn-empty.js | 61 ++++++++++ .../function/dstr/dflt-ary-ptrn-rest-ary-elem.js | 85 +++++++++++++ .../dstr/dflt-ary-ptrn-rest-ary-elision.js | 91 ++++++++++++++ .../function/dstr/dflt-ary-ptrn-rest-ary-empty.js | 74 ++++++++++++ .../function/dstr/dflt-ary-ptrn-rest-ary-rest.js | 70 +++++++++++ .../function/dstr/dflt-ary-ptrn-rest-id-direct.js | 65 ++++++++++ .../dstr/dflt-ary-ptrn-rest-id-elision-next-err.js | 60 +++++++++ .../function/dstr/dflt-ary-ptrn-rest-id-elision.js | 66 ++++++++++ .../dstr/dflt-ary-ptrn-rest-id-exhausted.js | 62 ++++++++++ .../dstr/dflt-ary-ptrn-rest-id-iter-step-err.js | 71 +++++++++++ .../dstr/dflt-ary-ptrn-rest-id-iter-val-err.js | 73 +++++++++++ .../function/dstr/dflt-ary-ptrn-rest-id.js | 63 ++++++++++ .../function/dstr/dflt-ary-ptrn-rest-init-ary.js | 59 +++++++++ .../function/dstr/dflt-ary-ptrn-rest-init-id.js | 59 +++++++++ .../function/dstr/dflt-ary-ptrn-rest-init-obj.js | 59 +++++++++ .../dstr/dflt-ary-ptrn-rest-not-final-ary.js | 59 +++++++++ .../dstr/dflt-ary-ptrn-rest-not-final-id.js | 59 +++++++++ .../dstr/dflt-ary-ptrn-rest-not-final-obj.js | 59 +++++++++ .../function/dstr/dflt-ary-ptrn-rest-obj-id.js | 63 ++++++++++ .../dstr/dflt-ary-ptrn-rest-obj-prop-id.js | 70 +++++++++++ .../statements/function/dstr/dflt-obj-init-null.js | 54 +++++++++ .../function/dstr/dflt-obj-init-undefined.js | 54 +++++++++ .../function/dstr/dflt-obj-ptrn-empty.js | 62 ++++++++++ .../dstr/dflt-obj-ptrn-id-get-value-err.js | 61 ++++++++++ .../dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js | 63 ++++++++++ .../dstr/dflt-obj-ptrn-id-init-fn-name-class.js | 65 ++++++++++ .../dstr/dflt-obj-ptrn-id-init-fn-name-cover.js | 64 ++++++++++ .../dstr/dflt-obj-ptrn-id-init-fn-name-fn.js | 64 ++++++++++ .../dstr/dflt-obj-ptrn-id-init-fn-name-gen.js | 65 ++++++++++ .../function/dstr/dflt-obj-ptrn-id-init-skipped.js | 67 +++++++++++ .../function/dstr/dflt-obj-ptrn-id-init-throws.js | 61 ++++++++++ .../dstr/dflt-obj-ptrn-id-init-unresolvable.js | 65 ++++++++++ .../dstr/dflt-obj-ptrn-id-trailing-comma.js | 57 +++++++++ .../function/dstr/dflt-obj-ptrn-list-err.js | 62 ++++++++++ .../function/dstr/dflt-obj-ptrn-prop-ary-init.js | 66 ++++++++++ .../dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js | 57 +++++++++ .../dstr/dflt-obj-ptrn-prop-ary-value-null.js | 56 +++++++++ .../function/dstr/dflt-obj-ptrn-prop-ary.js | 64 ++++++++++ .../function/dstr/dflt-obj-ptrn-prop-eval-err.js | 58 +++++++++ .../dstr/dflt-obj-ptrn-prop-id-get-value-err.js | 63 ++++++++++ .../dstr/dflt-obj-ptrn-prop-id-init-skipped.js | 79 ++++++++++++ .../dstr/dflt-obj-ptrn-prop-id-init-throws.js | 61 ++++++++++ .../dflt-obj-ptrn-prop-id-init-unresolvable.js | 65 ++++++++++ .../function/dstr/dflt-obj-ptrn-prop-id-init.js | 60 +++++++++ .../dstr/dflt-obj-ptrn-prop-id-trailing-comma.js | 61 ++++++++++ .../function/dstr/dflt-obj-ptrn-prop-id.js | 60 +++++++++ .../function/dstr/dflt-obj-ptrn-prop-obj-init.js | 66 ++++++++++ .../dstr/dflt-obj-ptrn-prop-obj-value-null.js | 56 +++++++++ .../dstr/dflt-obj-ptrn-prop-obj-value-undef.js | 56 +++++++++ .../function/dstr/dflt-obj-ptrn-prop-obj.js | 64 ++++++++++ .../function/dstr/dflt-obj-ptrn-rest-getter.js | 59 +++++++++ .../dstr/dflt-obj-ptrn-rest-skip-non-enumerable.js | 67 +++++++++++ .../function/dstr/dflt-obj-ptrn-rest-val-obj.js | 66 ++++++++++ .../statements/function/dstr/obj-init-null.js | 54 +++++++++ .../statements/function/dstr/obj-init-undefined.js | 54 +++++++++ .../statements/function/dstr/obj-ptrn-empty.js | 62 ++++++++++ .../function/dstr/obj-ptrn-id-get-value-err.js | 61 ++++++++++ .../dstr/obj-ptrn-id-init-fn-name-arrow.js | 63 ++++++++++ .../dstr/obj-ptrn-id-init-fn-name-class.js | 65 ++++++++++ .../dstr/obj-ptrn-id-init-fn-name-cover.js | 64 ++++++++++ .../function/dstr/obj-ptrn-id-init-fn-name-fn.js | 64 ++++++++++ .../function/dstr/obj-ptrn-id-init-fn-name-gen.js | 65 ++++++++++ .../function/dstr/obj-ptrn-id-init-skipped.js | 67 +++++++++++ .../function/dstr/obj-ptrn-id-init-throws.js | 61 ++++++++++ .../function/dstr/obj-ptrn-id-init-unresolvable.js | 65 ++++++++++ .../function/dstr/obj-ptrn-id-trailing-comma.js | 57 +++++++++ .../statements/function/dstr/obj-ptrn-list-err.js | 62 ++++++++++ .../function/dstr/obj-ptrn-prop-ary-init.js | 66 ++++++++++ .../dstr/obj-ptrn-prop-ary-trailing-comma.js | 57 +++++++++ .../function/dstr/obj-ptrn-prop-ary-value-null.js | 56 +++++++++ .../statements/function/dstr/obj-ptrn-prop-ary.js | 64 ++++++++++ .../function/dstr/obj-ptrn-prop-eval-err.js | 58 +++++++++ .../dstr/obj-ptrn-prop-id-get-value-err.js | 63 ++++++++++ .../function/dstr/obj-ptrn-prop-id-init-skipped.js | 79 ++++++++++++ .../function/dstr/obj-ptrn-prop-id-init-throws.js | 61 ++++++++++ .../dstr/obj-ptrn-prop-id-init-unresolvable.js | 65 ++++++++++ .../function/dstr/obj-ptrn-prop-id-init.js | 60 +++++++++ .../dstr/obj-ptrn-prop-id-trailing-comma.js | 61 ++++++++++ .../statements/function/dstr/obj-ptrn-prop-id.js | 60 +++++++++ .../function/dstr/obj-ptrn-prop-obj-init.js | 66 ++++++++++ .../function/dstr/obj-ptrn-prop-obj-value-null.js | 56 +++++++++ .../function/dstr/obj-ptrn-prop-obj-value-undef.js | 56 +++++++++ .../statements/function/dstr/obj-ptrn-prop-obj.js | 64 ++++++++++ .../function/dstr/obj-ptrn-rest-getter.js | 59 +++++++++ .../dstr/obj-ptrn-rest-skip-non-enumerable.js | 67 +++++++++++ .../function/dstr/obj-ptrn-rest-val-obj.js | 66 ++++++++++ .../language/statements/function/dstr/shell.js | 0 .../statements/function/early-body-super-call.js | 19 +++ .../statements/function/early-body-super-prop.js | 19 +++ .../statements/function/early-errors/browser.js | 0 .../invalid-names-call-expression-bad-reference.js | 41 +++++++ .../invalid-names-call-expression-this.js | 41 +++++++ ...nvalid-names-member-expression-bad-reference.js | 41 +++++++ .../invalid-names-member-expression-this.js | 41 +++++++ .../statements/function/early-errors/shell.js | 0 .../statements/function/early-params-super-call.js | 17 +++ .../statements/function/early-params-super-prop.js | 17 +++ .../statements/function/enable-strict-via-body.js | 27 +++++ .../function/enable-strict-via-outer-body.js | 27 +++++ .../enable-strict-via-outer-script-strict.js | 27 +++++ .../function/eval-var-scope-syntax-err.js | 59 +++++++++ .../function/forbidden-ext/b1/browser.js | 0 ...h-forbidden-ext-direct-access-prop-arguments.js | 35 ++++++ ...meth-forbidden-ext-direct-access-prop-caller.js | 35 ++++++ .../statements/function/forbidden-ext/b1/shell.js | 0 .../function/forbidden-ext/b2/browser.js | 0 ...dden-ext-indirect-access-own-prop-caller-get.js | 61 ++++++++++ ...en-ext-indirect-access-own-prop-caller-value.js | 61 ++++++++++ ...cl-forbidden-ext-indirect-access-prop-caller.js | 61 ++++++++++ .../statements/function/forbidden-ext/b2/shell.js | 0 .../statements/function/forbidden-ext/browser.js | 0 .../statements/function/forbidden-ext/shell.js | 0 .../statements/function/invalid-2-names.js | 17 +++ .../statements/function/invalid-3-names.js | 17 +++ .../statements/function/invalid-function-body-1.js | 18 +++ .../statements/function/invalid-function-body-2.js | 18 +++ .../statements/function/invalid-function-body-3.js | 18 +++ .../statements/function/invalid-name-dot.js | 17 +++ .../statements/function/invalid-name-two-dots.js | 17 +++ .../language/statements/function/length-dflt.js | 62 ++++++++++ .../statements/function/line-terminator.js | 50 ++++++++ .../function/name-arguments-non-strict.js | 14 +++ .../function/name-arguments-strict-body.js | 19 +++ .../function/name-arguments-strict-strict.js | 19 +++ .../statements/function/name-eval-non-strict.js | 14 +++ .../statements/function/name-eval-strict-body.js | 19 +++ .../statements/function/name-eval-strict-strict.js | 19 +++ .../statements/function/name-eval-stricteval.js | 17 +++ .../language/statements/function/name-unicode.js | 20 +++ .../test262/language/statements/function/name.js | 26 ++++ .../object-destructuring-param-strict-body.js | 134 +++++++++++++++++++++ .../function/param-arguments-non-strict.js | 14 +++ .../function/param-arguments-strict-body.js | 23 ++++ .../function/param-arguments-strict-strict.js | 24 ++++ .../function/param-dflt-yield-non-strict.js | 31 +++++ .../function/param-dflt-yield-strict-strict.js | 27 +++++ .../function/param-duplicated-non-strict.js | 14 +++ .../function/param-duplicated-strict-1-strict.js | 24 ++++ .../function/param-duplicated-strict-2-strict.js | 25 ++++ .../function/param-duplicated-strict-3-strict.js | 24 ++++ .../function/param-duplicated-strict-body-1.js | 23 ++++ .../function/param-duplicated-strict-body-2.js | 24 ++++ .../function/param-duplicated-strict-body-3.js | 23 ++++ .../param-eval-non-strict-is-correct-value.js | 23 ++++ .../statements/function/param-eval-non-strict.js | 14 +++ .../statements/function/param-eval-strict-body.js | 23 ++++ .../function/param-eval-strict-strict.js | 24 ++++ .../statements/function/param-eval-stricteval.js | 22 ++++ .../function/params-dflt-args-unmapped.js | 84 +++++++++++++ .../function/params-dflt-ref-arguments.js | 63 ++++++++++ .../function/params-trailing-comma-multiple.js | 61 ++++++++++ .../function/params-trailing-comma-single.js | 60 +++++++++ .../statements/function/rest-param-strict-body.js | 134 +++++++++++++++++++++ .../rest-params-trailing-comma-early-error.js | 59 +++++++++ .../statements/function/scope-body-lex-distinct.js | 55 +++++++++ .../function/scope-param-elem-var-close.js | 33 +++++ .../function/scope-param-elem-var-open.js | 31 +++++ .../function/scope-param-rest-elem-var-close.js | 31 +++++ .../function/scope-param-rest-elem-var-open.js | 31 +++++ .../function/scope-paramsbody-var-close.js | 37 ++++++ .../function/scope-paramsbody-var-open.js | 35 ++++++ .../test262/language/statements/function/shell.js | 0 .../function/static-init-await-binding-invalid.js | 28 +++++ .../function/static-init-await-binding-valid.js | 20 +++ .../function/unscopables-with-in-nested-fn.js | 104 ++++++++++++++++ .../statements/function/unscopables-with.js | 98 +++++++++++++++ .../function/use-strict-with-non-simple-param.js | 22 ++++ 463 files changed, 21216 insertions(+) create mode 100644 js/src/tests/test262/language/statements/function/13.0-12-s-strict.js create mode 100644 js/src/tests/test262/language/statements/function/13.0-13-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.0-14-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.0-15-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.0-16-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.0-17-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.0-7-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.0-8-s-strict.js create mode 100644 js/src/tests/test262/language/statements/function/13.0_4-17gs-strict.js create mode 100644 js/src/tests/test262/language/statements/function/13.0_4-5gs-strict.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-13gs-strict.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-19-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-1gs-strict.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-2-s-strict.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-21-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-22-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-23-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-25-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-27-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-29-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-31-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-33-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-39-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-4-s-strict.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-41-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-4gs-strict.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-5gs-strict.js create mode 100644 js/src/tests/test262/language/statements/function/13.1-8gs-strict.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-1-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-10-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-11-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-12-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-13-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-14-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-15-1.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-15-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-16-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-17-1.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-17-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-18-1.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-18-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-19-b-3gs-strict.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-19-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-2-s-strict.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-20-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-21-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-22-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-23-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-24-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-25-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-26-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-27-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-28-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-3-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-30-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-4-s-strict.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-5-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-6-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-7-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-8-s.js create mode 100644 js/src/tests/test262/language/statements/function/13.2-9-s.js create mode 100644 js/src/tests/test262/language/statements/function/S10.1.1_A1_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A1_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A4_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A4_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A4_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A4_T4.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A5_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A5_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A6_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A6_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A6_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A6_T4.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A7_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A7_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A7_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A7_T4.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A8_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A8_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A9.1_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A9.1_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A9_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.1_A9_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A10.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A11.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A12.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A13.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A14.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A15_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A15_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A15_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A15_T4.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A16_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A16_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A16_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A17_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A17_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A18_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A18_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A19_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A19_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A19_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A19_T4.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A19_T5.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A19_T6.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A19_T7.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A19_T8.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A1_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A1_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A3_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A3_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A4_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A4_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A5_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A5_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A6_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A6_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A7_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A7_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A8_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A8_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A8_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2.2_A9.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2_A1_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2_A1_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2_A2_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2_A2_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2_A3.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2_A4_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2_A4_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2_A5.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2_A6_T1-strict.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2_A6_T2-strict.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2_A7_T1-strict.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2_A7_T2-strict.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2_A8_T1-strict.js create mode 100644 js/src/tests/test262/language/statements/function/S13.2_A8_T2-strict.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A1.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A10.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A11_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A11_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A11_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A11_T4.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A12_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A12_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A13_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A13_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A13_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A14_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A15_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A15_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A15_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A15_T4.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A15_T5.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A17_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A17_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A18.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A19_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A19_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A2_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A2_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A2_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A3_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A3_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A3_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A4_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A4_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A4_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A4_T4.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A6_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A6_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A7_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A7_T3.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A8_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A8_T2.js create mode 100644 js/src/tests/test262/language/statements/function/S13_A9.js create mode 100644 js/src/tests/test262/language/statements/function/S14_A2.js create mode 100644 js/src/tests/test262/language/statements/function/S14_A3.js create mode 100644 js/src/tests/test262/language/statements/function/S14_A5_T1.js create mode 100644 js/src/tests/test262/language/statements/function/S14_A5_T2.js create mode 100644 js/src/tests/test262/language/statements/function/arguments-with-arguments-fn.js create mode 100644 js/src/tests/test262/language/statements/function/arguments-with-arguments-lex.js create mode 100644 js/src/tests/test262/language/statements/function/array-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/function/browser.js create mode 100644 js/src/tests/test262/language/statements/function/cptn-decl.js create mode 100644 js/src/tests/test262/language/statements/function/dflt-params-abrupt.js create mode 100644 js/src/tests/test262/language/statements/function/dflt-params-arg-val-not-undefined.js create mode 100644 js/src/tests/test262/language/statements/function/dflt-params-arg-val-undefined.js create mode 100644 js/src/tests/test262/language/statements/function/dflt-params-duplicates.js create mode 100644 js/src/tests/test262/language/statements/function/dflt-params-ref-later.js create mode 100644 js/src/tests/test262/language/statements/function/dflt-params-ref-prior.js create mode 100644 js/src/tests/test262/language/statements/function/dflt-params-ref-self.js create mode 100644 js/src/tests/test262/language/statements/function/dflt-params-rest.js create mode 100644 js/src/tests/test262/language/statements/function/dflt-params-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/browser.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/function/dstr/shell.js create mode 100644 js/src/tests/test262/language/statements/function/early-body-super-call.js create mode 100644 js/src/tests/test262/language/statements/function/early-body-super-prop.js create mode 100644 js/src/tests/test262/language/statements/function/early-errors/browser.js create mode 100644 js/src/tests/test262/language/statements/function/early-errors/invalid-names-call-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/function/early-errors/invalid-names-call-expression-this.js create mode 100644 js/src/tests/test262/language/statements/function/early-errors/invalid-names-member-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/function/early-errors/invalid-names-member-expression-this.js create mode 100644 js/src/tests/test262/language/statements/function/early-errors/shell.js create mode 100644 js/src/tests/test262/language/statements/function/early-params-super-call.js create mode 100644 js/src/tests/test262/language/statements/function/early-params-super-prop.js create mode 100644 js/src/tests/test262/language/statements/function/enable-strict-via-body.js create mode 100644 js/src/tests/test262/language/statements/function/enable-strict-via-outer-body.js create mode 100644 js/src/tests/test262/language/statements/function/enable-strict-via-outer-script-strict.js create mode 100644 js/src/tests/test262/language/statements/function/eval-var-scope-syntax-err.js create mode 100644 js/src/tests/test262/language/statements/function/forbidden-ext/b1/browser.js create mode 100644 js/src/tests/test262/language/statements/function/forbidden-ext/b1/cls-expr-meth-forbidden-ext-direct-access-prop-arguments.js create mode 100644 js/src/tests/test262/language/statements/function/forbidden-ext/b1/cls-expr-meth-forbidden-ext-direct-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/function/forbidden-ext/b1/shell.js create mode 100644 js/src/tests/test262/language/statements/function/forbidden-ext/b2/browser.js create mode 100644 js/src/tests/test262/language/statements/function/forbidden-ext/b2/func-decl-forbidden-ext-indirect-access-own-prop-caller-get.js create mode 100644 js/src/tests/test262/language/statements/function/forbidden-ext/b2/func-decl-forbidden-ext-indirect-access-own-prop-caller-value.js create mode 100644 js/src/tests/test262/language/statements/function/forbidden-ext/b2/func-decl-forbidden-ext-indirect-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/function/forbidden-ext/b2/shell.js create mode 100644 js/src/tests/test262/language/statements/function/forbidden-ext/browser.js create mode 100644 js/src/tests/test262/language/statements/function/forbidden-ext/shell.js create mode 100644 js/src/tests/test262/language/statements/function/invalid-2-names.js create mode 100644 js/src/tests/test262/language/statements/function/invalid-3-names.js create mode 100644 js/src/tests/test262/language/statements/function/invalid-function-body-1.js create mode 100644 js/src/tests/test262/language/statements/function/invalid-function-body-2.js create mode 100644 js/src/tests/test262/language/statements/function/invalid-function-body-3.js create mode 100644 js/src/tests/test262/language/statements/function/invalid-name-dot.js create mode 100644 js/src/tests/test262/language/statements/function/invalid-name-two-dots.js create mode 100644 js/src/tests/test262/language/statements/function/length-dflt.js create mode 100644 js/src/tests/test262/language/statements/function/line-terminator.js create mode 100644 js/src/tests/test262/language/statements/function/name-arguments-non-strict.js create mode 100644 js/src/tests/test262/language/statements/function/name-arguments-strict-body.js create mode 100644 js/src/tests/test262/language/statements/function/name-arguments-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/function/name-eval-non-strict.js create mode 100644 js/src/tests/test262/language/statements/function/name-eval-strict-body.js create mode 100644 js/src/tests/test262/language/statements/function/name-eval-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/function/name-eval-stricteval.js create mode 100644 js/src/tests/test262/language/statements/function/name-unicode.js create mode 100644 js/src/tests/test262/language/statements/function/name.js create mode 100644 js/src/tests/test262/language/statements/function/object-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/function/param-arguments-non-strict.js create mode 100644 js/src/tests/test262/language/statements/function/param-arguments-strict-body.js create mode 100644 js/src/tests/test262/language/statements/function/param-arguments-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/function/param-dflt-yield-non-strict.js create mode 100644 js/src/tests/test262/language/statements/function/param-dflt-yield-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/function/param-duplicated-non-strict.js create mode 100644 js/src/tests/test262/language/statements/function/param-duplicated-strict-1-strict.js create mode 100644 js/src/tests/test262/language/statements/function/param-duplicated-strict-2-strict.js create mode 100644 js/src/tests/test262/language/statements/function/param-duplicated-strict-3-strict.js create mode 100644 js/src/tests/test262/language/statements/function/param-duplicated-strict-body-1.js create mode 100644 js/src/tests/test262/language/statements/function/param-duplicated-strict-body-2.js create mode 100644 js/src/tests/test262/language/statements/function/param-duplicated-strict-body-3.js create mode 100644 js/src/tests/test262/language/statements/function/param-eval-non-strict-is-correct-value.js create mode 100644 js/src/tests/test262/language/statements/function/param-eval-non-strict.js create mode 100644 js/src/tests/test262/language/statements/function/param-eval-strict-body.js create mode 100644 js/src/tests/test262/language/statements/function/param-eval-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/function/param-eval-stricteval.js create mode 100644 js/src/tests/test262/language/statements/function/params-dflt-args-unmapped.js create mode 100644 js/src/tests/test262/language/statements/function/params-dflt-ref-arguments.js create mode 100644 js/src/tests/test262/language/statements/function/params-trailing-comma-multiple.js create mode 100644 js/src/tests/test262/language/statements/function/params-trailing-comma-single.js create mode 100644 js/src/tests/test262/language/statements/function/rest-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/function/rest-params-trailing-comma-early-error.js create mode 100644 js/src/tests/test262/language/statements/function/scope-body-lex-distinct.js create mode 100644 js/src/tests/test262/language/statements/function/scope-param-elem-var-close.js create mode 100644 js/src/tests/test262/language/statements/function/scope-param-elem-var-open.js create mode 100644 js/src/tests/test262/language/statements/function/scope-param-rest-elem-var-close.js create mode 100644 js/src/tests/test262/language/statements/function/scope-param-rest-elem-var-open.js create mode 100644 js/src/tests/test262/language/statements/function/scope-paramsbody-var-close.js create mode 100644 js/src/tests/test262/language/statements/function/scope-paramsbody-var-open.js create mode 100644 js/src/tests/test262/language/statements/function/shell.js create mode 100644 js/src/tests/test262/language/statements/function/static-init-await-binding-invalid.js create mode 100644 js/src/tests/test262/language/statements/function/static-init-await-binding-valid.js create mode 100644 js/src/tests/test262/language/statements/function/unscopables-with-in-nested-fn.js create mode 100644 js/src/tests/test262/language/statements/function/unscopables-with.js create mode 100644 js/src/tests/test262/language/statements/function/use-strict-with-non-simple-param.js (limited to 'js/src/tests/test262/language/statements/function') diff --git a/js/src/tests/test262/language/statements/function/13.0-12-s-strict.js b/js/src/tests/test262/language/statements/function/13.0-12-s-strict.js new file mode 100644 index 0000000000..689b521ee8 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.0-12-s-strict.js @@ -0,0 +1,20 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13; + The production FunctionBody : SourceElementsopt is evaluated as follows: +es5id: 13.0-12-s +description: > + Strict Mode - SourceElements is not evaluated as strict mode code + when a Function constructor is contained in strict mode code and + the function constructor body is not strict +flags: [onlyStrict] +---*/ + + var _13_0_12_fun = new Function(" ","eval = 42;"); + _13_0_12_fun(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.0-13-s.js b/js/src/tests/test262/language/statements/function/13.0-13-s.js new file mode 100644 index 0000000000..373cc10b3c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.0-13-s.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: | + Refer 13; + The production FunctionBody : SourceElementsopt is evaluated as follows: +es5id: 13.0-13-s +description: > + Strict Mode - SourceElements is evaluated as strict mode code when + the function body of a Function constructor begins with a Strict + Directive +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("var _13_0_13_fun = new Function(\" \", \"'use strict'; eval = 42;\"); _13_0_13_fun();"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.0-14-s.js b/js/src/tests/test262/language/statements/function/13.0-14-s.js new file mode 100644 index 0000000000..f9451634a7 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.0-14-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. + +/*--- +info: | + Refer 13; + The production FunctionBody : SourceElementsopt is evaluated as follows: +es5id: 13.0-14-s +description: > + Strict Mode - SourceElements is evaluated as strict mode code when + the function body of a Function constructor contains a Strict + Directive +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + var _13_0_14_fun = new Function(" ", "'use strict'; eval = 42; "); + _13_0_14_fun(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.0-15-s.js b/js/src/tests/test262/language/statements/function/13.0-15-s.js new file mode 100644 index 0000000000..d05e197a71 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.0-15-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. + +/*--- +info: | + Refer 13; + The production FunctionBody : SourceElementsopt is evaluated as follows: +es5id: 13.0-15-s +description: > + Strict Mode - SourceElements is evaluated as strict mode code when + a FunctionDeclaration is contained in strict mode code within eval + code +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("'use strict'; function _13_0_15_fun() {eval = 42;};"); + _13_0_15_fun(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.0-16-s.js b/js/src/tests/test262/language/statements/function/13.0-16-s.js new file mode 100644 index 0000000000..3d6c287da4 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.0-16-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. + +/*--- +info: | + Refer 13; + The production FunctionBody : SourceElementsopt is evaluated as follows: +es5id: 13.0-16-s +description: > + Strict Mode - SourceElements is evaluated as strict mode code when + a FunctionExpression is contained in strict mode code within eval + code +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("'use strict'; var _13_0_16_fun = function () {eval = 42;};"); + _13_0_16_fun(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.0-17-s.js b/js/src/tests/test262/language/statements/function/13.0-17-s.js new file mode 100644 index 0000000000..8049390a5a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.0-17-s.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. + +/*--- +info: | + Refer 13; + The production FunctionBody : SourceElementsopt is evaluated as follows: +es5id: 13.0-17-s +description: > + Strict Mode - SourceElements is not evaluated as strict mode code + when a Function constructor is contained in strict mode code + within eval code +flags: [noStrict] +---*/ + + eval("'use strict'; var _13_0_17_fun = new Function('eval = 42;'); _13_0_17_fun();"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.0-7-s.js b/js/src/tests/test262/language/statements/function/13.0-7-s.js new file mode 100644 index 0000000000..88175ea2a1 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.0-7-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. + +/*--- +info: | + Refer 13; + The production FunctionBody : SourceElementsopt is evaluated as follows: +es5id: 13.0-7-s +description: > + Strict Mode - SourceElements is evaluated as strict mode code when + the code of this FunctionDeclaration is contained in non-strict + mode but the call to eval is a direct call in strict mode code +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("'use strict'; function _13_0_7_fun() {eval = 42;};"); + _13_0_7_fun(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.0-8-s-strict.js b/js/src/tests/test262/language/statements/function/13.0-8-s-strict.js new file mode 100644 index 0000000000..1fad80b14d --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.0-8-s-strict.js @@ -0,0 +1,22 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13; + The production FunctionBody : SourceElementsopt is evaluated as follows: +es5id: 13.0-8-s +description: > + Strict Mode - SourceElements is evaluated as strict mode code when + the code of this FunctionExpression is contained in non-strict + mode but the call to eval is a direct call in strict mode code +flags: [onlyStrict] +---*/ + +assert.throws(SyntaxError, function() { + eval("var _13_0_8_fun = function () {eval = 42;};"); + _13_0_8_fun(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.0_4-17gs-strict.js b/js/src/tests/test262/language/statements/function/13.0_4-17gs-strict.js new file mode 100644 index 0000000000..903001cf8b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.0_4-17gs-strict.js @@ -0,0 +1,15 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.0_4-17gs +description: > + Strict Mode - SourceElements is not evaluated as strict mode code + when a Function constructor is contained in strict mode code +flags: [onlyStrict] +---*/ + +var _13_0_4_17_fun = new Function('eval = 42;'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.0_4-5gs-strict.js b/js/src/tests/test262/language/statements/function/13.0_4-5gs-strict.js new file mode 100644 index 0000000000..c0017683fa --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.0_4-5gs-strict.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.0_4-5gs +description: > + Strict Mode - SourceElements is evaluated as strict mode code when + a FunctionDeclaration is contained in strict mode code +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_0_4_5_fun() { eval = 42; }; diff --git a/js/src/tests/test262/language/statements/function/13.1-13gs-strict.js b/js/src/tests/test262/language/statements/function/13.1-13gs-strict.js new file mode 100644 index 0000000000..be377cfcfc --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-13gs-strict.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.1-13gs +description: > + StrictMode - SyntaxError is thrown if 'arguments' occurs as the + Identifier of a FunctionDeclaration +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +function arguments() { }; diff --git a/js/src/tests/test262/language/statements/function/13.1-19-s.js b/js/src/tests/test262/language/statements/function/13.1-19-s.js new file mode 100644 index 0000000000..bdac2fef4d --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-19-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. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs within a FormalParameterList + of a strict mode FunctionDeclaration or FunctionExpression. +es5id: 13.1-19-s +description: > + Strict Mode - SyntaxError is thrown if the identifier 'arguments' + appears within a FormalParameterList of a strict mode + FunctionDeclaration in strict eval code +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("'use strict';function _13_1_19_fun(arguments) { }"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.1-1gs-strict.js b/js/src/tests/test262/language/statements/function/13.1-1gs-strict.js new file mode 100644 index 0000000000..f376748867 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-1gs-strict.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.1-1gs +description: > + Strict Mode - SyntaxError is thrown if the identifier 'eval' + appears within a FormalParameterList of a strict mode + FunctionDeclaration +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_1_1_fun(eval) { } diff --git a/js/src/tests/test262/language/statements/function/13.1-2-s-strict.js b/js/src/tests/test262/language/statements/function/13.1-2-s-strict.js new file mode 100644 index 0000000000..d7869bec7f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-2-s-strict.js @@ -0,0 +1,23 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs within a FormalParameterList + of a strict mode FunctionDeclaration or FunctionExpression. +es5id: 13.1-2-s +description: > + Strict Mode - SyntaxError is thrown if the identifier 'eval' + appears within a FormalParameterList of a strict mode + FunctionExpression +flags: [onlyStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("var _13_1_2_fun = function (eval) { }"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.1-21-s.js b/js/src/tests/test262/language/statements/function/13.1-21-s.js new file mode 100644 index 0000000000..2c28c9b494 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-21-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. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs within a FormalParameterList + of a strict mode FunctionDeclaration or FunctionExpression. +es5id: 13.1-21-s +description: > + StrictMode - SyntaxError is thrown if the identifier 'arguments' + appears within a FormalParameterList of a strict mode + FunctionExpression in strict eval code +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("'use strict'; var _13_1_21_fun = function (arguments) { }"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.1-22-s.js b/js/src/tests/test262/language/statements/function/13.1-22-s.js new file mode 100644 index 0000000000..33798b6bac --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-22-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. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs within a FormalParameterList + of a strict mode FunctionDeclaration or FunctionExpression. +es5id: 13.1-22-s +description: > + StrictMode - SyntaxError is thrown if the identifier 'arguments' + appears within a FormalParameterList of a strict mode + FunctionExpression when FuctionBody is strict code +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("var _13_1_22_fun = function (arguments) { 'use strict'; }"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.1-23-s.js b/js/src/tests/test262/language/statements/function/13.1-23-s.js new file mode 100644 index 0000000000..9cb04206cc --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-23-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. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if any Identifier value occurs more than once within a FormalParameterList of a strict mode + FunctionDeclaration or FunctionExpression. +es5id: 13.1-23-s +description: > + Strict Mode - SyntaxError is thrown if a function is created using + a FunctionDeclaration that is contained in eval strict code and + the function has two identical parameters +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("'use strict'; function _13_1_23_fun(param, param) { }"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.1-25-s.js b/js/src/tests/test262/language/statements/function/13.1-25-s.js new file mode 100644 index 0000000000..a3cb436482 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-25-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. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if any Identifier value occurs more than once within a FormalParameterList of a strict mode + FunctionDeclaration or FunctionExpression. +es5id: 13.1-25-s +description: > + Strict Mode - SyntaxError is thrown if a function is created using + a FunctionDeclaration that is contained in eval strict code and + the function has two identical parameters which are separated by a + unique parameter name +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("'use strict'; function _13_1_25_fun(param1, param2, param1) { }"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.1-27-s.js b/js/src/tests/test262/language/statements/function/13.1-27-s.js new file mode 100644 index 0000000000..9662c3f550 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-27-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. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if any Identifier value occurs more than once within a FormalParameterList of a strict mode + FunctionDeclaration or FunctionExpression. +es5id: 13.1-27-s +description: > + Strict Mode - SyntaxError is thrown if a function is created using + a FunctionDeclaration that is contained in eval strict code and + the function has three identical parameters +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("'use strict'; function _13_1_27_fun(param, param, param) { }"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.1-29-s.js b/js/src/tests/test262/language/statements/function/13.1-29-s.js new file mode 100644 index 0000000000..809c463902 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-29-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. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if any Identifier value occurs more than once within a FormalParameterList of a strict mode + FunctionDeclaration or FunctionExpression. +es5id: 13.1-29-s +description: > + Strict Mode - SyntaxError is thrown if a function is created using + a FunctionExpression that is contained in eval strict code and the + function has two identical parameters +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("'use strict'; var _13_1_29_fun = function (param, param) { };"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.1-31-s.js b/js/src/tests/test262/language/statements/function/13.1-31-s.js new file mode 100644 index 0000000000..8fdecb495a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-31-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. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if any Identifier value occurs more than once within a FormalParameterList of a strict mode + FunctionDeclaration or FunctionExpression. +es5id: 13.1-31-s +description: > + Strict Mode - SyntaxError is thrown if a function is created using + a FunctionExpression that is contained in eval strict code and the + function has two identical parameters, which are separated by a + unique parameter name +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("'use strict'; var _13_1_31_fun = function (param1, param2, param1) { };"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.1-33-s.js b/js/src/tests/test262/language/statements/function/13.1-33-s.js new file mode 100644 index 0000000000..a99e51d68c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-33-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. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if any Identifier value occurs more than once within a FormalParameterList of a strict mode + FunctionDeclaration or FunctionExpression. +es5id: 13.1-33-s +description: > + Strict Mode - SyntaxError is thrown if function is created using a + FunctionExpression that is contained in eval strict code and the + function has three identical parameters +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("'use strict'; var _13_1_33_fun = function (param, param, param) { };") +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.1-39-s.js b/js/src/tests/test262/language/statements/function/13.1-39-s.js new file mode 100644 index 0000000000..066a4b8695 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-39-s.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. + +/*--- +es5id: 13.1-39-s +description: > + StrictMode - SyntaxError is thrown if 'arguments' occurs as the + function name of a FunctionDeclaration in strict eval code +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("'use strict'; function arguments() { };") +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.1-4-s-strict.js b/js/src/tests/test262/language/statements/function/13.1-4-s-strict.js new file mode 100644 index 0000000000..df8c40f7bf --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-4-s-strict.js @@ -0,0 +1,23 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs within a FormalParameterList + of a strict mode FunctionDeclaration or FunctionExpression. +es5id: 13.1-4-s +description: > + Strict Mode - SyntaxError is thrown if the identifier 'arguments' + appears within a FormalParameterList of a strict mode + FunctionExpression +flags: [onlyStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("var _13_1_4_fun = function (arguments) { };"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.1-41-s.js b/js/src/tests/test262/language/statements/function/13.1-41-s.js new file mode 100644 index 0000000000..9e0d146af7 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-41-s.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. + +/*--- +es5id: 13.1-41-s +description: > + StrictMode - SyntaxError is thrown if 'arguments' occurs as the + Identifier of a FunctionExpression in strict eval code +flags: [noStrict] +---*/ + + var _13_1_41_s = {}; +assert.throws(SyntaxError, function() { + eval("'use strict'; _13_1_41_s.x = function arguments() {};"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.1-4gs-strict.js b/js/src/tests/test262/language/statements/function/13.1-4gs-strict.js new file mode 100644 index 0000000000..d797a5b9cd --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-4gs-strict.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.1-4gs +description: > + Strict Mode - SyntaxError is thrown if the identifier 'arguments' + appears within a FormalParameterList of a strict mode + FunctionExpression +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +var _13_1_4_fun = function (arguments) { }; diff --git a/js/src/tests/test262/language/statements/function/13.1-5gs-strict.js b/js/src/tests/test262/language/statements/function/13.1-5gs-strict.js new file mode 100644 index 0000000000..afe138f50c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-5gs-strict.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.1-5gs +description: > + Strict Mode - SyntaxError is thrown if a FunctionDeclaration has + two identical parameters +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_1_5_fun(param, param) { } diff --git a/js/src/tests/test262/language/statements/function/13.1-8gs-strict.js b/js/src/tests/test262/language/statements/function/13.1-8gs-strict.js new file mode 100644 index 0000000000..c378ad1c2b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.1-8gs-strict.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.1-8gs +description: > + Strict Mode - SyntaxError is thrown if a FunctionExpression has + two identical parameters +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +var _13_1_8_fun = function (param, param) { }; diff --git a/js/src/tests/test262/language/statements/function/13.2-1-s.js b/js/src/tests/test262/language/statements/function/13.2-1-s.js new file mode 100644 index 0000000000..47729a26ca --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-1-s.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. + +/*--- +es5id: 13.2-1-s +description: > + StrictMode - Writing or reading from a property named 'caller' of + function objects is allowed under both strict and normal modes. +---*/ + + var foo = function () { + this.caller = 12; + } + var obj = new foo(); + +assert.sameValue(obj.caller, 12, 'obj.caller'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-10-s.js b/js/src/tests/test262/language/statements/function/13.2-10-s.js new file mode 100644 index 0000000000..51ebae59bb --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-10-s.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: 13.2-10-s +description: > + StrictMode - writing a property named 'caller' of function objects + is not allowed outside the function +---*/ + + var foo = Function("'use strict';"); +assert.throws(TypeError, function() { + foo.caller = 41; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-11-s.js b/js/src/tests/test262/language/statements/function/13.2-11-s.js new file mode 100644 index 0000000000..c3c30fa6c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-11-s.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. + +/*--- +es5id: 13.2-11-s +description: > + StrictMode - enumerating over a function object looking for + 'caller' fails outside of the function +---*/ + + var foo = Function("'use strict';"); + + for (var tempIndex in foo) { + assert.notSameValue(tempIndex, "caller", 'tempIndex'); + } + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-12-s.js b/js/src/tests/test262/language/statements/function/13.2-12-s.js new file mode 100644 index 0000000000..c31b97e710 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-12-s.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: 13.2-12-s +description: > + StrictMode - enumerating over a function object looking for + 'caller' fails inside the function +---*/ + + var foo = Function("'use strict'; for (var tempIndex in this) {assert.notSameValue(tempIndex, 'caller', 'tempIndex');}"); + foo.call(foo); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-13-s.js b/js/src/tests/test262/language/statements/function/13.2-13-s.js new file mode 100644 index 0000000000..b809fa2939 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-13-s.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: 13.2-13-s +description: > + StrictMode - reading a property named 'arguments' of function + objects is not allowed outside the function +---*/ + + var foo = new Function("'use strict';"); +assert.throws(TypeError, function() { + var temp = foo.arguments; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-14-s.js b/js/src/tests/test262/language/statements/function/13.2-14-s.js new file mode 100644 index 0000000000..401e8f5b88 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-14-s.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: 13.2-14-s +description: > + StrictMode - writing a property named 'arguments' of function + objects is not allowed outside the function +---*/ + + var foo = new Function("'use strict';"); +assert.throws(TypeError, function() { + foo.arguments = 41; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-15-1.js b/js/src/tests/test262/language/statements/function/13.2-15-1.js new file mode 100644 index 0000000000..b70d843dd1 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-15-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. + +/*--- +es5id: 13.2-15-1 +description: > + Function Object has length as its own property and does not invoke + the setter defined on Function.prototype.length (Step 15) +includes: [propertyHelper.js] +---*/ + +var fun = function (x, y) { }; + +assert(fun.hasOwnProperty("length")); +assert.sameValue(fun.length, 2); + +verifyNotEnumerable(fun, "length"); +verifyNotWritable(fun, "length"); +verifyConfigurable(fun, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-15-s.js b/js/src/tests/test262/language/statements/function/13.2-15-s.js new file mode 100644 index 0000000000..d4242f0104 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-15-s.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. + +/*--- +es5id: 13.2-15-s +description: > + StrictMode - enumerating over a function object looking for + 'arguments' fails outside of the function +---*/ + + var foo = new Function("'use strict';"); + + for (var tempIndex in foo) { + assert.notSameValue(tempIndex, "arguments", 'tempIndex'); + } + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-16-s.js b/js/src/tests/test262/language/statements/function/13.2-16-s.js new file mode 100644 index 0000000000..befc8af88f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-16-s.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: 13.2-16-s +description: > + StrictMode - enumerating over a function object looking for + 'arguments' fails inside the function +---*/ + + var foo = new Function("'use strict'; for (var tempIndex in this) {assert.notSameValue(tempIndex, 'arguments', 'tempIndex');}"); + foo.call(foo); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-17-1.js b/js/src/tests/test262/language/statements/function/13.2-17-1.js new file mode 100644 index 0000000000..bed00f4e65 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-17-1.js @@ -0,0 +1,55 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.2-17-1 +description: > + Function Object has 'constructor' as its own property, it is not + enumerable and does not invoke the setter defined on + Function.prototype.constructor (Step 17) +---*/ + + var desc = Object.getOwnPropertyDescriptor(Object.prototype, "constructor"); + + var getFunc = function () { + return 100; + }; + + var data = "data"; + var setFunc = function (value) { + data = value; + }; + + Object.defineProperty(Object.prototype, "constructor", { + get: getFunc, + set: setFunc, + configurable: true + }); + + var fun = function () {}; + + var verifyValue = false; + verifyValue = typeof fun.prototype.constructor === "function"; + + var verifyEnumerable = false; + for (var p in fun.prototype) { + if (p === "constructor" && fun.prototype.hasOwnProperty("constructor")) { + verifyEnumerable = true; + } + } + + var verifyWritable = false; + fun.prototype.constructor = 12; + verifyWritable = (fun.prototype.constructor === 12); + + var verifyConfigurable = false; + delete fun.prototype.constructor; + verifyConfigurable = fun.hasOwnProperty("constructor"); + +assert(verifyValue, 'verifyValue !== true'); +assert(verifyWritable, 'verifyWritable !== true'); +assert.sameValue(verifyEnumerable, false, 'verifyEnumerable'); +assert.sameValue(verifyConfigurable, false, 'verifyConfigurable'); +assert.sameValue(data, "data", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-17-s.js b/js/src/tests/test262/language/statements/function/13.2-17-s.js new file mode 100644 index 0000000000..085f40f6dc --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-17-s.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: 13.2-17-s +description: > + StrictMode - reading a property named 'arguments' of function + objects is not allowed outside the function +---*/ + + var foo = Function("'use strict';"); +assert.throws(TypeError, function() { + var temp = foo.arguments; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-18-1.js b/js/src/tests/test262/language/statements/function/13.2-18-1.js new file mode 100644 index 0000000000..f03cc05137 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-18-1.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. + +/*--- +es5id: 13.2-18-1 +description: > + Function Object has 'prototype' as its own property, it is not + enumerable and does not invoke the setter defined on + Function.prototype (Step 18) +includes: [propertyHelper.js] +---*/ + +try { + var getFunc = function () { + return 100; + }; + + var data = "data"; + var setFunc = function (value) { + data = value; + }; + Object.defineProperty(Function.prototype, "prototype", { + get: getFunc, + set: setFunc, + configurable: true + }); + + var fun = function () { }; + + assert.notSameValue(fun.prototype, 100); + assert.sameValue(fun.prototype.toString(), "[object Object]"); + + verifyNotEnumerable(fun, "prototype"); + verifyWritable(fun, "prototype"); + verifyNotConfigurable(fun, "prototype"); + + assert.sameValue(data, "data"); +} finally { + delete Function.prototype.prototype; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-18-s.js b/js/src/tests/test262/language/statements/function/13.2-18-s.js new file mode 100644 index 0000000000..2c7c625874 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-18-s.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: 13.2-18-s +description: > + StrictMode - writing a property named 'arguments' of function + objects is not allowed outside the function +---*/ + + var foo = Function("'use strict';"); +assert.throws(TypeError, function() { + foo.arguments = 41; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-19-b-3gs-strict.js b/js/src/tests/test262/language/statements/function/13.2-19-b-3gs-strict.js new file mode 100644 index 0000000000..5890e2be96 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-19-b-3gs-strict.js @@ -0,0 +1,19 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.2-19-b-3gs +description: > + StrictMode - error is thrown when assign a value to the 'caller' + property of a function object +flags: [onlyStrict] +---*/ + +function _13_2_19_b_3_gs() {} + +assert.throws(TypeError, function() { + _13_2_19_b_3_gs.caller = 1; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-19-s.js b/js/src/tests/test262/language/statements/function/13.2-19-s.js new file mode 100644 index 0000000000..8ba75c3f1c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-19-s.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. + +/*--- +es5id: 13.2-19-s +description: > + StrictMode - enumerating over a function object looking for + 'arguments' fails outside of the function +---*/ + + var foo = Function("'use strict';"); + + for (var tempIndex in foo) { + assert.notSameValue(tempIndex, "arguments", 'tempIndex'); + } + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-2-s-strict.js b/js/src/tests/test262/language/statements/function/13.2-2-s-strict.js new file mode 100644 index 0000000000..d88c22ad07 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-2-s-strict.js @@ -0,0 +1,20 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.2-2-s +description: > + StrictMode - A TypeError is thrown when a strict mode code writes + to properties named 'caller' of function instances. +flags: [onlyStrict] +---*/ + + +assert.throws(TypeError, function() { + var foo = function () { + } + foo.caller = 20; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-20-s.js b/js/src/tests/test262/language/statements/function/13.2-20-s.js new file mode 100644 index 0000000000..1bc7826598 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-20-s.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. + +/*--- +es5id: 13.2-20-s +description: > + StrictMode - enumerating over a function object looking for + 'arguments' fails inside the function +flags: [noStrict] +---*/ + + var foo = Function("'use strict'; for (var tempIndex in this) {assert.notSameValue(tempIndex, 'arguments', 'tempIndex');}"); + foo.call(foo); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-21-s.js b/js/src/tests/test262/language/statements/function/13.2-21-s.js new file mode 100644 index 0000000000..847fc8cbd9 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-21-s.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. + +/*--- +es5id: 13.2-21-s +description: > + StrictMode - reading a property named 'caller' of function objects + is not allowed outside the function +flags: [noStrict] +---*/ + + function foo () {"use strict";} +assert.throws(TypeError, function() { + var temp = foo.caller; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-22-s.js b/js/src/tests/test262/language/statements/function/13.2-22-s.js new file mode 100644 index 0000000000..179ccd960c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-22-s.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. + +/*--- +es5id: 13.2-22-s +description: > + StrictMode - writing a property named 'caller' of function objects + is not allowed outside the function +flags: [noStrict] +---*/ + + function foo () {"use strict";} +assert.throws(TypeError, function() { + foo.caller = 41; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-23-s.js b/js/src/tests/test262/language/statements/function/13.2-23-s.js new file mode 100644 index 0000000000..3ae25bb462 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-23-s.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. + +/*--- +es5id: 13.2-23-s +description: > + StrictMode - enumerating over a function object looking for + 'caller' fails outside of the function +flags: [noStrict] +---*/ + + function foo () {"use strict";} + for (var tempIndex in foo) { + assert.notSameValue(tempIndex, "caller", 'tempIndex'); + } + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-24-s.js b/js/src/tests/test262/language/statements/function/13.2-24-s.js new file mode 100644 index 0000000000..c5f4695b08 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-24-s.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. + +/*--- +es5id: 13.2-24-s +description: > + StrictMode - enumerating over a function object looking for + 'caller' fails inside the function +flags: [noStrict] +---*/ + + function foo () { + "use strict"; + for (var tempIndex in this) { + assert.notSameValue(tempIndex, "caller", 'tempIndex'); + } + } + +foo.call(foo); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-25-s.js b/js/src/tests/test262/language/statements/function/13.2-25-s.js new file mode 100644 index 0000000000..44a7343aa6 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-25-s.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. + +/*--- +es5id: 13.2-25-s +description: > + StrictMode - reading a property named 'arguments' of function + objects is not allowed outside the function +flags: [noStrict] +---*/ + + function foo () {"use strict";} +assert.throws(TypeError, function() { + var temp = foo.arguments; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-26-s.js b/js/src/tests/test262/language/statements/function/13.2-26-s.js new file mode 100644 index 0000000000..e6ea555aa7 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-26-s.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. + +/*--- +es5id: 13.2-26-s +description: > + StrictMode - writing a property named 'arguments' of function + objects is not allowed outside the function +flags: [noStrict] +---*/ + + function foo () {"use strict";} +assert.throws(TypeError, function() { + foo.arguments = 41; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-27-s.js b/js/src/tests/test262/language/statements/function/13.2-27-s.js new file mode 100644 index 0000000000..df1be54766 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-27-s.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. + +/*--- +es5id: 13.2-27-s +description: > + StrictMode - enumerating over a function object looking for + 'arguments' fails outside of the function +flags: [noStrict] +---*/ + + function foo () {"use strict";} + + for (var tempIndex in foo) { + assert.notSameValue(tempIndex, "arguments", 'tempIndex'); + } + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-28-s.js b/js/src/tests/test262/language/statements/function/13.2-28-s.js new file mode 100644 index 0000000000..ea9f57b27e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-28-s.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. + +/*--- +es5id: 13.2-28-s +description: > + StrictMode - enumerating over a function object looking for + 'arguments' fails inside the function +flags: [noStrict] +---*/ + + function foo() { + "use strict"; + for (var tempIndex in this) { + assert.notSameValue(tempIndex, "arguments", 'tempIndex'); + } + } + foo.call(foo); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-3-s.js b/js/src/tests/test262/language/statements/function/13.2-3-s.js new file mode 100644 index 0000000000..e078018a03 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-3-s.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. + +/*--- +es5id: 13.2-3-s +description: > + StrictMode - Writing or reading from a property named 'arguments' + of function objects is allowed under both strict and normal modes. +---*/ + + var foo = function () { + this.arguments = 12; + } + var obj = new foo(); + +assert.sameValue(obj.arguments, 12, 'obj.arguments'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-30-s.js b/js/src/tests/test262/language/statements/function/13.2-30-s.js new file mode 100644 index 0000000000..029581a04e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-30-s.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 Caitlin Potter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + Functions created using Function.prototype.bind() do not have own + properties "caller" or "arguments", but inherit them from + %FunctionPrototype%. +---*/ + +function target() {} +var self = {}; +var bound = target.bind(self); + +assert.sameValue(bound.hasOwnProperty('caller'), false, 'Functions created using Function.prototype.bind() do not have own property "caller"'); +assert.sameValue(bound.hasOwnProperty('arguments'), false, 'Functions created using Function.prototype.bind() do not have own property "arguments"'); + +assert.throws(TypeError, function() { + return bound.caller; +}); + +assert.throws(TypeError, function() { + bound.caller = {}; +}); + +assert.throws(TypeError, function() { + return bound.arguments; +}); + +assert.throws(TypeError, function() { + bound.arguments = {}; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-4-s-strict.js b/js/src/tests/test262/language/statements/function/13.2-4-s-strict.js new file mode 100644 index 0000000000..94b7f191a9 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-4-s-strict.js @@ -0,0 +1,20 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.2-4-s +description: > + StrictMode - A TypeError is thrown when a code in strict mode + tries to write to 'arguments' of function instances. +flags: [onlyStrict] +---*/ + + +assert.throws(TypeError, function() { + var foo = function () { + } + foo.arguments = 20; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-5-s.js b/js/src/tests/test262/language/statements/function/13.2-5-s.js new file mode 100644 index 0000000000..48733cc5b6 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-5-s.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. + +/*--- +es5id: 13.2-5-s +description: > + StrictMode - reading a property named 'caller' of function objects + is not allowed outside the function +flags: [noStrict] +---*/ + + var foo = new Function("'use strict';"); +assert.throws(TypeError, function() { + var temp = foo.caller; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-6-s.js b/js/src/tests/test262/language/statements/function/13.2-6-s.js new file mode 100644 index 0000000000..c688a5f2d2 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-6-s.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. + +/*--- +es5id: 13.2-6-s +description: > + StrictMode - writing a property named 'caller' of function objects + is not allowed outside the function +flags: [noStrict] +---*/ + + var foo = new Function("'use strict';"); +assert.throws(TypeError, function() { + foo.caller = 41; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-7-s.js b/js/src/tests/test262/language/statements/function/13.2-7-s.js new file mode 100644 index 0000000000..59f3aecae3 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-7-s.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. + +/*--- +es5id: 13.2-7-s +description: > + StrictMode - enumerating over a function object looking for + 'caller' fails outside of the function +flags: [noStrict] +---*/ + + var foo = new Function("'use strict';"); + + for (var tempIndex in foo) { + assert.notSameValue(tempIndex, "caller", 'tempIndex'); + } + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-8-s.js b/js/src/tests/test262/language/statements/function/13.2-8-s.js new file mode 100644 index 0000000000..d8a8f800a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-8-s.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. + +/*--- +es5id: 13.2-8-s +description: > + StrictMode - enumerating over a function object looking for + 'caller' fails inside the function +flags: [noStrict] +---*/ + + var foo = new Function("'use strict'; for (var tempIndex in this) {assert.notSameValue(tempIndex, 'caller', 'tempIndex');}"); + foo.call(foo); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/13.2-9-s.js b/js/src/tests/test262/language/statements/function/13.2-9-s.js new file mode 100644 index 0000000000..3aabaaa1a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/13.2-9-s.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. + +/*--- +es5id: 13.2-9-s +description: > + StrictMode - reading a property named 'caller' of function objects + is not allowed outside the function +flags: [noStrict] +---*/ + + var foo = Function("'use strict';"); +assert.throws(TypeError, function() { + var temp = foo.caller; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S10.1.1_A1_T1.js b/js/src/tests/test262/language/statements/function/S10.1.1_A1_T1.js new file mode 100644 index 0000000000..9b3e996f20 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S10.1.1_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Program functions are defined in source text by a FunctionDeclaration or created dynamically either + by using a FunctionExpression or by using the built-in Function object as a constructor +es5id: 10.1.1_A1_T1 +description: Defining function by a FunctionDeclaration +---*/ + +//CHECK#1 +function f1(){ + return 1; +} +if(typeof(f1)!=="function") + throw new Test262Error('#1: typeof(f1)!=="function"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A1_T1.js b/js/src/tests/test262/language/statements/function/S13.2.1_A1_T1.js new file mode 100644 index 0000000000..7a938678cb --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A1_T1.js @@ -0,0 +1,74 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The depth of nested function calls reaches 32 +es5id: 13.2.1_A1_T1 +description: Creating function calls 32 elements depth +---*/ + +(function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){})() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() +})() + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A4_T1.js b/js/src/tests/test262/language/statements/function/S13.2.1_A4_T1.js new file mode 100644 index 0000000000..ad94529dc2 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A4_T1.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Objects as arguments are passed by reference +es5id: 13.2.1_A4_T1 +description: > + Adding new number property to a function argument within the + function body, where explicit argument is an object defined with + "var __obj={}" +---*/ + +function __func(__arg){ + __arg.foo=7; +} + +var __obj={}; + +__func(__obj); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.foo !== 7) { + throw new Test262Error('#1: __obj.foo === 7. Actual: __obj.foo ==='+__obj.foo); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A4_T2.js b/js/src/tests/test262/language/statements/function/S13.2.1_A4_T2.js new file mode 100644 index 0000000000..e13abef967 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A4_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: Objects as arguments are passed by reference +es5id: 13.2.1_A4_T2 +description: > + Adding new string property to a function argument within the + function body, where explicit argument is an object defined with + "__obj={}" +---*/ + +function __func(__arg){ + __arg.foo="whiskey gogo"; +} + +var __obj={}; + + __func(__obj); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.foo !== "whiskey gogo") { + throw new Test262Error('#1: __obj.foo === "whiskey gogo". Actual: __obj.foo ==='+__obj.foo); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A4_T3.js b/js/src/tests/test262/language/statements/function/S13.2.1_A4_T3.js new file mode 100644 index 0000000000..706bfcee79 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A4_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: Objects as arguments are passed by reference +es5id: 13.2.1_A4_T3 +description: > + Adding new number property to a function argument within the + function body, where array element "arguments[0]" is an object + defined with "__obj={}" +---*/ + +function __func(){ + arguments[0]["PI"]=3.14; +} + +var __obj={}; + +__func(__obj); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.PI !== 3.14) { + throw new Test262Error('#1: __obj.PI === 3.14. Actual: __obj.PI ==='+__obj.PI); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A4_T4.js b/js/src/tests/test262/language/statements/function/S13.2.1_A4_T4.js new file mode 100644 index 0000000000..c54588b235 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A4_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: Objects as arguments are passed by reference +es5id: 13.2.1_A4_T4 +description: > + Adding new number property to a function argument within the + function body, where array element "arguments[0]" is an object + defined with "var __obj={}" +---*/ + +function __func(){ + arguments[0]["E"]=2.74; +} + +var __obj={}; + +__func(__obj); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.E !== 2.74) { + throw new Test262Error('#1: __obj.E === 2.74. Actual: __obj.E ==='+__obj.E); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A5_T1.js b/js/src/tests/test262/language/statements/function/S13.2.1_A5_T1.js new file mode 100644 index 0000000000..ab95e11349 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A5_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: Closures are admitted +es5id: 13.2.1_A5_T1 +description: Sorting with closure +---*/ + +var __arr = [4,3,2,1,4,3,2,1,4,3,2,1]; +//Sort uses closure +// +__arr.sort( + function(x,y) { + if (x>y){return -1;} + if (x + Returning a function that approximates the derivative of f using + an interval of dx, which should be appropriately small +---*/ + +// Return a function that approximates the derivative of f +// using an interval of dx, which should be appropriately small. +function derivative(f, dx) { + return function(x) { + return (f(x + dx) - f(x)) / dx; + }; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (Math.abs(derivative(Math.sin, 0.0001)(0) - derivative(Math.sin, 0.0001)(2*Math.PI)) >= 1/65536.0) { + throw new Test262Error('#1: Math.abs(derivative(Math.sin, 0.0001)(0) - derivative(Math.sin, 0.0001)(2*Math.PI)) <= 1/65536.0'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A6_T1.js b/js/src/tests/test262/language/statements/function/S13.2.1_A6_T1.js new file mode 100644 index 0000000000..6dd6f3df27 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A6_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: Primitive types are passed by value +es5id: 13.2.1_A6_T1 +description: Declaring a function with "function __func(arg1, arg2)" +flags: [noStrict] +---*/ + +function __func(arg1, arg2){ + arg1++; + arg2+="BA"; +}; + +var x=1; +y=2; +var a="AB" +b="SAM"; + +__func(x,a); +__func(y,b); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x!==1 || y!==2 || a!=="AB" || b!=="SAM") { + throw new Test262Error('#1: x === 1 and y === 2 and a === "AB" and b === "SAM". Actual: x ==='+x+' and y ==='+y+' and a ==='+a+' and b ==='+b); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A6_T2.js b/js/src/tests/test262/language/statements/function/S13.2.1_A6_T2.js new file mode 100644 index 0000000000..274fc50f4a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A6_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: Primitive types are passed by value +es5id: 13.2.1_A6_T2 +description: Declaring a function with "__func = function(arg1, arg2)" +flags: [noStrict] +---*/ + +__func = function(arg1, arg2){ + arg1++; + arg2+="BA"; +}; + +var x=1; +y=2; +var a="AB" +b="SAM"; + +__func(x,a); +__func(y,b); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x!==1 || y!==2 || a!=="AB" || b!=="SAM") { + throw new Test262Error('#1: x === 1 and y === 2 and a === "AB" and b === "SAM". Actual: x ==='+x+' and y ==='+y+' and a ==='+a+' and b ==='+b); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A6_T3.js b/js/src/tests/test262/language/statements/function/S13.2.1_A6_T3.js new file mode 100644 index 0000000000..51c41e1d2c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A6_T3.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Primitive types are passed by value +es5id: 13.2.1_A6_T1 +description: Declaring a function with "function __func(arg1, arg2)" +---*/ + +var __func, y, b; + +function __func(arg1, arg2){ + arg1++; + arg2+="BA"; +}; + +var x=1; +y=2; +var a="AB" +b="SAM"; + +__func(x,a); +__func(y,b); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x!==1 || y!==2 || a!=="AB" || b!=="SAM") { + throw new Test262Error('#1: x === 1 and y === 2 and a === "AB" and b === "SAM". Actual: x ==='+x+' and y ==='+y+' and a ==='+a+' and b ==='+b); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A6_T4.js b/js/src/tests/test262/language/statements/function/S13.2.1_A6_T4.js new file mode 100644 index 0000000000..443df08052 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A6_T4.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: Primitive types are passed by value +es5id: 13.2.1_A6_T2 +description: Declaring a function with "__func = function(arg1, arg2)" +---*/ + +var __func, y, b; + +__func = function(arg1, arg2){ + arg1++; + arg2+="BA"; +}; + +var x=1; +y=2; +var a="AB" +b="SAM"; + +__func(x,a); +__func(y,b); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x!==1 || y!==2 || a!=="AB" || b!=="SAM") { + throw new Test262Error('#1: x === 1 and y === 2 and a === "AB" and b === "SAM". Actual: x ==='+x+' and y ==='+y+' and a ==='+a+' and b ==='+b); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A7_T1.js b/js/src/tests/test262/language/statements/function/S13.2.1_A7_T1.js new file mode 100644 index 0000000000..f891e5921c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A7_T1.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When the [[Call]] property for a Function object F is called, the following steps are taken: + 2. Evaluate F's FunctionBody; + if Result.type is returned then Result.value is returned too +es5id: 13.2.1_A7_T1 +description: Returning null. Declaring a function with "function __func()" +---*/ + +function __func(){ + var x = null; + return x; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + var x=__func(); +} catch(e){ + throw new Test262Error('#1: var x=__func() does not lead to throwing exception. Actual: exception is '+e); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A7_T2.js b/js/src/tests/test262/language/statements/function/S13.2.1_A7_T2.js new file mode 100644 index 0000000000..9aa2ab4864 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A7_T2.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When the [[Call]] property for a Function object F is called, the following steps are taken: + 2. Evaluate F's FunctionBody; + if Result.type is returned then Result.value is returned too +es5id: 13.2.1_A7_T2 +description: > + Returning null. Declaring a function with "var __func = function + ()" +---*/ + +var __func = function (){ + var x = null; + return x; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + var x=__func(); +} catch(e){ + throw new Test262Error('#1: var x=__func() does not lead to throwing exception. Actual: exception is '+e); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A7_T3.js b/js/src/tests/test262/language/statements/function/S13.2.1_A7_T3.js new file mode 100644 index 0000000000..dfa88c33e0 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A7_T3.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: | + When the [[Call]] property for a Function object F is called, the following steps are taken: + 2. Evaluate F's FunctionBody; + if Result.type is returned then Result.value is returned too +es5id: 13.2.1_A7_T3 +description: Returning number. Declaring a function with "function __func()" +flags: [noStrict] +---*/ + +function __func(){ + x = 1; + return x; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +try { + x=x; + throw new Test262Error('#0: "x=x" lead to throwing exception'); +} catch (e) { + if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + var __x=__func(); +} catch(e){ + throw new Test262Error('#1: var __x=__func() does not lead to throwing exception. Actual: exception is '+e); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__x !== 1) { + throw new Test262Error('#2: __x === 1. Actual: __x ==='+__x); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (x !== 1) { + throw new Test262Error('#3: x === 1. Actual: x ==='+x); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A7_T4.js b/js/src/tests/test262/language/statements/function/S13.2.1_A7_T4.js new file mode 100644 index 0000000000..c6a3257a0e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A7_T4.js @@ -0,0 +1,58 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When the [[Call]] property for a Function object F is called, the following steps are taken: + 2. Evaluate F's FunctionBody; + if Result.type is returned then Result.value is returned too +es5id: 13.2.1_A7_T4 +description: Returning boolean. Declaring a function with "function __func()" +---*/ + +function __func(){ + var x = true; + return x; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +try { + x=x; + throw new Test262Error('#0: "x=x" lead to throwing exception'); +} catch (e) { + if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + var __x=__func() +} catch(e){ + throw new Test262Error('#1: var __x=__func() does not lead to throwing exception. Actual: exception is '+e); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (!(__x)) { + throw new Test262Error('#2: __x === true. Actual: __x ==='+__x); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +try { + x=x; + throw new Test262Error('#3: "x=x" lead to throwing exception'); +} catch (e) { + if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A8_T1.js b/js/src/tests/test262/language/statements/function/S13.2.1_A8_T1.js new file mode 100644 index 0000000000..9ab0050a36 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A8_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: | + When the [[Call]] property for a Function object F is called, the following steps are taken: + 2. Evaluate F's FunctionBody; + if Result.type is thrown then Result.value is thrown too +es5id: 13.2.1_A8_T1 +description: > + Throwing an exception within a function body. Declaring function + with "function __func()" +---*/ + +function __func(){ + var x = 1; + throw ("Catch Me If You Can") + return x; +} + +try{ + var x=__func() + throw new Test262Error('#0: var x=__func() lead to throwing exception'); +} catch(e){ + if (e !== "Catch Me If You Can") { + throw new Test262Error('#1: Exception === "Catch Me If You Can". Actual: exception ==='+e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A8_T2.js b/js/src/tests/test262/language/statements/function/S13.2.1_A8_T2.js new file mode 100644 index 0000000000..418376aeb8 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A8_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: | + When the [[Call]] property for a Function object F is called, the following steps are taken: + 2. Evaluate F's FunctionBody; + if Result.type is thrown then Result.value is thrown too +es5id: 13.2.1_A8_T2 +description: > + Throwing an exception within a function body. Declaring function + with "var __func = function (message)" +---*/ + +var CATCH_ME_IF_YOU_CAN = true; + +var __func = function (message){ + var x = 1; + throw (message) + return x; +} + +try{ + var x=__func(CATCH_ME_IF_YOU_CAN) + throw new Test262Error('#0: var x=__func(CATCH_ME_IF_YOU_CAN) lead to throwing exception'); +} catch(e){ + if (!e) { + throw new Test262Error('#1: Exception === true. Actual: exception ==='+e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A9.1_T1.js b/js/src/tests/test262/language/statements/function/S13.2.1_A9.1_T1.js new file mode 100644 index 0000000000..ed32b92093 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A9.1_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: | + When the [[Call]] property for a Function object is called, + the body is evaluated and if evaluation result has type "normal", then "undefined" is returned +es5id: 13.2.1_A9.1_T1 +description: > + Declaring a function with "function __func()" and no "return" in + the function body +---*/ + +var x; + +function __func(){ + x = true; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func() !== undefined) { + throw new Test262Error('#1: __func() === undefined. Actual: __func() ==='+__func()); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (!x) { + throw new Test262Error('#2: x === true. Actual: x === '+x); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A9.1_T2.js b/js/src/tests/test262/language/statements/function/S13.2.1_A9.1_T2.js new file mode 100644 index 0000000000..a1c12ce74a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A9.1_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: | + When the [[Call]] property for a Function object is called, + the body is evaluated and if evaluation result has type "normal", then "undefined" is returned +es5id: 13.2.1_A9.1_T2 +description: > + Declaring a function with "var __func = function()" and no + "return" in the function body +---*/ + +var x; + +var __func = function(){ + x = true; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func() !== undefined) { + throw new Test262Error('#1: __func() === undefined. Actual: __func() ==='+__func()); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (!x) { + throw new Test262Error('#2: x === true. Actual: x === '+x); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A9_T1.js b/js/src/tests/test262/language/statements/function/S13.2.1_A9_T1.js new file mode 100644 index 0000000000..c5e84d2641 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A9_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: | + When the [[Call]] property for a Function object is called, + the body is evaluated and if evaluation result has type "return" its value is not defined, then "undefined" is returned +es5id: 13.2.1_A9_T1 +description: > + Using "return" with no expression. Declaring a function with + "function __func()" +---*/ + +var x; + +function __func(){ + x = 1; + return; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func() !== undefined) { + throw new Test262Error('#1: __func() === undefined. Actual: __func() ==='+__func()); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (x!==1) { + throw new Test262Error('#2: x === 1. Actual: x === '+x); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.1_A9_T2.js b/js/src/tests/test262/language/statements/function/S13.2.1_A9_T2.js new file mode 100644 index 0000000000..cd7c9b50b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.1_A9_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: | + When the [[Call]] property for a Function object is called, + the body is evaluated and if evaluation result has type "return" its value is not defined, then "undefined" is returned +es5id: 13.2.1_A9_T2 +description: > + Using "return" with no expression. Declaring a function with "var + __func = function()" +---*/ + +var x; + +var __func = function(){ + x = 1; + return; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func() !== undefined) { + throw new Test262Error('#1: __func() === undefined. Actual: __func() ==='+__func()); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (x!==1) { + throw new Test262Error('#2: x === 1. Actual: x === '+x); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A10.js b/js/src/tests/test262/language/statements/function/S13.2.2_A10.js new file mode 100644 index 0000000000..68bac38cc8 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A10.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: | + Calling a function as a constructor is possible as long as + this.any_Function is declared +es5id: 13.2.2_A10 +description: Calling a function as a constructor after it has been declared +---*/ + +function FACTORY(){ + this.id = 0; + + this.func = function (){ + return 5; + } + + this.id = this.func(); + +} +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var obj = new FACTORY(); +} catch (e) { + throw new Test262Error('#1: var obj = new FACTORY() does not lead to throwing exception. Actual: Exception is '+e); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (obj.id !== 5) { + throw new Test262Error('#2: obj.id === 5. Actual: obj.id ==='+obj.id); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A11.js b/js/src/tests/test262/language/statements/function/S13.2.2_A11.js new file mode 100644 index 0000000000..2ac9c4345f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A11.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: | + Calling a function as a constructor is possible as long as + this.any_Function is declared and called +es5id: 13.2.2_A11 +description: > + Calling a function as a constructor after it has been declared + with "function func()" +---*/ + +function FACTORY(){ + this.id = 0; + + this.id = this.func(); + + function func(){ + return "id_string"; + } + +} +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var obj = new FACTORY(); + throw new Test262Error('#1: var obj = new FACTORY() lead to throwing exception'); +} catch (e) { + if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A12.js b/js/src/tests/test262/language/statements/function/S13.2.2_A12.js new file mode 100644 index 0000000000..02f6d6e8c5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A12.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: | + Calling a function as a constructor is possible as long as + this.any_Function is declared and called +es5id: 13.2.2_A12 +description: > + Calling a function as a constructor after it has been declared + with "function func()" +---*/ + +function FACTORY(){ + this.id = 0; + + this.id = func(); + + function func(){ + return "id_string"; + } + +} +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var obj = new FACTORY(); +} catch (e) { + throw new Test262Error('#1: var obj = new FACTORY() does not lead to throwing exception. Actual: Exception is '+e); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (obj.id !== "id_string") { + throw new Test262Error('#2: obj.id === "id_string". Actual: obj.id ==='+obj.id); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A13.js b/js/src/tests/test262/language/statements/function/S13.2.2_A13.js new file mode 100644 index 0000000000..7077426b4e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A13.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: | + Calling a function as a constructor is inadmissible as long as + this.any_Function is declared by eval and called +es5id: 13.2.2_A13 +description: > + Calling a function as a constructor after it has been declared by + eval +---*/ + +function FACTORY(){ + this.id = 0; + + this.id = func(); + + eval("function func(){return \"id_string\";}"); + +} +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var obj = new FACTORY(); + throw new Test262Error('#1: var obj = new FACTORY() lead to throwing exception'); +} catch (e) { + if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A14.js b/js/src/tests/test262/language/statements/function/S13.2.2_A14.js new file mode 100644 index 0000000000..49b017f724 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A14.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: | + Calling a function as a constructor is inadmissible as long as + this.any_Function is declared by eval and called +es5id: 13.2.2_A14 +description: > + Calling a function as a constructor after it has been declared by + eval +flags: [noStrict] +---*/ + +function FACTORY(){ + this.id = 0; + + eval("function func(){return \"id_string\";}"); + + this.id = func(); + +} +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var obj = new FACTORY(); +} catch (e) { + throw new Test262Error('#1: var obj = new FACTORY() does not lead to throwing exception'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A15_T1.js b/js/src/tests/test262/language/statements/function/S13.2.2_A15_T1.js new file mode 100644 index 0000000000..c73e673ead --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A15_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: | + When the [[Construct]] property for a Function object F is called, + and the object created in the function is returned, the object (declared with "this" within a function) will be strong and healthy +es5id: 13.2.2_A15_T1 +description: > + Function declared at the end of the program and "obj" property is + declared with "var obj = {}" +---*/ + +var __obj = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof obj !== "undefined") { + throw new Test262Error('#1: typeof obj === "undefined". Actual: typeof obj ==='+typeof obj); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.prop !== "A") { + throw new Test262Error('#2: __obj.prop === "A". Actual: __obj.prop ==='+__obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__obj.slot.prop !==1) { + throw new Test262Error('#3: __obj.slot.prop ===1. Actual: __obj.slot.prop ==='+__obj.slot.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __FACTORY(){ + this.prop = 1; + var obj = {}; + obj.prop = "A"; + obj.slot = this; + return obj; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A15_T2.js b/js/src/tests/test262/language/statements/function/S13.2.2_A15_T2.js new file mode 100644 index 0000000000..cbf5c775f6 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A15_T2.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: | + When the [[Construct]] property for a Function object F is called, + and the object created in the function is returned, the object (declared with "this" within a function) will be strong and healthy +es5id: 13.2.2_A15_T2 +description: > + Function declared at the end of the program and "obj" property is + declared with "obj = {}" +---*/ + +var obj; + +var __obj = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (obj.prop !== "A") { + throw new Test262Error('#1: obj.prop === "A". Actual: obj.prop ==='+obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.prop !== "A") { + throw new Test262Error('#2: __obj.prop === "A". Actual: __obj.prop ==='+__obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__obj.slot.prop !==1) { + throw new Test262Error('#3: __obj.slot.prop === 1. Actual: __obj.slot.prop ==='+__obj.slot.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __FACTORY(){ + this.prop = 1; + obj = {}; + obj.prop = "A"; + obj.slot = this; + return obj; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A15_T3.js b/js/src/tests/test262/language/statements/function/S13.2.2_A15_T3.js new file mode 100644 index 0000000000..a58c0a57d5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A15_T3.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: | + When the [[Construct]] property for a Function object F is called, + and the object created in the function is returned, the object (declared with "this" within a function) will be strong and healthy +es5id: 13.2.2_A15_T3 +description: > + Function declared at the end of the program and "obj" property is + declared with "var obj = {}" +---*/ + +var __FACTORY, __obj; + +__FACTORY = function (){ + this.prop = 1; + var obj = {}; + obj.prop = "A"; + obj.slot = this; + return obj; +} + +__obj = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof obj !== "undefined") { + throw new Test262Error('#1: typeof obj === "undefined". Actual: typeof obj ==='+typeof obj); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.prop !== "A") { + throw new Test262Error('#2: __obj.prop === "A". Actual: __obj.prop ==='+__obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__obj.slot.prop !==1) { + throw new Test262Error('#3: __obj.slot.prop ===1. Actual: __obj.slot.prop ==='+__obj.slot.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A15_T4.js b/js/src/tests/test262/language/statements/function/S13.2.2_A15_T4.js new file mode 100644 index 0000000000..014ced8751 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A15_T4.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: | + When the [[Construct]] property for a Function object F is called, + and the object created in the function is returned, the object (declared with "this" within a function) will be strong and healthy +es5id: 13.2.2_A15_T4 +description: > + Function declared at the end of the program and "obj" property is + declared with "obj = {}" +---*/ + +var __FACTORY, __obj, obj; + +__FACTORY = function(){ + this.prop = 1; + obj = {}; + obj.prop = "A"; + obj.slot = this; + return obj; +} + +__obj = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (obj.prop !== "A") { + throw new Test262Error('#1: obj.prop === "A". Actual: obj.prop ==='+obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.prop !== "A") { + throw new Test262Error('#2: __obj.prop === "A". Actual: __obj.prop ==='+obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__obj.slot.prop !==1) { + throw new Test262Error('#3: __obj.slot.prop ===1. Actual: __obj.slot.prop ==='+obj.slot.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A16_T1.js b/js/src/tests/test262/language/statements/function/S13.2.2_A16_T1.js new file mode 100644 index 0000000000..4ffd0fb889 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A16_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. + +/*--- +info: FunctionExpression within a new statement is admitted +es5id: 13.2.2_A16_T1 +description: > + Using "is __obj = new function __func(){this.prop=1;}" as + FunctionExpression +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "undefined") { + throw new Test262Error('#1: typeof __func === "undefined". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = new function __func(){this.prop=1;}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.prop !== 1) { + throw new Test262Error('#2: __obj.prop === 1. Actual: __obj.prop ==='+__obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (typeof __func !== "undefined") { + throw new Test262Error('#5: typeof __func === "undefined". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A16_T2.js b/js/src/tests/test262/language/statements/function/S13.2.2_A16_T2.js new file mode 100644 index 0000000000..9473e06431 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A16_T2.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: FunctionExpression within a new statement is admitted +es5id: 13.2.2_A16_T2 +description: > + Using "var __obj = new function __func(arg){this.prop=arg;}(5)" as + FunctionExpression +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "undefined") { + throw new Test262Error('#1: typeof __func === "undefined". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = new function __func(arg){this.prop=arg;}(5); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.prop !== 5) { + throw new Test262Error('#2: __obj.prop === 5. Actual: __obj.prop ==='+__obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof __func !== "undefined") { + throw new Test262Error('#3: typeof __func === "undefined". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A16_T3.js b/js/src/tests/test262/language/statements/function/S13.2.2_A16_T3.js new file mode 100644 index 0000000000..34db63b436 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A16_T3.js @@ -0,0 +1,46 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: FunctionExpression within a new statement is admitted +es5id: 13.2.2_A16_T3 +description: > + Using "is __obj = new function __func(arg){this.prop=arg; return + {feat: ++arg}}(5)" as FunctionExpression +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "undefined") { + throw new Test262Error('#1: typeof __func === "undefined"'); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = new function __func(arg){this.prop=arg; return {feat: ++arg}}(5); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.prop !== undefined) { + throw new Test262Error('#2: __obj.prop === undefined. Actual: __obj.prop ==='+__obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__obj.feat !== 6) { + throw new Test262Error('#3: __obj.feat === 6. Actual: __obj.feat ==='+__obj.feat); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (typeof __func !== "undefined") { + throw new Test262Error('#4: typeof __func === "undefined". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A17_T2.js b/js/src/tests/test262/language/statements/function/S13.2.2_A17_T2.js new file mode 100644 index 0000000000..e5d0d2e5d2 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A17_T2.js @@ -0,0 +1,72 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: FunctionExpression containing "with" statement is admitted +es5id: 13.2.2_A17_T2 +description: Throwing an exception within "with" statement +flags: [noStrict] +---*/ + +this.p1="alert"; + +__obj={p1:1,getRight:function(){return "right";}}; + +getRight=function(){return "napravo";}; + +try { + (function(){ + with(__obj){ + p1="w1"; + getRight=function(){return false;} + throw p1; + } + })(); +} catch (e) { + resukt = p1; +} + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (p1!=="alert") { + throw new Test262Error('#1: p1 === "alert". Actual: p1==='+p1); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (getRight()!=="napravo") { + throw new Test262Error('#2: getRight() === "napravo". Actual: getRight() === '+getRight()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__obj.p1!=="w1") { + throw new Test262Error('#3: __obj.p1 === "w1". Actual: __obj.p1 ==='+__obj.p1); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__obj.getRight()!==false) { + throw new Test262Error('#4: __obj.getRight() === false. Actual: __obj.getRight() === '+__obj.getRight()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (resukt !== "alert") { + throw new Test262Error('#5: resukt === "alert". Actual: resukt ==='+resukt); +} +// +////////////////////////////////////////////////////////////////////////////// + +var resukt; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A17_T3.js b/js/src/tests/test262/language/statements/function/S13.2.2_A17_T3.js new file mode 100644 index 0000000000..451355fe6e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A17_T3.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: FunctionExpression containing "with" statement is admitted +es5id: 13.2.2_A17_T3 +description: > + In the check 4 we populate field getRight in __obj object since + var getRight declaration adds variable to function scope but + getRight in statement resolves within with(__obj) scope and + searchs getRight in __obj first +flags: [noStrict] +---*/ + +p1="alert"; + +this.__obj={p1:1,getRight:function(){return "right";}}; + +var getRight=function(){return "napravo";}; + +resukt=(function(){ + with(__obj){ + p1="w1"; + var getRight=function(){return false;}; + return p1; + } +})(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (p1!=="alert") { + throw new Test262Error('#1: p1 === "alert". Actual: p1==='+p1); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (getRight()!=="napravo") { + throw new Test262Error('#2: getRight() === "napravo". Actual: getRight()==='+getRight()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__obj.p1!=="w1") { + throw new Test262Error('#3: __obj.p1 === "w1". Actual: __obj.p1 ==='+__obj.p1); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__obj.getRight()!==false) { + throw new Test262Error('#4: __obj.getRight() === false. Actual: __obj.getRight()==='+__obj.getRight()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (resukt !== "w1") { + throw new Test262Error('#5: resukt === "w1". Actual: resukt ==='+resukt); +} +// +////////////////////////////////////////////////////////////////////////////// + +var resukt; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A18_T1.js b/js/src/tests/test262/language/statements/function/S13.2.2_A18_T1.js new file mode 100644 index 0000000000..5983be4bf7 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A18_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: | + Using arguments object within a "with" Expression that is nested in a + function is admitted +es5id: 13.2.2_A18_T1 +description: "Object is declared with \"var __obj={callee:\"a\"}\"" +flags: [noStrict] +---*/ + +var callee=0, b; + +var __obj={callee:"a"}; + +result=(function(){ + with (arguments){ + callee=1; + b=true; + } + return arguments; +})(__obj); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (callee !== 0) { + throw new Test262Error('#1: callee === 0. Actual: callee ==='+callee); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.callee !== "a") { + throw new Test262Error('#2: __obj.callee === "a". Actual: __obj.callee==='+__obj.callee); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (result.callee !== 1) { + throw new Test262Error('#3: result.callee === 1. Actual: result.callee ==='+result.callee); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (!(this.b)) { + throw new Test262Error('#4: this.b === true. Actual: this.b ==='+this.b); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A18_T2.js b/js/src/tests/test262/language/statements/function/S13.2.2_A18_T2.js new file mode 100644 index 0000000000..443e0195a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A18_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. + +/*--- +info: | + Using arguments object within a "with" Expression that is nested in a + function is admitted +es5id: 13.2.2_A18_T2 +description: "Object is declared with \"__obj={callee:\"a\"}\"" +flags: [noStrict] +---*/ + +this.callee = 0; +var b; + +__obj={callee:"a"}; + +function f(){ + with (arguments){ + callee=1; + b=true; + return arguments; + } +}; + +result=f(__obj); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (callee !== 0) { + throw new Test262Error('#1: callee === 0. Actual: callee ==='+callee); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.callee !== "a") { + throw new Test262Error('#2: __obj.callee === "a". Actual: __obj.callee ==='+__obj.callee); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (result.callee !== 1) { + throw new Test262Error('#3: result.callee === 1. Actual: result.callee ==='+result.callee); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (!(this.b)) { + throw new Test262Error('#4: this.b === true. Actual: this.b ==='+this.b); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A19_T1.js b/js/src/tests/test262/language/statements/function/S13.2.2_A19_T1.js new file mode 100644 index 0000000000..8d9fda0448 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A19_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: Function's scope chain is started when it is declared +es5id: 13.2.2_A19_T1 +description: Function is declared in the global scope +flags: [noStrict] +---*/ + +var a = 1; + +var __func= function(){return a;}; + +var __obj = {a:2}; + +with (__obj) +{ + result = __func(); +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (result !== 1) { + throw new Test262Error('#1: result === 1. Actual: result ==='+result); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A19_T2.js b/js/src/tests/test262/language/statements/function/S13.2.2_A19_T2.js new file mode 100644 index 0000000000..fc4ac71d42 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A19_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: Function's scope chain is started when it is declared +es5id: 13.2.2_A19_T2 +description: Function is declared in the object scope. Using "with" statement +flags: [noStrict] +---*/ + +var a = 1; + +var __obj = {a:2}; + +with (__obj) +{ + result = (function(){return a;})(); +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (result !== 2) { + throw new Test262Error('#1: result === 2. Actual: result ==='+result); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A19_T3.js b/js/src/tests/test262/language/statements/function/S13.2.2_A19_T3.js new file mode 100644 index 0000000000..8467e7da14 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A19_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: Function's scope chain is started when it is declared +es5id: 13.2.2_A19_T3 +description: > + Function is declared in the object scope and then an exception is + thrown +flags: [noStrict] +---*/ + +var a = 1; + +var __obj = {a:2}; + +try { + with (__obj) + { + var __func = function (){return a;}; + throw 3; + } +} catch (e) { + ; +} + +result = __func(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (result !== 2) { + throw new Test262Error('#1: result === 2. Actual: result ==='+result); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A19_T4.js b/js/src/tests/test262/language/statements/function/S13.2.2_A19_T4.js new file mode 100644 index 0000000000..fa3ca8b7eb --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A19_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: Function's scope chain is started when it is declared +es5id: 13.2.2_A19_T4 +description: > + Function is declared in the hierarchical object scope and then an + exception is thrown +flags: [noStrict] +---*/ + +var a = 1; + +var __obj = {a:2,__obj:{a:3}}; + +try { + with (__obj) + { + with(__obj){ + var __func = function(){return a;}; + throw 5; + } + } +} catch (e) { + ; +} + +result = __func(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (result !== 3) { + throw new Test262Error('#1: result === 3. Actual: result ==='+result); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A19_T5.js b/js/src/tests/test262/language/statements/function/S13.2.2_A19_T5.js new file mode 100644 index 0000000000..09695df97a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A19_T5.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: Function's scope chain is started when it is declared +es5id: 13.2.2_A19_T5 +description: > + Function is declared in the object scope, then an exception is + thrown and the object is deleted +flags: [noStrict] +---*/ + +var a = 1; + +var __obj = {a:2}; + +with (__obj) +{ + try { + + var __func = function() + { + return a; + } + throw 3; + } catch (e) { + ; + } +} + +delete __obj; + +result = __func(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (result !== 2) { + throw new Test262Error('#1: result === 2. Actual: result ==='+result); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A19_T6.js b/js/src/tests/test262/language/statements/function/S13.2.2_A19_T6.js new file mode 100644 index 0000000000..b13daa112f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A19_T6.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: Function's scope chain is started when it is declared +es5id: 13.2.2_A19_T6 +description: > + Function is declared in the "object->do-while" scope, then the + object is deleted and another object with the same name is declared +flags: [noStrict] +---*/ + +var a = 1; + +var __obj = {a:2}; + +with (__obj) +{ + do { + var __func = function() + { + return a; + } + } while(0); +} + +delete __obj; + +var __obj = {a:3}; + +with (__obj) +{ + result = __func(); +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (result !== 2) { + throw new Test262Error('#1: result === 2. Actual: result ==='+result); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A19_T7.js b/js/src/tests/test262/language/statements/function/S13.2.2_A19_T7.js new file mode 100644 index 0000000000..1982732b66 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A19_T7.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: Function's scope chain is started when it is declared +es5id: 13.2.2_A19_T7 +description: Function is declared in the object scope as a variable +flags: [noStrict] +---*/ + +var a = 1; + +var __obj = {a:2}; + +with (__obj) +{ + var __func = function() + { + return a; + } +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.hasOwnProperty('__func')) { + throw new Test262Error('#1: __obj.hasOwnProperty(\'__func\') === false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////// ///////////////////////////////////////// +//CHECK#2 +if (!(this.hasOwnProperty('__func'))) { + throw new Test262Error('#2: this.hasOwnProperty(\'__func\') === true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__func in __obj) { + throw new Test262Error('#3: (__func in __obj) === false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (this.__func === undefined) { + throw new Test262Error('#4: this.__func !== undefined'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A19_T8.js b/js/src/tests/test262/language/statements/function/S13.2.2_A19_T8.js new file mode 100644 index 0000000000..577fba297f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A19_T8.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: Function's scope chain is started when it is declared +es5id: 13.2.2_A19_T8 +description: Function is declared multiply times +flags: [noStrict] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (typeof __func !== "undefined") { + throw new Test262Error('#0: typeof __func === "undefined". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +var a = 1, b = "a"; + +var __obj = {a:2}; + +with (__obj) +{ + while(1){ + var __func = function() + { + return a; + }; + break; + } +} + +delete __obj; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func() !== 2) { + throw new Test262Error('#1: __func() === 2. Actual: __func() ==='+__func()); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = {a:3,b:"b"}; + +with (__obj) +{ + var __func = function() + { + return b; + } +} + +delete __obj; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func()!=="b") { + throw new Test262Error('#2: __func()==="b". Actual: __func()==='+__func()); +} +// +////////////////////////////////////////////////////////////////////////////// + +with ({a:99,b:"c"}) +{ + ////////////////////////////////////////////////////////////////////////////// + //CHECK#3 + if (__func() !== "b") { + throw new Test262Error('#3: __func()==="b". Actual: __func()==='+__func()); + } + // + ////////////////////////////////////////////////////////////////////////////// +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A1_T1.js b/js/src/tests/test262/language/statements/function/S13.2.2_A1_T1.js new file mode 100644 index 0000000000..8ef3731517 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A1_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: | + Since a function is an object, it might be set to [[Prototype]] property + of a new created object through [[Construct]] property +es5id: 13.2.2_A1_T1 +description: Declaring a function with "function __func()" +---*/ + +var __MONSTER="monster"; +var __PREDATOR="predator"; + +function __PROTO(){}; + +try{ + __PROTO.type=__MONSTER; +} +catch(e){ + throw new Test262Error('#0: __PROTO.type=__MONSTER does not lead to throwing exception') +} + +function __FACTORY(){}; + +__FACTORY.prototype=__PROTO; + +var __monster = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(__PROTO.isPrototypeOf(__monster))) { + throw new Test262Error('#1: __PROTO.isPrototypeOf(__monster) must be true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__monster.type !==__MONSTER) { + throw new Test262Error('#2: __monster.type ===__MONSTER. Actual: __monster.type ==='+__monster.type); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A1_T2.js b/js/src/tests/test262/language/statements/function/S13.2.2_A1_T2.js new file mode 100644 index 0000000000..00296c20ed --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A1_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: | + Since a function is an object, it might be set to [[Prototype]] property + of a new created object through [[Construct]] property +es5id: 13.2.2_A1_T2 +description: Declaring a function with "var __PROTO = function()" +---*/ + +var __MONSTER="monster"; +var __PREDATOR="predator"; + +var __PROTO = function(){}; + +try{ + __PROTO.type=__MONSTER; +} +catch(e){ + throw new Test262Error('#0: __PROTO.type=__MONSTER does not lead to throwing exception') +} + +var __FACTORY = function(){}; + +__FACTORY.prototype=__PROTO; + +var __monster = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(__PROTO.isPrototypeOf(__monster))) { + throw new Test262Error('#1: __PROTO.isPrototypeOf(__monster) must be true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__monster.type !==__MONSTER) { + throw new Test262Error('#2: __monster.type ===__MONSTER. Actual: __monster.type ==='+__monster.type); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A2.js b/js/src/tests/test262/language/statements/function/S13.2.2_A2.js new file mode 100644 index 0000000000..0ca29945fe --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A2.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: | + Since a function is an object, it might be set to [[Prototype]] property of a new created object through [[Construct]] property, + but [[call]] property must fail with TypeError error +es5id: 13.2.2_A2 +description: Trying to [[call]] this function +---*/ + +var __PLANT="flower"; +var __ROSE="rose"; + +function __PROTO(){}; + +try{ + __PROTO.type=__PLANT; +} +catch(e){ + throw new Test262Error('#0: __PROTO.type=__PLANT does not lead to throwing exception') +} + +function __FACTORY(){}; + +__FACTORY.prototype=__PROTO; + +var __rose = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + __rose(); + throw new Test262Error('#1: __rose() lead to throwing exception'); +} catch(e){ + if (!(e instanceof TypeError)) { + throw new Test262Error('#2: Exception Type is TypeError. Actual: exception ==='+e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A3_T1.js b/js/src/tests/test262/language/statements/function/S13.2.2_A3_T1.js new file mode 100644 index 0000000000..9708a4a34a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A3_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: | + When the [[Construct]] property for a Function object F is called: + A new native ECMAScript object is created. + It gets the value of the [[Prototype]] property of the F(Denote it PROTO_VAL). + If PROTO_VAL is not an object, sets the [[Prototype]] property of native ECMAScript object just created + to the original Object prototype object as described in 15.2.3.1 +es5id: 13.2.2_A3_T1 +description: Declaring a function with "function __FACTORY()" +---*/ + +function __FACTORY(){}; +__FACTORY.prototype=1; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __FACTORY.prototype !== 'number') { + throw new Test262Error('#1: typeof __FACTORY.prototype === \'number\'. Actual: typeof __FACTORY.prototype ==='+(typeof __FACTORY.prototype)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __device = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (!(Object.prototype.isPrototypeOf(__device))) { + throw new Test262Error('#2: Object.prototype.isPrototypeOf(__device) === true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A3_T2.js b/js/src/tests/test262/language/statements/function/S13.2.2_A3_T2.js new file mode 100644 index 0000000000..922413d1fe --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A3_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: | + When the [[Construct]] property for a Function object F is called: + A new native ECMAScript object is created. + It gets the value of the [[Prototype]] property of the F(Denote it PROTO_VAL). + If PROTO_VAL is not an object, sets the [[Prototype]] property of native ECMAScript object just created + to the original Object prototype object as described in 15.2.3.1 +es5id: 13.2.2_A3_T2 +description: Declaring a function with "var __FACTORY = function()" +---*/ + +var __FACTORY = function(){}; +__FACTORY.prototype=1; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __FACTORY.prototype !== 'number') { + throw new Test262Error('#1: typeof __FACTORY.prototype === \'number\'. Actual: typeof __FACTORY.prototype ==='+(typeof __FACTORY.prototype)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __device = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (!(Object.prototype.isPrototypeOf(__device))) { + throw new Test262Error('#2: Object.prototype.isPrototypeOf(__device) === true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A4_T1.js b/js/src/tests/test262/language/statements/function/S13.2.2_A4_T1.js new file mode 100644 index 0000000000..a891b83d41 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A4_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: | + When the [[Construct]] property for a Function object F is called: + A new native ECMAScript object is created. + Gets the value of the [[Prototype]] property of the F(Denote it PROTO_VAL). + If PROTO_VAL is an object, sets the [[Prototype]] property of native ECMAScript object just created + to the PROTO_VAL +es5id: 13.2.2_A4_T1 +description: Declaring a function with "function __FACTORY()" +---*/ + +var __CUBE="cube"; + +function __FACTORY(){ +}; +__FACTORY.prototype={ shape:__CUBE, printShape:function(){return this.shape;} }; + +var __device = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__device.printShape === undefined) { + throw new Test262Error('#1: __device.printShape !== undefined. Actual: __device.printShape ==='+__device.printShape); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__device.printShape() !== __CUBE) { + throw new Test262Error('#2: __device.printShape() === __CUBE. Actual: __device.printShape() ==='+__device.printShape()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A4_T2.js b/js/src/tests/test262/language/statements/function/S13.2.2_A4_T2.js new file mode 100644 index 0000000000..5536c28a43 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A4_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: | + When the [[Construct]] property for a Function object F is called: + A new native ECMAScript object is created. + Gets the value of the [[Prototype]] property of the F(Denote it PROTO_VAL). + If PROTO_VAL is an object, sets the [[Prototype]] property of native ECMAScript object just created + to the PROTO_VAL +es5id: 13.2.2_A4_T2 +description: Declaring a function with "__FACTORY = function()" +---*/ + +var __CUBE, __FACTORY, __device; + +__CUBE="cube"; + +__FACTORY = function(){}; + +__FACTORY.prototype={ shape:__CUBE, printShape:function(){return this.shape;} }; + +__device = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__device.printShape === undefined) { + throw new Test262Error('#1: __device.printShape !== undefined. Actual: __device.printShape ==='+__device.printShape); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__device.printShape() !== __CUBE) { + throw new Test262Error('#2: __device.printShape() === __CUBE. Actual: __device.printShape() ==='+__device.printShape()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A5_T1.js b/js/src/tests/test262/language/statements/function/S13.2.2_A5_T1.js new file mode 100644 index 0000000000..3a50043b88 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A5_T1.js @@ -0,0 +1,83 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When the [[Construct]] property for a Function object F is called: + A new native ECMAScript object is created. + Invoke the [[Call]] property of F, providing native ECMAScript object just created as the this value and + providing the argument list passed into [[Construct]] as the argument values +es5id: 13.2.2_A5_T1 +description: Declaring a function with "function __FACTORY(arg1, arg2)" +---*/ + +var __VOLUME, __RED, __ID, __BOTTOM, __TOP, __LEFT, color, bottom, left, __device; + +__VOLUME=8; +__RED="red"; +__ID=12342; +__BOTTOM=1.1; +__TOP=0.1; +__LEFT=0.5; + + +function __FACTORY(arg1, arg2){ + this.volume=__VOLUME; + color=__RED; + this.id=arg1; + bottom=arg2; + this.top=arguments[2]; + left=arguments[3]; +}; + +__device = new __FACTORY(__ID, __BOTTOM, __TOP, __LEFT); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__device.color !== undefined) { + throw new Test262Error('#1: __device.color === undefined. Actual: __device.color ==='+__device.color); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__device.volume !== __VOLUME) { + throw new Test262Error('#2: __device.volume === __VOLUME. Actual: __device.volume ==='+__device.volume); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__device.bottom !== undefined) { + throw new Test262Error('#3: __device.bottom === undefined. Actual: __device.bottom ==='+__device.bottom); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__device.id !== __ID) { + throw new Test262Error('#4: __device.id === __ID. Actual: __device.id ==='+__device.id); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (__device.left !== undefined) { + throw new Test262Error('#5: __device.left === undefined. Actual: __device.left ==='+__device.left); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (__device.top !== __TOP) { + throw new Test262Error('#6: __device.top === __TOP. Actual: __device.top ==='+__device.top); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A5_T2.js b/js/src/tests/test262/language/statements/function/S13.2.2_A5_T2.js new file mode 100644 index 0000000000..9b2e46107d --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A5_T2.js @@ -0,0 +1,83 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When the [[Construct]] property for a Function object F is called: + A new native ECMAScript object is created. + Invoke the [[Call]] property of F, providing native ECMAScript object just created as the this value and + providing the argument list passed into [[Construct]] as the argument values +es5id: 13.2.2_A5_T2 +description: Declaring a function with "__FACTORY = function(arg1, arg2)" +---*/ + +var __VOLUME, __RED, __ID, __BOTTOM, __TOP, __LEFT, __FACTORY, color, bottom, left, __device; + +__VOLUME=8; +__RED="red"; +__ID=12342; +__BOTTOM=1.1; +__TOP=0.1; +__LEFT=0.5; + + +__FACTORY = function(arg1, arg2){ + this.volume=__VOLUME; + color=__RED; + this.id=arg1; + bottom=arg2; + this.top=arguments[2]; + left=arguments[3]; +}; + +__device = new __FACTORY(__ID, __BOTTOM, __TOP, __LEFT); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__device.color !== undefined) { + throw new Test262Error('#1: __device.color === undefined. Actual: __device.color ==='+__device.color); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__device.volume !== __VOLUME) { + throw new Test262Error('#2: __device.volume === __VOLUME. Actual: __device.volume ==='+__device.volume); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__device.bottom !== undefined) { + throw new Test262Error('#3: __device.bottom === undefined. Actual: __device.bottom ==='+__device.bottom); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__device.id !== __ID) { + throw new Test262Error('#4: __device.id === __ID. Actual: __device.id ==='+__device.id); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (__device.left !== undefined) { + throw new Test262Error('#5: __device.left === undefined. Actual: __device.left ==='+__device.left); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (__device.top !== __TOP) { + throw new Test262Error('#6: __device.top === __TOP. Actual: __device.top ==='+__device.top); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A6_T1.js b/js/src/tests/test262/language/statements/function/S13.2.2_A6_T1.js new file mode 100644 index 0000000000..f5b29daaeb --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A6_T1.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When the [[Construct]] property for a Function object F is called: + A new native ECMAScript object is created. + Invoke the [[Call]] property of F, providing just created native ECMAScript object as the this value and providing the argument + list passed into [[Construct]] as the argument values. + If Type( [[Call]] returned) is not Object then return passed as this into [[Call]] object +es5id: 13.2.2_A6_T1 +description: Declaring a function with "__func = function(arg)" +---*/ + +var __FOO, __BAR, __func, __obj; + +__FOO="fooValue"; +__BAR="barValue"; + +__func = function(arg){ + this.foo=arg; + return 0; + this.bar=arguments[1]; +}; + +__obj = new __func(__FOO, __BAR); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.foo!==__FOO) { + throw new Test262Error('#1: __obj.foo === __FOO. Actual: __obj.foo==='+__obj.foo); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.bar!==undefined) { + throw new Test262Error('#2: __obj.bar === undefined. Actual: __obj.bar==='+__obj.bar); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A6_T2.js b/js/src/tests/test262/language/statements/function/S13.2.2_A6_T2.js new file mode 100644 index 0000000000..4ebe5d7c8a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A6_T2.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When the [[Construct]] property for a Function object F is called: + A new native ECMAScript object is created. + Invoke the [[Call]] property of F, providing just created native ECMAScript object as the this value and providing the argument + list passed into [[Construct]] as the argument values. + If Type( [[Call]] returned) is not Object then return passed as this into [[Call]] object +es5id: 13.2.2_A6_T2 +description: Declaring a function with "function __func (arg)" +---*/ + +var __FOO="fooValue"; +var __BAR="barValue"; + +function __func (arg){ + this.foo=arg; + return true; + this.bar=arguments[1]; +}; + +var __obj = new __func(__FOO, __BAR); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.foo!==__FOO) { + throw new Test262Error('#1: __obj.foo === __FOO. Actual: __obj.foo==='+__obj.foo); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.bar!==undefined) { + throw new Test262Error('#2: __obj.bar === undefined. Actual: __obj.bar==='+__obj.bar); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A7_T1.js b/js/src/tests/test262/language/statements/function/S13.2.2_A7_T1.js new file mode 100644 index 0000000000..8133b46288 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A7_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: | + When the [[Construct]] property for a Function object F is called: + A new native ECMAScript object is created. + Invoke the [[Call]] property of F, providing just created native ECMAScript object as the this value and providing the argument + list passed into [[Construct]] as the argument values. + If Type( [[Call]] returned) is an Object then return this just as obtained object +es5id: 13.2.2_A7_T1 +description: Declaring a function with "as __func = function(arg)" +---*/ + +var __FRST="one"; +var __SCND="two"; + +function __func (arg1, arg2){ + this.first=arg1; + var __obj={second:arg2}; + return __obj; + +}; + +var __obj__ = new __func(__FRST, __SCND); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj__.first !== undefined) { + throw new Test262Error('#1: __obj__.first === undefined. Actual: __obj__.first==='+__obj__.first); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj__.second !== __SCND) { + throw new Test262Error('#2: __obj__.second === __SCND. Actual: __obj__.second ==='+__obj__.second); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A7_T2.js b/js/src/tests/test262/language/statements/function/S13.2.2_A7_T2.js new file mode 100644 index 0000000000..5c5a629675 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A7_T2.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: | + When the [[Construct]] property for a Function object F is called: + A new native ECMAScript object is created. + Invoke the [[Call]] property of F, providing just created native ECMAScript object as the this value and providing the argument + list passed into [[Construct]] as the argument values. + If Type( [[Call]] returned) is an Object then return this just as obtained object +es5id: 13.2.2_A7_T2 +description: Declaring a "function as function __func (arg)" +---*/ + +var __FRST, __SCND, __func, __obj__; + +__FRST="one"; +__SCND="two"; + +__func = function(arg1, arg2){ + this.first=arg1; + var __obj={second:arg2}; + return __obj; + +}; + +__obj__ = new __func(__FRST, __SCND); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj__.first !== undefined) { + throw new Test262Error('#1: __obj__.first === undefined. Actual: __obj__.first==='+__obj__.first); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj__.second !== __SCND) { + throw new Test262Error('#2: __obj__.second === __SCND. Actual: __obj__.second ==='+__obj__.second); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A8_T1.js b/js/src/tests/test262/language/statements/function/S13.2.2_A8_T1.js new file mode 100644 index 0000000000..25fe3e8615 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A8_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: | + When the [[Construct]] property for a Function object F is called: + A new native ECMAScript object is created. + Invoke the [[Call]] property of F, providing just created native ECMAScript object as the this value and providing the argument + list passed into [[Construct]] as the argument values. + If Type( [[Call]] returned) is an Function then return this just as obtained function +es5id: 13.2.2_A8_T1 +description: > + Creating a function whose prototype contains "return" followed by + declaration of another function +---*/ + +var __FRST="one"; +var __SCND="two"; + +var __func = function(arg1, arg2){ + this.first=arg1; + + __gunc.prop=arg2; + return __gunc; + // function declaration + function __gunc(arg){return ++arg}; + +}; + +var __instance = new __func(__FRST, __SCND); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.first !== undefined) { + throw new Test262Error('#1: __instance.first === undefined. Actual: __instance.first ==='+__instance.first); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__instance.prop!==__SCND) { + throw new Test262Error('#2: __instance.prop === __SCND. Actual: __instance.prop ==='+__instance.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__instance(1)!== 2) { + throw new Test262Error('#2: __instance(1)=== 2. Actual: __instance(1) ==='+__instance(1)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A8_T2.js b/js/src/tests/test262/language/statements/function/S13.2.2_A8_T2.js new file mode 100644 index 0000000000..fe7c7069b0 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A8_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: | + When the [[Construct]] property for a Function object F is called: + A new native ECMAScript object is created. + Invoke the [[Call]] property of F, providing just created native ECMAScript object as the this value and providing the argument + list passed into [[Construct]] as the argument values. + If Type( [[Call]] returned) is an Function then return this just as obtained function +es5id: 13.2.2_A8_T2 +description: > + Creating a function whose prototype contains declaration of + another function declared as a variable +---*/ + +var __FRST="one"; +var __SCND="two"; + +var __func = function(arg1, arg2){ + this.first=arg1; + var __gunc = function(arg){return arg+="BA"}; + __gunc.prop=arg2; + return __gunc; + +}; + +var __instance = new __func(__FRST, __SCND); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.first !== undefined) { + throw new Test262Error('#1: __instance.first === undefined. Actual: __instance.first ==='+__instance.first); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__instance.prop!==__SCND) { + throw new Test262Error('#2: __instance.prop === __SCND. Actual: __instance.prop ==='+__instance.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__instance("SAM")!== "SAMBA") { + throw new Test262Error('#2: __instance("SAM") === "SAMBA". Actual: __instance("SAM") ==='+__instance("SAM")); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A8_T3.js b/js/src/tests/test262/language/statements/function/S13.2.2_A8_T3.js new file mode 100644 index 0000000000..dbe654fa37 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A8_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: | + When the [[Construct]] property for a Function object F is called: + A new native ECMAScript object is created. + Invoke the [[Call]] property of F, providing just created native ECMAScript object as the this value and providing the argument + list passed into [[Construct]] as the argument values. + If Type( [[Call]] returned) is an Function then return this just as obtained function +es5id: 13.2.2_A8_T3 +description: > + Creating a function whose prototype contains declaration of + another function defined by using Function.call method +---*/ + +var __FRST="one"; +var __SCND="two"; + +var __func = function(arg1, arg2){ + this.first=arg1; + var __gunc = Function.call(this,"arg","return ++arg;"); + __gunc.prop=arg2; + return __gunc; + +}; + +var __instance = new __func(__FRST, __SCND); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.first !== undefined) { + throw new Test262Error('#1: __instance.first === undefined. Actual: __instance.first ==='+__instance.first); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__instance.prop!==__SCND) { + throw new Test262Error('#2: __instance.prop === __SCND. Actual: __instance.prop ==='+__instance.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__instance(1)!== 2) { + throw new Test262Error('#2: __instance(1)=== 2. Actual: __instance(1) ==='+__instance(1)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2.2_A9.js b/js/src/tests/test262/language/statements/function/S13.2.2_A9.js new file mode 100644 index 0000000000..ac0c051aa3 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2.2_A9.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: | + Calling a function as a constructor is inadmissible as long as + this.any_Function is called before it is declared +es5id: 13.2.2_A9 +description: Calling a function as a constructor +---*/ + +function FACTORY(){ + this.id = 0; + + this.id = this.func(); + + this.func = function (){ + return 5; + } + +} +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var obj = new FACTORY(); + throw new Test262Error('#1: var obj = new FACTORY() lead to throwing exception'); +} catch (e) { + if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2_A1_T1.js b/js/src/tests/test262/language/statements/function/S13.2_A1_T1.js new file mode 100644 index 0000000000..45ff8a4857 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2_A1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: A "prototype" property is automatically created for every function +es5id: 13.2_A1_T1 +description: Using "function __func(){}" as a FunctionDeclaration +---*/ + +function __func(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func.prototype === undefined) { + throw new Test262Error('#1: __func.prototype !== undefined'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2_A1_T2.js b/js/src/tests/test262/language/statements/function/S13.2_A1_T2.js new file mode 100644 index 0000000000..e180e4c15e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2_A1_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: A "prototype" property is automatically created for every function +es5id: 13.2_A1_T2 +description: Using "var __func = function(){}" as a FunctionDeclaration +---*/ + +var __func = function(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func.prototype === undefined) { + throw new Test262Error('#1: __func.prototype !== undefined'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2_A2_T1.js b/js/src/tests/test262/language/statements/function/S13.2_A2_T1.js new file mode 100644 index 0000000000..1a9c6b46ea --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2_A2_T1.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Nested function are admitted +es5id: 13.2_A2_T1 +description: Nesting level is two +---*/ + +var __JEDI="jedi"; + +function __FUNC(){ + function __GUNC(){ + return arguments[0]; + }; + + return __GUNC; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__FUNC()(__JEDI) !== __JEDI) { + throw new Test262Error('#1: __FUNC()(__JEDI) === __JEDI. Actual: __FUNC()(__JEDI) ==='+__FUNC()(__JEDI)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2_A2_T2.js b/js/src/tests/test262/language/statements/function/S13.2_A2_T2.js new file mode 100644 index 0000000000..f985522156 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2_A2_T2.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Nested function are admitted +es5id: 13.2_A2_T2 +description: Nesting level is three +---*/ + +var __ROBOT="C3PO"; + +function __FUNC(){ + function __GUNC(){ + return arguments[0]; + }; + function __HUNC(){ + return __GUNC; + }; + return __HUNC; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__FUNC()()(__ROBOT) !== __ROBOT) { + throw new Test262Error('#1: __FUNC()()(__ROBOT) === __ROBOT. Actual: __FUNC()()(__ROBOT) ==='+__FUNC()()(__ROBOT)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2_A3.js b/js/src/tests/test262/language/statements/function/S13.2_A3.js new file mode 100644 index 0000000000..28b526ca4d --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2_A3.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When Function object(F) is constructed the length property of F is set to + the number of formal properties specified in FormalParameterList +es5id: 13.2_A3 +description: > + Creating functions with various FormalParameterList and checking + their lengths +---*/ + +function __func(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func.length !== 0) { + throw new Test262Error('#1: __func.length === 0. Actual: __func.length ==='+__func.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __gunc(a,b,c){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__gunc.length !== 3) { + throw new Test262Error('#2: __gunc.length === 3. Actual: __gunc.length ==='+__gunc.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2_A4_T1.js b/js/src/tests/test262/language/statements/function/S13.2_A4_T1.js new file mode 100644 index 0000000000..81ecd23d1a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2_A4_T1.js @@ -0,0 +1,50 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When Function object(F) is constructed the following steps from 9 to 11 take place + 9.Create a new object as would be constructed by the expression new Object(). + 10. Set the constructor property of Result(9) to F. This property is given attributes { DontEnum }. + 11. Set the "prototype" property of F to Result(9). +es5id: 13.2_A4_T1 +description: > + Checking prototype, prototype.constructor properties and + {DontEnum} property of a constructor. Using "function __func(){}" + as a FunctionDeclaration +---*/ + +function __func(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func.prototype !== 'object') { + throw new Test262Error('#1: typeof __func.prototype === \'object\'. Actual: typeof __gunc.prototype ==='+typeof __gunc.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func.prototype.constructor !== __func) { + throw new Test262Error('#2: __func.prototype.constructor === __func. Actual: __gunc.prototype.constructor ==='+__gunc.prototype.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __constructor_was__enumed; + +for (__prop in __func.prototype){ + if (__prop === 'constructor') + __constructor_was__enumed = true; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__constructor_was__enumed) { + throw new Test262Error('#3: __constructor_was__enumed === false. Actual: __constructor_was__enumed ==='+__constructor_was__enumed); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2_A4_T2.js b/js/src/tests/test262/language/statements/function/S13.2_A4_T2.js new file mode 100644 index 0000000000..7e7d5d68c5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2_A4_T2.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: | + When Function object(F) is constructed the following steps from 9 to 11 take place + 9.Create a new object as would be constructed by the expression new Object(). + 10. Set the constructor property of Result(9) to F. This property is given attributes { DontEnum }. + 11. Set the "prototype" property of F to Result(9). +es5id: 13.2_A4_T2 +description: > + Checking prototype, prototype.constructor properties and + {DontEnum} property of a constructor. Using "var __gunc = + function(){}" as a FunctionDeclaration +---*/ + +var __gunc = function(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __gunc.prototype !== 'object') { + throw new Test262Error('#1: typeof __gunc.prototype === \'object\'. Actual: typeof __gunc.prototype ==='+typeof __gunc.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__gunc.prototype.constructor !== __gunc) { + throw new Test262Error('#2: __gunc.prototype.constructor === __gunc. Actual: __gunc.prototype.constructor ==='+__gunc.prototype.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __constructor_was__enumed; + +for (__prop in __gunc.prototype){ + if (__prop === 'constructor') + __constructor_was__enumed = true; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__constructor_was__enumed) { + throw new Test262Error('#3: __constructor_was__enumed === false. Actual: __constructor_was__enumed ==='+__constructor_was__enumed); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2_A5.js b/js/src/tests/test262/language/statements/function/S13.2_A5.js new file mode 100644 index 0000000000..d2b096119a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2_A5.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: | + When Function object(F) is constructed + the [[Prototype]] property of F is set to the original Function prototype object as specified in 15.3.3.1 +es5id: 13.2_A5 +description: Function.prototype.isPrototypeOf() is used +---*/ + +function __func(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(Function.prototype.isPrototypeOf(__func))) { + throw new Test262Error('#1: Function.prototype.isPrototypeOf(__func)'); +} +// +////////////////////////////////////////////////////////////////////////////// + + +var __gunc = function(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (!(Function.prototype.isPrototypeOf(__gunc))) { + throw new Test262Error('#1: Function.prototype.isPrototypeOf(__gunc)'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2_A6_T1-strict.js b/js/src/tests/test262/language/statements/function/S13.2_A6_T1-strict.js new file mode 100644 index 0000000000..d065c8ed05 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2_A6_T1-strict.js @@ -0,0 +1,13 @@ +'use strict'; +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.2_A6_T1 +description: check if "caller" poisoning poisons getOwnPropertyDescriptor too +flags: [onlyStrict] +---*/ + +Object.getOwnPropertyDescriptor(function(){}, 'caller'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2_A6_T2-strict.js b/js/src/tests/test262/language/statements/function/S13.2_A6_T2-strict.js new file mode 100644 index 0000000000..b4fa421bf7 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2_A6_T2-strict.js @@ -0,0 +1,15 @@ +'use strict'; +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.2_A6_T2 +description: > + check if "arguments" poisoning poisons getOwnPropertyDescriptor + too +flags: [onlyStrict] +---*/ + +Object.getOwnPropertyDescriptor(function(){}, 'arguments'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2_A7_T1-strict.js b/js/src/tests/test262/language/statements/function/S13.2_A7_T1-strict.js new file mode 100644 index 0000000000..049044d2b3 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2_A7_T1-strict.js @@ -0,0 +1,13 @@ +'use strict'; +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.2_A7_T1 +description: check if "caller" poisoning poisons hasOwnProperty too +flags: [onlyStrict] +---*/ + +(function(){}).hasOwnProperty('caller'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2_A7_T2-strict.js b/js/src/tests/test262/language/statements/function/S13.2_A7_T2-strict.js new file mode 100644 index 0000000000..3e8f46bfb3 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2_A7_T2-strict.js @@ -0,0 +1,13 @@ +'use strict'; +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.2_A7_T2 +description: check if "arguments" poisoning poisons hasOwnProperty too +flags: [onlyStrict] +---*/ + +(function(){}).hasOwnProperty('arguments'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2_A8_T1-strict.js b/js/src/tests/test262/language/statements/function/S13.2_A8_T1-strict.js new file mode 100644 index 0000000000..5e3647ff91 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2_A8_T1-strict.js @@ -0,0 +1,13 @@ +'use strict'; +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.2_A8_T1 +description: check if "caller" poisoning poisons "in" too +flags: [onlyStrict] +---*/ + +'caller' in function() {}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13.2_A8_T2-strict.js b/js/src/tests/test262/language/statements/function/S13.2_A8_T2-strict.js new file mode 100644 index 0000000000..ec8bde2745 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13.2_A8_T2-strict.js @@ -0,0 +1,13 @@ +'use strict'; +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.2_A8_T2 +description: check if "arguments" poisoning poisons "in" too +flags: [onlyStrict] +---*/ + +'arguments' in function() {}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A1.js b/js/src/tests/test262/language/statements/function/S13_A1.js new file mode 100644 index 0000000000..647a1e47fa --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A1.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: | + "x=function y(){}" statement does not store a reference to the new + function in the varaible y(Identifier) +es5id: 13_A1 +description: Checking the type of y +---*/ + +var __func = function __exp__func(){return 0;}; + +//////////////////////////////////////////////// +// ////////////////////////////// +//CHECK#1 +if (typeof __func !== "function") { + throw new Test262Error('#1: typeof __func === "function". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof __exp__func !== "undefined"){ + throw new Test262Error('#2: typeof __exp__func === "undefined". Actual: typeof __exp__func ==='+typeof __exp__func); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A10.js b/js/src/tests/test262/language/statements/function/S13_A10.js new file mode 100644 index 0000000000..29a737ded2 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A10.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: Function is a data +es5id: 13_A10 +description: Using function as a property of an object +---*/ + +function __ziggy__func(){return "ziggy stardust"} + +var __music_box={}; + +__music_box.ziggy = __ziggy__func; + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +if (typeof __music_box.ziggy !== "function") { + throw new Test262Error('#1: typeof __music_box.ziggy === "function". Actual: typeof __music_box.ziggy ==='+typeof __music_box.ziggy); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__music_box.ziggy() !== "ziggy stardust") { + throw new Test262Error('#2: __music_box.ziggy() === "ziggy stardust". Actual: __music_box.ziggy() ==='+__music_box.ziggy()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A11_T1.js b/js/src/tests/test262/language/statements/function/S13_A11_T1.js new file mode 100644 index 0000000000..89d46919d9 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A11_T1.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Since arguments property has attribute { DontDelete }, only its elements + can be deleted +es5id: 13_A11_T1 +description: Returning result of "delete arguments" +flags: [noStrict] +---*/ + +function __func(){ return delete arguments;} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func("A","B",1,2)) { + throw new Test262Error('#1: arguments property has attribute { DontDelete }'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A11_T2.js b/js/src/tests/test262/language/statements/function/S13_A11_T2.js new file mode 100644 index 0000000000..37fd1c0241 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A11_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: | + Since arguments property has attribute { DontDelete }, only its elements + can be deleted +es5id: 13_A11_T2 +description: > + Checking if deleting the arguments property fails and then + returning it +flags: [noStrict] +---*/ + +function __func(){ + delete arguments; + return arguments; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func("A","B",1,2) !== "object") { + throw new Test262Error('#1: arguments property has attribute { DontDelete }'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A11_T3.js b/js/src/tests/test262/language/statements/function/S13_A11_T3.js new file mode 100644 index 0000000000..6612f1e31f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A11_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: | + Since arguments property has attribute { DontDelete }, only its elements + can be deleted +es5id: 13_A11_T3 +description: Deleting arguments[i] and returning result of the operation +---*/ + +function __func(){ + var was_del=false; + for (var i=0; i < arguments.length; i++) + was_del= was_del || delete arguments[i]; + return was_del; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!__func("A","B",1,2)) { + throw new Test262Error('#1: Since arguments property has attribute { DontDelete } elements of arguments can be deleted'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A11_T4.js b/js/src/tests/test262/language/statements/function/S13_A11_T4.js new file mode 100644 index 0000000000..3533b634f3 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A11_T4.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: | + Since arguments property has attribute { DontDelete }, only its elements + can be deleted +es5id: 13_A11_T4 +description: Deleting arguments[i] and checking the type of arguments[i] +---*/ + +function __func(){ + var is_undef=true; + for (var i=0; i < arguments.length; i++) + { + delete arguments[i]; + is_undef= is_undef && (typeof arguments[i] === "undefined"); + }; + return is_undef; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!__func("A","B",1,2)) { + throw new Test262Error('#1: Since arguments property has attribute { DontDelete }, but elements of arguments can be deleted'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A12_T1.js b/js/src/tests/test262/language/statements/function/S13_A12_T1.js new file mode 100644 index 0000000000..05ae3e7504 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A12_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. + +/*--- +info: Function declarations in global or function scope are {DontDelete} +es5id: 13_A12_T1 +description: > + Checking if deleting a function that is declared in global scope + fails +flags: [noStrict] +---*/ + +ALIVE="Letov is alive" + +function __func(){ + return ALIVE; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (delete __func) { + throw new Test262Error('#1: delete __func returning false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func() !== ALIVE) { + throw new Test262Error('#2: __func() === ALIVE. Actual: __func() ==='+__func()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A12_T2.js b/js/src/tests/test262/language/statements/function/S13_A12_T2.js new file mode 100644 index 0000000000..4bda588cab --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A12_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: Function declarations in global or function scope are {DontDelete} +es5id: 13_A12_T2 +description: > + Checking if deleting a function that is declared in function scope + fails +flags: [noStrict] +---*/ + +ALIVE="Letov is alive" + +function __cont(){ + + function __func(){ + return ALIVE; + }; + + ////////////////////////////////////////////////////////////////////////////// + //CHECK#1 + if (delete __func) { + throw new Test262Error('#1: delete __func returning false'); + } + // + ////////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////////////// + //CHECK#2 + if (__func() !== ALIVE) { + throw new Test262Error('#2: __func() === ALIVE. Actual: __func() ==='+__func()); + } + // + ////////////////////////////////////////////////////////////////////////////// +}; + +__cont(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A13_T1.js b/js/src/tests/test262/language/statements/function/S13_A13_T1.js new file mode 100644 index 0000000000..7065a7324a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A13_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: Deleting arguments[i] leads to breaking the connection to local reference +es5id: 13_A13_T1 +description: Deleting arguments[i] +---*/ + +function __func(__arg){ + delete arguments[0]; + if (arguments[0] !== undefined) { + throw new Test262Error('#1.1: arguments[0] === undefined'); + } + return __arg; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func(1) !== 1) { + throw new Test262Error('#1.2: __func(1) === 1. Actual: __func(1) ==='+__func(1)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A13_T2.js b/js/src/tests/test262/language/statements/function/S13_A13_T2.js new file mode 100644 index 0000000000..08cc30cbf1 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A13_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: Deleting arguments[i] leads to breaking the connection to local reference +es5id: 13_A13_T2 +description: Changing arguments value and then deleting the argument +---*/ + +function __func(__arg){ + __arg = 2; + delete arguments[0]; + if (arguments[0] !== undefined) { + throw new Test262Error('#1.1: arguments[0] === undefined'); + } + return __arg; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func(1) !== 2) { + throw new Test262Error('#1.2: __func(1) === 2. Actual: __func(1) ==='+__func(1)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A13_T3.js b/js/src/tests/test262/language/statements/function/S13_A13_T3.js new file mode 100644 index 0000000000..47f0e2a515 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A13_T3.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Deleting arguments[i] leads to breaking the connection to local reference +es5id: 13_A13_T3 +description: > + Changing argument value, deleting the argument and then defining a + new value for arguments[i] +---*/ + +function __func(__arg){ + __arg = 2; + delete arguments[0]; + if (arguments[0] !== undefined) { + throw new Test262Error('#1.1: arguments[0] === undefined'); + } + arguments[0] = "A"; + if (arguments[0] !== "A") { + throw new Test262Error('#1.2: arguments[0] === "A"'); + } + return __arg; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func(1) !== 2) { + throw new Test262Error('#1.3: __func(1) === 2. Actual: __func(1) ==='+__func(1)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A14_T1.js b/js/src/tests/test262/language/statements/function/S13_A14_T1.js new file mode 100644 index 0000000000..e64bbcc44a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A14_T1.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Unicode symbols in function name are allowed +es5id: 13_A14 +description: Defining function name with unicode symbols +flags: [noStrict] +---*/ + +eval("function __func\u0041(__arg){return __arg;};"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __funcA !== "function") { + throw new Test262Error('#1: unicode symbols in function name are allowed'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A15_T1.js b/js/src/tests/test262/language/statements/function/S13_A15_T1.js new file mode 100644 index 0000000000..c3ae2781c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A15_T1.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "''arguments'' variable overrides ActivationObject.arguments" +es5id: 13_A15_T1 +description: Declaring a function with "__func(arguments)" +flags: [noStrict] +---*/ + +function __func(arguments){ + return arguments; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func(42) !== 42) { + throw new Test262Error('#1: "arguments" variable overrides ActivationObject.arguments'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A15_T2.js b/js/src/tests/test262/language/statements/function/S13_A15_T2.js new file mode 100644 index 0000000000..8d17396bc3 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A15_T2.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "''arguments'' variable overrides ActivationObject.arguments" +es5id: 13_A15_T2 +description: Overriding arguments within functions body +flags: [noStrict] +---*/ + +THE_ANSWER="Answer to Life, the Universe, and Everything"; + +function __func(){ + var arguments = THE_ANSWER; + return arguments; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func(42,42,42) !== THE_ANSWER) { + throw new Test262Error('#1: "arguments" variable overrides ActivationObject.arguments'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A15_T3.js b/js/src/tests/test262/language/statements/function/S13_A15_T3.js new file mode 100644 index 0000000000..902302ae2c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A15_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: "''arguments'' variable overrides ActivationObject.arguments" +es5id: 13_A15_T3 +description: Declaring a variable named with "arguments" without a function +flags: [noStrict] +---*/ + +THE_ANSWER="Answer to Life, the Universe, and Everything"; + +var arguments = THE_ANSWER; + +function __func(arguments){ + return arguments; + +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func() !== "undefined") { + throw new Test262Error('#1: typeof __func() === "undefined". Actual: typeof __func() ==='+typeof __func()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func("The Ultimate Question") !== "The Ultimate Question") { + throw new Test262Error('#2: __func("The Ultimate Question") === "The Ultimate Question". Actual: __func("The Ultimate Question")==='+__func("The Ultimate Question")); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A15_T4.js b/js/src/tests/test262/language/statements/function/S13_A15_T4.js new file mode 100644 index 0000000000..c58bddc29d --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A15_T4.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "''arguments'' variable overrides ActivationObject.arguments" +es5id: 13_A15_T4 +description: > + Declaring a variable named with "arguments" and following a + "return" statement within a function body +flags: [noStrict] +---*/ + +THE_ANSWER="Answer to Life, the Universe, and Everything"; + +function __func(){ + return typeof arguments; + var arguments = THE_ANSWER; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func(42,42,42) !== "object") { + throw new Test262Error('#1: __func(42,42,42) === "object". Actual: __func(42,42,42)==='+__func(42,42,42)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A15_T5.js b/js/src/tests/test262/language/statements/function/S13_A15_T5.js new file mode 100644 index 0000000000..ad2e15b54e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A15_T5.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: "''arguments'' variable overrides ActivationObject.arguments" +es5id: 13_A15_T5 +description: Creating a variable named with "arguments" without a function +flags: [noStrict] +---*/ + +THE_ANSWER="Answer to Life, the Universe, and Everything"; + +var arguments = THE_ANSWER; + +function __func(){ + return arguments; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ( __func() === THE_ANSWER) { + throw new Test262Error('#1: __func() !== THE_ANSWER'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func("The Ultimate Question") === "The Ultimate Question") { + throw new Test262Error('#2: __func("The Ultimate Question") !== "The Ultimate Question"'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A17_T1.js b/js/src/tests/test262/language/statements/function/S13_A17_T1.js new file mode 100644 index 0000000000..2729bcfcdf --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A17_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: | + Function call cannot appear in the program before the FunctionExpression + appears +es5id: 13_A17_T1 +description: Trying to call a function before the FunctionExpression appears +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + var __result = __func(); + throw new Test262Error("#1.1: var __result = __func() lead to throwing exception"); +} catch(e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: func should throw a TypeError Actual: ' + (e)); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +var __func = function (){return "ONE";}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +var __result = __func(); +if (__result !== "ONE") { + throw new Test262Error('#2: __result === "ONE". Actual: __result ==='+__result); +} +// +////////////////////////////////////////////////////////////////////////////// + +__func = function (){return "TWO";}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +var __result = __func(); +if (__result !== "TWO") { + throw new Test262Error('#3: __result === "TWO". Actual: __result ==='+__result); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A17_T2.js b/js/src/tests/test262/language/statements/function/S13_A17_T2.js new file mode 100644 index 0000000000..8706dd0d3c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A17_T2.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: | + Function call cannot appear in the program before the FunctionExpression + appears +es5id: 13_A17_T2 +description: > + Trying to call a function before the FunctionExpression appears + and then using the FunctionExpression one more time +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + var __result = __func(); + throw new Test262Error("#1: var __result = __func() lead to throwing exception"); +} catch(e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: func should throw a TypeError Actual: ' + (e)); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +// now we reach the __func overwriting by new expression +var __func = function __func(){return "ONE";}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +var __result = __func(); +if (__result !== "ONE") { + throw new Test262Error('#2: __result === "ONE". Actual: __result ==='+__result); +} +// +////////////////////////////////////////////////////////////////////////////// + +__func = function __func(){return "TWO";}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +var __result = __func(); +if (__result !== "TWO") { + throw new Test262Error('#3: __result === "TWO". Actual: __result ==='+__result); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A18.js b/js/src/tests/test262/language/statements/function/S13_A18.js new file mode 100644 index 0000000000..1ed224697b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A18.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: Closures are admitted +es5id: 13_A18 +description: Using a function declaration as a function parameter +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof sinx !== 'undefined') { + throw new Test262Error('#1: typeof sinx === \'undefined\'. Actual: typeof sinx ==='+typeof sinx); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __val = function derivative(f, dx) { + return function(x) { + return (f(x + dx) - f(x)) / dx; + }; +}(function sinx(x){return Math.sin(x);},.0001)(0.5); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof sinx !== 'undefined') { + throw new Test262Error('#2: typeof sinx === \'undefined\'. Actual: typeof sinx ==='+typeof sinx); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A19_T1.js b/js/src/tests/test262/language/statements/function/S13_A19_T1.js new file mode 100644 index 0000000000..e165b0c9f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A19_T1.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "\"var\" does not override function declaration" +es5id: 13_A19_T1 +description: > + Creating a function and a variable with identical Identifiers in + global scope +---*/ + +// since "var" does not override function declaration __decl is set to function +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __decl !== "function") { + throw new Test262Error('#1: typeof __decl === "function". Actual: typeof __decl ==='+typeof __decl); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __decl = 1; + +//since statement was evaluted __decl turns to 1 from function +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__decl !== 1) { + throw new Test262Error('#2: __decl === 1. Actual: __decl ==='+__decl); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __decl(){return 1;} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A19_T2.js b/js/src/tests/test262/language/statements/function/S13_A19_T2.js new file mode 100644 index 0000000000..a96e8a3e7a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A19_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: "\"var\" does not override function declaration" +es5id: 13_A19_T2 +description: > + Creating a function and a variable with identical Identifiers + within function scope +---*/ + +(function (){ + + // since "var" does not override function declaration __decl is set to function + ////////////////////////////////////////////////////////////////////////////// + //CHECK#1 + if (typeof __decl !== "function") { + throw new Test262Error('#1: typeof __decl === "function". Actual: typeof __decl ==='+typeof __decl); + } + // + ////////////////////////////////////////////////////////////////////////////// + + var __decl = 1; + + //since statement was evaluted __decl turns to 1 from function + ////////////////////////////////////////////////////////////////////////////// + //CHECK#2 + if (__decl !== 1) { + throw new Test262Error('#2: __decl === 1. Actual: __decl ==='+__decl); + } + // + ////////////////////////////////////////////////////////////////////////////// + + function __decl(){return 1;} +})(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A2_T1.js b/js/src/tests/test262/language/statements/function/S13_A2_T1.js new file mode 100644 index 0000000000..aa9dae5851 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A2_T1.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: function must be evaluated inside the expression +es5id: 13_A2_T1 +description: Defining function body with "return arg" +---*/ + +var x = (function __func(arg){return arg})(1); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x !== 1) { + throw new Test262Error('#1: x === 1. Actual: x ==='+x); +} + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof __func !== 'undefined') { + throw new Test262Error('#2: typeof __func === \'undefined\'. Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A2_T2.js b/js/src/tests/test262/language/statements/function/S13_A2_T2.js new file mode 100644 index 0000000000..35ca568fcb --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A2_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: function must be evaluated inside the expression +es5id: 13_A2_T2 +description: Defining function body with "return arg + arguments[1]" +---*/ + +var x = (function __func(arg){return arg + arguments[1]})(1,"1"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x !== "11") { + throw new Test262Error('#1: x === "11". Actual: x ==='+x); +} + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof __func !== 'undefined') { + throw new Test262Error('#2: typeof __func === \'undefined\'. Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A2_T3.js b/js/src/tests/test262/language/statements/function/S13_A2_T3.js new file mode 100644 index 0000000000..bdb6b69659 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A2_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: function must be evaluated inside the expression +es5id: 13_A2_T3 +description: > + Defining function body with "return arguments[0] +"-"+ + arguments[1]" +---*/ + +var x = (function __func(){return arguments[0] +"-"+ arguments[1]})("Obi","Wan"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x !== "Obi-Wan") { + throw new Test262Error('#1: x === "Obi-Wan". Actual: x ==='+x); +} + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof __func !== 'undefined') { + throw new Test262Error('#2: typeof __func === \'undefined\'. Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A3_T1.js b/js/src/tests/test262/language/statements/function/S13_A3_T1.js new file mode 100644 index 0000000000..a742380333 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_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: | + The Identifier in a FunctionExpression can be referenced from inside the + FunctionExpression's FunctionBody to allow the function calling itself + recursively +es5id: 13_A3_T1 +description: > + Creating a recursive function that calculates factorial, as a + variable. Function call itself by its name +---*/ + +var __func = function __exp__func(arg){ + if (arg === 1) { + return arg; + } else { + return __exp__func(arg-1)*arg; + } +}; + +var fact_of_3 = __func(3); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (fact_of_3 !== 6) { + throw new Test262Error("#1: fact_of_3 === 6. Actual: fact_of_3 ==="+fact_of_3); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A3_T2.js b/js/src/tests/test262/language/statements/function/S13_A3_T2.js new file mode 100644 index 0000000000..00915e1e5b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A3_T2.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Identifier in a FunctionExpression can be referenced from inside the + FunctionExpression's FunctionBody to allow the function calling itself + recursively +es5id: 13_A3_T2 +description: > + Creating a recursive function that calculates factorial, as a + variable. Function calls itself by the name of the variable +---*/ + +var __func = function (arg){ + if (arg === 1) { + return arg; + } else { + return __func(arg-1)*arg; + } +}; + +var fact_of_3 = __func(3); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (fact_of_3 !== 6) { + throw new Test262Error("#1: fact_of_3 === 6. Actual: fact_of_3 ==="+fact_of_3); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A3_T3.js b/js/src/tests/test262/language/statements/function/S13_A3_T3.js new file mode 100644 index 0000000000..085841d86b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_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: | + The Identifier in a FunctionExpression can be referenced from inside the + FunctionExpression's FunctionBody to allow the function calling itself + recursively +es5id: 13_A3_T3 +description: Creating simple recursive function that calculates factorial +---*/ + +function __func(arg){ + if (arg === 1) { + return arg; + } else { + return __func(arg-1)*arg; + } +}; + +var fact_of_3 = __func(3); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (fact_of_3 !== 6) { + throw new Test262Error("#1: fact_of_3 === 6. Actual: fact_of_3 ==="+fact_of_3); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A4_T1.js b/js/src/tests/test262/language/statements/function/S13_A4_T1.js new file mode 100644 index 0000000000..de4b130945 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A4_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: | + The production FunctionDeclaration: "function Identifier ( + FormalParameterList_opt ) { FunctionBody }" is processed by function + declarations +es5id: 13_A4_T1 +description: Declaring a function that returns string +---*/ + +function __func(){return "zig-zig-sputnik";}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "function") { + throw new Test262Error('#1: typeof __func === "function". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func() !== "zig-zig-sputnik") { + throw new Test262Error('#2: __func() === "zig-zig-sputnik". Actual: __func() ==='+__func()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A4_T2.js b/js/src/tests/test262/language/statements/function/S13_A4_T2.js new file mode 100644 index 0000000000..02428a6422 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A4_T2.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The production FunctionDeclaration: "function Identifier ( + FormalParameterList_opt ) { FunctionBody }" is processed by function + declarations +es5id: 13_A4_T2 +description: > + Declaring a function that uses prefix increment operator within + its "return" Expression +---*/ + +function __func(arg){return ++arg;}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "function") { + throw new Test262Error('#1: typeof __func === "function". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func(1) !== 2) { + throw new Test262Error('#2: __func(1) === 2. Actual: __func(1) ==='+__func(1)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A4_T3.js b/js/src/tests/test262/language/statements/function/S13_A4_T3.js new file mode 100644 index 0000000000..9b559c8170 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A4_T3.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The production FunctionDeclaration: "function Identifier ( + FormalParameterList_opt ) { FunctionBody }" is processed by function + declarations +es5id: 13_A4_T3 +description: > + Declaring a function that uses arithmetical operators within its + "return" Expression +---*/ + +function __func(arg1, arg2, arg3){return arg1+=(arg2+=arg3);}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "function") { + throw new Test262Error('#1: typeof __func === "function". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func(10, 20, 30) !== 60) { + throw new Test262Error('#2: __func(10, 20, 30) === 60. Actual: __func(10,20,30) ==='+__func(10,20,30)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A4_T4.js b/js/src/tests/test262/language/statements/function/S13_A4_T4.js new file mode 100644 index 0000000000..8097d7ba57 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A4_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: | + The production FunctionDeclaration: "function Identifier ( + FormalParameterList_opt ) { FunctionBody }" is processed by function + declarations +es5id: 13_A4_T4 +description: > + Declaring a function that uses strings concatenaion opeator within + its "return" Expression +---*/ + +function __func(){return arguments[0].name + " " + arguments[0].surname;}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "function") { + throw new Test262Error('#1: typeof __func === "function". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func({name:'fox', surname:'malder'}) !== "fox malder") { + throw new Test262Error('#2: __func({name:\'fox\', surname:\'malder\'}) === "fox malder". Actual: __func({name:\'fox\', surname:\'malder\'}) ==='+__func({name:'fox', surname:'malder'})); +} +// +////////////////////////////////////////////////////////////////////////////// + +function func__(arg){return arg.name + " " + arg.surname;}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof func__ !== "function") { + throw new Test262Error('#3: typeof func__ === "function". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (func__({name:'john', surname:'lennon'}) !== "john lennon") { + throw new Test262Error('#4: func__({name:\'john\', surname:\'lennon\'}) === "john lennon". Actual: __func({name:\'john\', surname:\'lennon\'}) ==='+__func({name:'john', surname:'lennon'})); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A6_T1.js b/js/src/tests/test262/language/statements/function/S13_A6_T1.js new file mode 100644 index 0000000000..72ebedfeb3 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A6_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. + +/*--- +info: | + FunctionDeclaration can be overrided by other FunctionDeclaration with + the same Identifier +es5id: 13_A6_T1 +description: Duplicating function declaration +---*/ + +function __func(){return 1}; + +var __store__func = __func; + +var __1 = __func(); + + function __func(){return 'A'}; + +var __A = __func(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__store__func !== __func) { + throw new Test262Error('#1: __store__func === __func. Actual: __store__func ==='+__store__func); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__1 !== __A) { + throw new Test262Error('#2: __1 === __A. Actual: __1 ==='+__1); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A6_T2.js b/js/src/tests/test262/language/statements/function/S13_A6_T2.js new file mode 100644 index 0000000000..358becf1f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A6_T2.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + FunctionDeclaration can be overrided by other FunctionDeclaration with + the same Identifier +es5id: 13_A6_T2 +description: Calling a function before it is declared one more time +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + var __result = __func(); +} catch(e) { + throw new Test262Error("#1: Function call can appears in the program before the FunctionDeclaration appears"); +} +if (__result !== "SECOND") { + throw new Test262Error('#1.1: __result === "SECOND". Actual: __result ==='+__result); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func(){return "FIRST";}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +__result = __func(); +if (__result !== "SECOND") { + throw new Test262Error('#2: __result === "SECOND". Actual: __result ==='+__result); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func(){return "SECOND";}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A7_T1.js b/js/src/tests/test262/language/statements/function/S13_A7_T1.js new file mode 100644 index 0000000000..556fbd5c5a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A7_T1.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 FunctionBody must be SourceElements +es5id: 13_A7_T1 +description: Using only SourceElements within the FunctionBody +---*/ + +function __func(){'ground control to major tom'}; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "function") { + throw new Test262Error('#1: typeof __func === "function". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func__2(){b}; +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof __func__2 !== "function") { + throw new Test262Error('#2: typeof __func__2 === "function". Actual: typeof __func__2 ==='+typeof __func__2); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func__3(){1}; +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof __func__3 !== "function") { + throw new Test262Error('#3: typeof __func__3 === "function". Actual: typeof __func__3 ==='+typeof __func__3); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func__4(){1+c}; +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (typeof __func__4 !== "function") { + throw new Test262Error('#4: typeof __func__4 === "function". Actual: typeof __func__4 ==='+typeof __func__4); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func__5(){inc(d)}; +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (typeof __func__5 !== "function") { + throw new Test262Error('#5: typeof __func__5 === "function". Actual: typeof __func__5 ==='+typeof __func__5); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func__6(){var \u0042 = 1;}; +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (typeof __func__6 !== "function") { + throw new Test262Error('#6: typeof __func__6 === "function". Actual: typeof __func__6 ==='+typeof __func__6); +} +// +////////////////////////////////////////////////////////////////////////////// + +//function __func__7(){var \u003d = 1;}; +//////////////////////////////////////////////////////////////////////////////// +////CHECK#7 +//if (typeof __func__7 !== "function") { +// throw new Test262Error('#7: The FunctionBody must be SourceElements'); +//} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A7_T3.js b/js/src/tests/test262/language/statements/function/S13_A7_T3.js new file mode 100644 index 0000000000..ec722be785 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A7_T3.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The FunctionBody must be SourceElements +es5id: 13_A7_T3 +description: Checking if execution of "function __func(){\A\B\C}" fails +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function __func(){\A\B\C}; diff --git a/js/src/tests/test262/language/statements/function/S13_A8_T1.js b/js/src/tests/test262/language/statements/function/S13_A8_T1.js new file mode 100644 index 0000000000..609f00704e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A8_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: Arguments property of activation object contains real params to be passed +es5id: 13_A8_T1 +description: > + Creating a function declared with "function __func(param1, param2, + param3)" and using arguments.length property in order to perform + the test +---*/ + +function __func(param1, param2, param3) { + return arguments.length; + } + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func('A') !== 1) { + throw new Test262Error('#1: __func(\'A\') === 1. Actual: __func(\'A\') ==='+__func('A')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func('A', 'B', 1, 2,__func) !== 5) { + throw new Test262Error('#2: __func(\'A\', \'B\', 1, 2,__func) === 5. Actual: __func(\'A\', \'B\', 1, 2,__func) ==='+__func('A', 'B', 1, 2,__func)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A8_T2.js b/js/src/tests/test262/language/statements/function/S13_A8_T2.js new file mode 100644 index 0000000000..be709296c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A8_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: Arguments property of activation object contains real params to be passed +es5id: 13_A8_T2 +description: > + Creating a function with no parameters and using arguments.length + property in order to perform the test +---*/ + +function __func() { + return arguments.length; + } + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func('A') !== 1) { + throw new Test262Error('#1: __func(\'A\') === 1. Actual: __func(\'A\') ==='+__func('A')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func('A', 'B', 1, 2,__func) !== 5) { + throw new Test262Error('#2: __func(\'A\', \'B\', 1, 2,__func) === 5. Actual: __func(\'A\', \'B\', 1, 2,__func) ==='+__func('A', 'B', 1, 2,__func)); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__func() !== 0) { + throw new Test262Error('#3: __func() === 0. Actual: __func() ==='+__func()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S13_A9.js b/js/src/tests/test262/language/statements/function/S13_A9.js new file mode 100644 index 0000000000..d36d86d099 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S13_A9.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Function can be passed as argument +es5id: 13_A9 +description: Using function as argument of another function +---*/ + +function __func__INC(arg){return arg + 1;}; +function __func__MULT(incrementator, arg, mult){ return incrementator(arg)*mult; }; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func__MULT(__func__INC, 2, 2) !== 6) { + throw new Test262Error('#1: function can be passed as argument'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S14_A2.js b/js/src/tests/test262/language/statements/function/S14_A2.js new file mode 100644 index 0000000000..d66482a36a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S14_A2.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: FunctionDeclaration cannot be localed inside an Expression +es5id: 14_A2 +description: Declaring a function within an "if" Expression +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof f !== 'undefined') { + throw new Test262Error('#1: typeof f === \'undefined\'. Actual: typeof f ==='+ typeof f ); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (function f(arg){ + if (arg===0) + return 1; + else + return f(arg-1)*arg; +}(3)!==6) { + throw new Test262Error('#2: FunctionDeclaration cannot be localed inside an Expression'); +}; +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S14_A3.js b/js/src/tests/test262/language/statements/function/S14_A3.js new file mode 100644 index 0000000000..09ebe3e2a0 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S14_A3.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: | + Global FunctionDeclaration cannot be defined within the body of another + FunctionDeclaration +es5id: 14_A3 +description: Declaring a function within the body of another function +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "function") { + throw new Test262Error('#1: typeof __func === "function". Actual: typeof __func ==='+ typeof __func ); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof __gunc !== "undefined") { + throw new Test262Error('#2: typeof __gunc === "undefined". Actual: typeof __gunc ==='+ typeof __gunc ); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func(){ + function __gunc(){return true}; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S14_A5_T1.js b/js/src/tests/test262/language/statements/function/S14_A5_T1.js new file mode 100644 index 0000000000..ced62566b6 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S14_A5_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 Identifier within a FunctionDeclaration can be written in both letters + and unicode +es5id: 14_A5_T1 +description: > + Declaring a function with "function + __\u0066\u0075\u006e\u0063(){return "both"}" +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func() !== "both") { + throw new Test262Error('#1: __func() === "both". Actual: __func() ==='+ __func() ); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func(){return "ascii"}; +function \u005f\u005f\u0066\u0075\u006e\u0063(){return "unicode"};//__func in unicode +function __\u0066\u0075\u006e\u0063(){return "both"};//__func in unicode + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/S14_A5_T2.js b/js/src/tests/test262/language/statements/function/S14_A5_T2.js new file mode 100644 index 0000000000..45a22d4de9 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/S14_A5_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: | + The Identifier within a FunctionDeclaration can be written in both letters + and unicode +es5id: 14_A5_T2 +description: > + Declaring a function with "function + \u005f\u005f\u0066\u0075\u006e\u0063(){return "unicode"}" +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func() !== "unicode") { + throw new Test262Error('#1: __func() === "unicode". Actual: __func() ==='+ __func() ); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func(){return "ascii"}; +function \u005f\u005f\u0066\u0075\u006e\u0063(){return "unicode"};//__func in unicode + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/arguments-with-arguments-fn.js b/js/src/tests/test262/language/statements/function/arguments-with-arguments-fn.js new file mode 100644 index 0000000000..b868647bd6 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/arguments-with-arguments-fn.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-functiondeclarationinstantiation +es6id: 9.2.12 +description: > + Arguments object is created even when the body contains a lexically-scoped + binding named "arguments" +info: | + [...] + 19. Else if "arguments" is an element of parameterNames, then + a. Let argumentsObjectNeeded be false. + 20. Else if hasParameterExpressions is false, then + a. If "arguments" is an element of functionNames or if "arguments" is an + element of lexicalNames, then + i. Let argumentsObjectNeeded be false. + [...] +flags: [noStrict] +---*/ + +var args; + +function f(x = args = arguments) { + function arguments() {} +} + +f(); + +assert.sameValue(typeof args, 'object'); +assert.sameValue(args.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/arguments-with-arguments-lex.js b/js/src/tests/test262/language/statements/function/arguments-with-arguments-lex.js new file mode 100644 index 0000000000..5c983389d5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/arguments-with-arguments-lex.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-functiondeclarationinstantiation +es6id: 9.2.12 +description: > + Arguments object is created even when the body contains a function named + "arguments" +info: | + [...] + 19. Else if "arguments" is an element of parameterNames, then + a. Let argumentsObjectNeeded be false. + 20. Else if hasParameterExpressions is false, then + a. If "arguments" is an element of functionNames or if "arguments" is an + element of lexicalNames, then + i. Let argumentsObjectNeeded be false. + [...] +flags: [noStrict] +---*/ + +var args; + +function f(x = args = arguments) { + let arguments; +} + +f(); + +assert.sameValue(typeof args, 'object'); +assert.sameValue(args.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/array-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/function/array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..e6b614bcf5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/array-destructuring-param-strict-body.js @@ -0,0 +1,134 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/array-destructuring-param-strict-body.case +// - src/function-forms/syntax/func-decl.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +function f([element]) { + "use strict"; +} diff --git a/js/src/tests/test262/language/statements/function/browser.js b/js/src/tests/test262/language/statements/function/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/function/cptn-decl.js b/js/src/tests/test262/language/statements/function/cptn-decl.js new file mode 100644 index 0000000000..7e0c9a90cd --- /dev/null +++ b/js/src/tests/test262/language/statements/function/cptn-decl.js @@ -0,0 +1,15 @@ +// Copyright (C) 2017 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-function-definitions-runtime-semantics-evaluation +description: Function declaration completion value is empty. +info: | + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + 1. Return NormalCompletion(empty). +---*/ + +assert.sameValue(eval('function f() {}'), undefined); +assert.sameValue(eval('1; function f() {}'), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dflt-params-abrupt.js b/js/src/tests/test262/language/statements/function/dflt-params-abrupt.js new file mode 100644 index 0000000000..577d4141d1 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dflt-params-abrupt.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/func-decl.template +/*--- +description: Abrupt completion returned by evaluation of initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + +var callCount = 0; +function f(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; +} +assert.throws(Test262Error, function() { + f(); +}); +assert.sameValue(callCount, 0, 'function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/statements/function/dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..367fdd31ac --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dflt-params-arg-val-not-undefined.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/func-decl.template +/*--- +description: Use of initializer when argument value is not `undefined` (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +// Stores a reference `ref` for case evaluation +function ref(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; +} + +ref(false, '', NaN, 0, null, obj); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/statements/function/dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..3aacdd8a81 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dflt-params-arg-val-undefined.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/func-decl.template +/*--- +description: Use of initializer when argument value is `undefined` (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + +var callCount = 0; +// Stores a reference `ref` for case evaluation +function ref(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; +} + +ref(undefined, void 0); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dflt-params-duplicates.js b/js/src/tests/test262/language/statements/function/dflt-params-duplicates.js new file mode 100644 index 0000000000..2863fb152e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dflt-params-duplicates.js @@ -0,0 +1,63 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/func-decl.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ +$DONOTEVALUATE(); + +function f(x = 0, x) { + +} diff --git a/js/src/tests/test262/language/statements/function/dflt-params-ref-later.js b/js/src/tests/test262/language/statements/function/dflt-params-ref-later.js new file mode 100644 index 0000000000..6bc1f74cce --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dflt-params-ref-later.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/func-decl.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +function f(x = y, y) { + + callCount = callCount + 1; +} +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dflt-params-ref-prior.js b/js/src/tests/test262/language/statements/function/dflt-params-ref-prior.js new file mode 100644 index 0000000000..888cc81114 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dflt-params-ref-prior.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/func-decl.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +// Stores a reference `ref` for case evaluation +function ref(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; +} + +ref(3); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dflt-params-ref-self.js b/js/src/tests/test262/language/statements/function/dflt-params-ref-self.js new file mode 100644 index 0000000000..552f0c2efb --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dflt-params-ref-self.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/func-decl.template +/*--- +description: Referencing a parameter from within its own initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +function f(x = x) { + + callCount = callCount + 1; +} +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dflt-params-rest.js b/js/src/tests/test262/language/statements/function/dflt-params-rest.js new file mode 100644 index 0000000000..4cfb8fa37a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dflt-params-rest.js @@ -0,0 +1,67 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/func-decl.template +/*--- +description: RestParameter does not support an initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ +$DONOTEVALUATE(); + +function f(...x = []) { + +} diff --git a/js/src/tests/test262/language/statements/function/dflt-params-trailing-comma.js b/js/src/tests/test262/language/statements/function/dflt-params-trailing-comma.js new file mode 100644 index 0000000000..e0c766be90 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dflt-params-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/func-decl.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +// Stores a reference `ref` for case evaluation +function ref(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +} + +ref(42, undefined, 1); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-init-iter-close.js b/js/src/tests/test262/language/statements/function/dstr/ary-init-iter-close.js new file mode 100644 index 0000000000..16252b5168 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-init-iter-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +function f([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/function/dstr/ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..11e56935b8 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Abrupt completion returned by GetIterator (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + +function f([x, y, z]) {} + +assert.throws(TypeError, function() { + f([1, 2, 3]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/function/dstr/ary-init-iter-get-err.js new file mode 100644 index 0000000000..2b854024f7 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-init-iter-get-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Abrupt completion returned by GetIterator (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +function f([x]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/function/dstr/ary-init-iter-no-close.js new file mode 100644 index 0000000000..b747b8e2e2 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-init-iter-no-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +function f([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-name-iter-val.js b/js/src/tests/test262/language/statements/function/dstr/ary-name-iter-val.js new file mode 100644 index 0000000000..bc5c3ba848 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-name-iter-val.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding with normal value iteration (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..ef33c24e34 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..3b0405e941 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; +f([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..18da2bd987 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function f([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..0dfcd5333e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +function f([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; +f([[]]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..df20a2052e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +function f([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..9adfd86715 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +function f([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f([[23]]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..bd28052df5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +function f([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..e04582bb72 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +function f([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f([values]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..d553ad96ac --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Nested array destructuring with a null value (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +function f([[x]]) {} + +assert.throws(TypeError, function() { + f([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..008f37c4bf --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Destructuring initializer with an exhausted iterator (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..67b63f246a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding does assign name to arrow functions (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..ddecbe6b96 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..450bcdbc3f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..ede01e6f42 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..07c213741a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +function f([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..fdc6489113 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Destructuring initializer with a "hole" (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; +f([,]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..580f912c6a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function f([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f([null, 0, false, '']); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..5d1515520e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Destructuring initializer returns an abrupt completion (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +function f([x = (function() { throw new Test262Error(); })()]) {} + +assert.throws(Test262Error, function() { + f([undefined]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..fad5ab108f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Destructuring initializer with an undefined value (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f([undefined]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..c545fd680d --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +function f([ x = unresolvableReference ]) {} + +assert.throws(ReferenceError, function() { + f([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..db500d9a23 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding when value iteration completes (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..80160c24bd --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding when value iteration was completed previously (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..a61a89af9c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +function f([x]) {} + +assert.throws(Test262Error, function() { + f(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..ed9132b868 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + b. If next is an abrupt completion, set iteratorRecord.[[Done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[Done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[Done]] to true. + iii. ReturnIfAbrupt(v). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +function f([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; +}; +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..b226203dbd --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +function f([x]) {} + +assert.throws(Test262Error, function() { + f(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..235d76f129 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding when value iteration was completed previously (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..ee6d5e6e9b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is used (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..5b6b7c5d46 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; +f([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..05b0b7b119 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is used (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..98bb7c4229 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..78d41ccd06 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Nested object destructuring with a null value (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +function f([{ x }]) {} + +assert.throws(TypeError, function() { + f([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..ebc74d9197 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Nested object destructuring with a value of `undefined` (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +function f([{ x }]) {} + +assert.throws(TypeError, function() { + f([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..70b014538d --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elision-exhausted.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Elision accepts exhausted iterator (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +function f([,]) { + + callCount = callCount + 1; +}; +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..8b3ce84951 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elision-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Elision advances iterator and forwards abrupt completions (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +function f([,]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elision.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elision.js new file mode 100644 index 0000000000..27466cd07e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-elision.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Elision advances iterator (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function f([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f(g()); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-empty.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-empty.js new file mode 100644 index 0000000000..6bb86e3360 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-empty.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +function f([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..7fc9c3df53 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-elem.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element containing an array BindingElementList pattern (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; +f([3, 4, 5]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..06c692fa68 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-elision.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element containing an elision (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function f([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; +f(g()); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..6707ef04a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-empty.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element containing an "empty" array pattern (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +function f([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..206cdb6c90 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-ary-rest.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element containing a rest element (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +function f([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; +f(values); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..3a207e8774 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-direct.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Lone rest element (direct binding) (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +includes: [compareArray.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +function f([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; +}; +f([1]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..0f65e18e61 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Rest element following elision elements (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +function f([, ...x]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..bc81108aae --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-elision.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element following elision elements (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +function f([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f(values); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..021b307443 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: RestElement applied to an exhausted iterator (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +function f([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; +f([1, 2]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..930983759b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +function f([...x]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..c8533c0a22 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +function f([...x]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id.js new file mode 100644 index 0000000000..915317ebc7 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Lone rest element (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +function f([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f(values); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..6769219b28 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-init-ary.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element (nested array pattern) does not support initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +function f([...[ x ] = []]) { + + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..57a4cae64b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-init-id.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element (identifier) does not support initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +function f([...x = []]) { + + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..fc213f29da --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-init-obj.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element (nested object pattern) does not support initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +function f([...{ x } = []]) { + + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..82809bed78 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +function f([...[x], y]) { + + callCount = callCount + 1; +}; +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..299ccae4c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-not-final-id.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element (identifier) may not be followed by any element (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +function f([...x, y]) { + + callCount = callCount + 1; +}; +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..4f27fa7019 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +function f([...{ x }, y]) { + + callCount = callCount + 1; +}; +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..e5d140ebb7 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-obj-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element containing an object binding pattern (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +function f([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..dea5b3d8d8 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element containing an object binding pattern (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +function f([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; +}; +f([7, 8, 9]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/browser.js b/js/src/tests/test262/language/statements/function/dstr/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-close.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..039b9798ba --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +function f([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..1e0021e44c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + +function f([x, y, z] = [1, 2, 3]) {} + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..88ebad721d --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-get-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +function f([x] = iter) {} + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..24526e9912 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-init-iter-no-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +function f([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-name-iter-val.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..50fcc1e4be --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-name-iter-val.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..b182579632 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..135ddd3924 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..1f6701b728 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function f([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..4d438b5513 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +function f([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..d77e901c6a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +function f([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..b2e73e1ea1 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +function f([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..be32264182 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +function f([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..f050e0b167 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +function f([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..537a4ced79 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Nested array destructuring with a null value (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +function f([[x]] = [null]) {} + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..a18c222d95 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..fb7560ea7e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..35208ee9e1 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..3e02e20c1c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..457a5316b0 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..d11c7f8166 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +function f([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..721ae98e27 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Destructuring initializer with a "hole" (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..e2295a9544 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function f([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..9991a0a209 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +function f([x = (function() { throw new Test262Error(); })()] = [undefined]) {} + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..be4ea2e15e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Destructuring initializer with an undefined value (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..36e4bd7351 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +function f([ x = unresolvableReference ] = []) {} + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..0caf1bd485 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..398c727a6b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..33ad782552 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +function f([x] = g) {} + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..9478c13693 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + b. If next is an abrupt completion, set iteratorRecord.[[Done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[Done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[Done]] to true. + iii. ReturnIfAbrupt(v). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +function f([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..febb36ce8e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +function f([x] = g) {} + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..dda695d302 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..d617e8d319 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..10e3ed6ce0 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..f26d8a00cd --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..84566fd64f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..90606b282d --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Nested object destructuring with a null value (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +function f([{ x }] = [null]) {} + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..e3e5a528ad --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +function f([{ x }] = []) {} + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..d73336b34a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Elision accepts exhausted iterator (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +function f([,] = iter) { + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..5afec0d420 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +function f([,] = iter) {} + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..9c396ff442 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-elision.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Elision advances iterator (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function f([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..6b2aa6810a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-empty.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +function f([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..24cdea25a2 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..6064ae16ce --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element containing an elision (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function f([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..439abacd1a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +function f([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..9b7f87af9c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element containing a rest element (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +function f([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..787abfb1ce --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Lone rest element (direct binding) (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [compareArray.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +function f([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..79d37c6562 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Rest element following elision elements (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +function f([, ...x] = iter) {} + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..5f202dfb07 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element following elision elements (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +function f([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..745537ba41 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +function f([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..c7f07ca0c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +function f([...x] = iter) {} + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..07ff4eebf2 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +function f([...x] = iter) {} + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..f55e8075cb --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Lone rest element (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +function f([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..55568d3607 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +function f([...[ x ] = []] = []) { + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..3b42cf7732 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +function f([...x = []] = []) { + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..68324d49a1 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +function f([...{ x } = []] = []) { + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..aa2c49a263 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +function f([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..e5586adfdd --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +function f([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..987af5c16b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +function f([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..1d9e9a564d --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element containing an object binding pattern (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +function f([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..40b6632b4f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element containing an object binding pattern (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +function f([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-init-null.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-init-null.js new file mode 100644 index 0000000000..3d1c31c1d7 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-init-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +function f({} = null) {} + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-init-undefined.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-init-undefined.js new file mode 100644 index 0000000000..7721c9a624 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-init-undefined.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +function f({} = undefined) {} + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..e33f6dbb9d --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-empty.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +function f({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..c8b824ba4a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +function f({ poisoned } = poisonedProperty) {} + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..f762208a95 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..ce7c96c8e8 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..cbfe8f198a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..4447d04188 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..b63faed164 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +function f({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..c6e73db2f9 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function f({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..6da01e2fef --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error thrown when evaluating the initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +function f({ x = thrower() } = {}) {} + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..7ae174d219 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +function f({ x = unresolvableReference } = {}) {} + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..9df9b6455b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function f({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..f42fcca11f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-list-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +function f({ a, b = thrower(), c = ++initCount } = {}) {} + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..628ff18100 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..edf33341c0 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function f({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..876bbe8ec0 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +function f({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..b3de9df33d --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..a931cd9ae3 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +function f({ [thrower()]: x } = {}) {} + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..53f7517c0f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +function f({ poisoned: x = ++initEvalCount } = poisonedProperty) {} + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..a506f0e9d1 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function f({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..319d22efb3 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error thrown when evaluating the initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +function f({ x: y = thrower() } = {}) {} + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..6cb94987cd --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +function f({ x: y = unresolvableReference } = {}) {} + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..deb3ad15eb --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..b27c7bd0fd --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function f({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..713545b927 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-id.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Binding as specified via property name and identifier (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..6b13689b61 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..c744de7878 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +function f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..59a91bc79b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +function f({ w: { x, y, z } = undefined } = { }) {} + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..fcf5954fb0 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..fc3c63ae84 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +function f({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..654d65653f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +function f({...rest} = o) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..e7f8f49ef4 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest object contains just unextracted data (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function f({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-init-null.js b/js/src/tests/test262/language/statements/function/dstr/obj-init-null.js new file mode 100644 index 0000000000..b817199ea0 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-init-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +function f({}) {} + +assert.throws(TypeError, function() { + f(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-init-undefined.js b/js/src/tests/test262/language/statements/function/dstr/obj-init-undefined.js new file mode 100644 index 0000000000..83d41c0e7f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-init-undefined.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +function f({}) {} + +assert.throws(TypeError, function() { + f(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-empty.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-empty.js new file mode 100644 index 0000000000..aa44acee8f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-empty.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: No property access occurs for an "empty" object binding pattern (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +function f({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; +f(obj); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..5090974f20 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +function f({ poisoned }) {} + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..d3018ea20a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..fc3141f965 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; +}; +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..0e008931e5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..4c676d43fc --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..8d230f9944 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [generators, destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +function f({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..442871f0a7 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-skipped.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function f({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..6fb2199826 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error thrown when evaluating the initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +function f({ x = thrower() }) {} + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..f430b91bd8 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +function f({ x = unresolvableReference }) {} + +assert.throws(ReferenceError, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..06e423f28a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-id-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function f({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f({ x: 23 }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-list-err.js new file mode 100644 index 0000000000..1b8b9b738c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-list-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +function f({ a, b = thrower(), c = ++initCount }) {} + +assert.throws(Test262Error, function() { + f({}); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..e1b46c0e04 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..087edd0332 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function f({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; +}; +f({ x: [45] }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..f2dfe9c805 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +function f({ w: [x, y, z] = [4, 5, 6] }) {} + +assert.throws(TypeError, function() { + f({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..a9ae0983da --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-ary.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..f67a272d53 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-eval-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Evaluation of property name returns an abrupt completion (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +function f({ [thrower()]: x }) {} + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..10a30cdb80 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +function f({ poisoned: x = ++initEvalCount }) {} + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..08c0924fd2 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function f({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..cdcc2c0f92 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error thrown when evaluating the initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +function f({ x: y = thrower() }) {} + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..20030ee0b1 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +function f({ x: y = unresolvableReference }) {} + +assert.throws(ReferenceError, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..bac8c645c6 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-init.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Binding as specified via property name, identifier, and initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f({ }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..7343bb53be --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function f({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f({ x: 23 }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id.js new file mode 100644 index 0000000000..9d22fca341 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-id.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Binding as specified via property name and identifier (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f({ x: 23 }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..c6fd892b1f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({ w: undefined }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..907d817a48 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +function f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} + +assert.throws(TypeError, function() { + f({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..32fcb08bec --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +function f({ w: { x, y, z } = undefined }) {} + +assert.throws(TypeError, function() { + f({ }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..6a3dceffab --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-prop-obj.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..202ae80c82 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-rest-getter.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +function f({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; +}; +f({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..13cc15ec3f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest object doesn't contain non-enumerable properties (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +function f({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; +}; +f(o); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..3a84a74a5f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/dstr/obj-ptrn-rest-val-obj.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest object contains just unextracted data (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function f({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; +}; +f({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/dstr/shell.js b/js/src/tests/test262/language/statements/function/dstr/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/function/early-body-super-call.js b/js/src/tests/test262/language/statements/function/early-body-super-call.js new file mode 100644 index 0000000000..cd84ccbe9a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/early-body-super-call.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// 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-function-definitions-static-semantics-early-errors +es6id: 14.1.2 +description: Body may not contain a "super" call +info: | + It is a Syntax Error if FunctionBody Contains SuperCall is true. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function f() { + super(); +} diff --git a/js/src/tests/test262/language/statements/function/early-body-super-prop.js b/js/src/tests/test262/language/statements/function/early-body-super-prop.js new file mode 100644 index 0000000000..4ad4324620 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/early-body-super-prop.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// 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-function-definitions-static-semantics-early-errors +es6id: 14.1.2 +description: Body may not contain a "super" property reference +info: | + It is a Syntax Error if FunctionBody Contains SuperProperty is true. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function f() { + super.x; +} diff --git a/js/src/tests/test262/language/statements/function/early-errors/browser.js b/js/src/tests/test262/language/statements/function/early-errors/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/function/early-errors/invalid-names-call-expression-bad-reference.js b/js/src/tests/test262/language/statements/function/early-errors/invalid-names-call-expression-bad-reference.js new file mode 100644 index 0000000000..d7e43cbd3c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/early-errors/invalid-names-call-expression-bad-reference.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-bad-reference.case +// - src/invalid-private-names/default/function-decl.template +/*--- +description: bad reference in call expression (Invalid private names should throw a SyntaxError, inside function declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +function fn() { (() => {})().#x } diff --git a/js/src/tests/test262/language/statements/function/early-errors/invalid-names-call-expression-this.js b/js/src/tests/test262/language/statements/function/early-errors/invalid-names-call-expression-this.js new file mode 100644 index 0000000000..eb7b2b5f8b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/early-errors/invalid-names-call-expression-this.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-this.case +// - src/invalid-private-names/default/function-decl.template +/*--- +description: this evaluated in call expression (Invalid private names should throw a SyntaxError, inside function declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +function fn() { (() => this)().#x } diff --git a/js/src/tests/test262/language/statements/function/early-errors/invalid-names-member-expression-bad-reference.js b/js/src/tests/test262/language/statements/function/early-errors/invalid-names-member-expression-bad-reference.js new file mode 100644 index 0000000000..af2df59e63 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/early-errors/invalid-names-member-expression-bad-reference.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-bad-reference.case +// - src/invalid-private-names/default/function-decl.template +/*--- +description: bad reference in member expression (Invalid private names should throw a SyntaxError, inside function declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +function fn() { something.#x } diff --git a/js/src/tests/test262/language/statements/function/early-errors/invalid-names-member-expression-this.js b/js/src/tests/test262/language/statements/function/early-errors/invalid-names-member-expression-this.js new file mode 100644 index 0000000000..029da1500e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/early-errors/invalid-names-member-expression-this.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-this.case +// - src/invalid-private-names/default/function-decl.template +/*--- +description: this reference in member expression (Invalid private names should throw a SyntaxError, inside function declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +function fn() { this.#x } diff --git a/js/src/tests/test262/language/statements/function/early-errors/shell.js b/js/src/tests/test262/language/statements/function/early-errors/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/function/early-params-super-call.js b/js/src/tests/test262/language/statements/function/early-params-super-call.js new file mode 100644 index 0000000000..2d107196eb --- /dev/null +++ b/js/src/tests/test262/language/statements/function/early-params-super-call.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// 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-function-definitions-static-semantics-early-errors +es6id: 14.1.2 +description: Parameters may not contain a "super" call +info: | + It is a Syntax Error if FormalParameters Contains SuperProperty is true. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function f(x = super()) {} diff --git a/js/src/tests/test262/language/statements/function/early-params-super-prop.js b/js/src/tests/test262/language/statements/function/early-params-super-prop.js new file mode 100644 index 0000000000..2be0153bdf --- /dev/null +++ b/js/src/tests/test262/language/statements/function/early-params-super-prop.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// 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-function-definitions-static-semantics-early-errors +es6id: 14.1.2 +description: Parameters may not contain a "super" property reference +info: | + It is a Syntax Error if FunctionBody Contains SuperProperty is true. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function f(x = super.x) {} diff --git a/js/src/tests/test262/language/statements/function/enable-strict-via-body.js b/js/src/tests/test262/language/statements/function/enable-strict-via-body.js new file mode 100644 index 0000000000..7a979deaa8 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/enable-strict-via-body.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13; + The production FunctionBody : SourceElementsopt is evaluated as follows: +es5id: 13.0-10-s +description: > + Strict Mode - SourceElements is evaluated as strict mode code when + the code of this FunctionBody with an inner function contains a + Use Strict Directive +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_0_10_fun() { + function _13_0_10_inner() { + "use strict"; + eval = 42; + } +} diff --git a/js/src/tests/test262/language/statements/function/enable-strict-via-outer-body.js b/js/src/tests/test262/language/statements/function/enable-strict-via-outer-body.js new file mode 100644 index 0000000000..1183ffc0d5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/enable-strict-via-outer-body.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13; + The production FunctionBody : SourceElementsopt is evaluated as follows: +es5id: 13.0-11-s +description: > + Strict Mode - SourceElements is evaluated as strict mode code when + the code of this FunctionBody with an inner function which is in + strict mode +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_0_11_fun() { + "use strict"; + function _13_0_11_inner() { + eval = 42; + } +} diff --git a/js/src/tests/test262/language/statements/function/enable-strict-via-outer-script-strict.js b/js/src/tests/test262/language/statements/function/enable-strict-via-outer-script-strict.js new file mode 100644 index 0000000000..050860b245 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/enable-strict-via-outer-script-strict.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13; + The production FunctionBody : SourceElementsopt is evaluated as follows: +es5id: 13.0-9-s +description: > + Strict Mode - SourceElements is evaluated as strict mode code when + a FunctionDeclaration that is contained in strict mode code has an + inner function +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +var _13_0_9_fun = function () { + function _13_0_9_inner() { + eval = 42; + } +}; diff --git a/js/src/tests/test262/language/statements/function/eval-var-scope-syntax-err.js b/js/src/tests/test262/language/statements/function/eval-var-scope-syntax-err.js new file mode 100644 index 0000000000..00e562e634 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/eval-var-scope-syntax-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/eval-var-scope-syntax-err.case +// - src/function-forms/error-no-strict/func-decl.template +/*--- +description: sloppy direct eval in params introduces var (function declaration in sloppy code) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [default-parameters] +flags: [generated, noStrict] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + Runtime Semantics: IteratorBindingInitialization + FormalParameter : BindingElement + + 1. Return the result of performing IteratorBindingInitialization for BindingElement with arguments iteratorRecord and environment. + +---*/ + +var callCount = 0; +function f(a = eval("var a = 42")) { + + callCount = callCount + 1; +} +assert.throws(SyntaxError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/statements/function/forbidden-ext/b1/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/function/forbidden-ext/b1/cls-expr-meth-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/statements/function/forbidden-ext/b1/cls-expr-meth-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..88c54bd38f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/forbidden-ext/b1/cls-expr-meth-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-arguments.case +// - src/function-forms/forbidden-extensions/bullet-one/func-decl-strict.template +/*--- +description: Forbidden extension, f.arguments (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +flags: [generated, noStrict] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + +var callCount = 0; +function f() { + "use strict"; + assert.sameValue(f.hasOwnProperty("arguments"), false); + callCount++; +} + +f(); +assert.sameValue(callCount, 1, 'function body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/forbidden-ext/b1/cls-expr-meth-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/statements/function/forbidden-ext/b1/cls-expr-meth-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..6a5038a200 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/forbidden-ext/b1/cls-expr-meth-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-one/func-decl-strict.template +/*--- +description: Forbidden extension, o.caller (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +flags: [generated, noStrict] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + +var callCount = 0; +function f() { + "use strict"; + assert.sameValue(f.hasOwnProperty("caller"), false); + callCount++; +} + +f(); +assert.sameValue(callCount, 1, 'function body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/statements/function/forbidden-ext/b1/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/function/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/statements/function/forbidden-ext/b2/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/function/forbidden-ext/b2/func-decl-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/statements/function/forbidden-ext/b2/func-decl-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..3a981a7dfe --- /dev/null +++ b/js/src/tests/test262/language/statements/function/forbidden-ext/b2/func-decl-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-get.case +// - src/function-forms/forbidden-extensions/bullet-two/func-decl.template +/*--- +description: Forbidden extension, o.caller (function declaration) +esid: sec-definitions-runtime-semantics-instantiatefunctionobject +flags: [generated, noStrict] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +function f() { + "use strict"; + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + // the same templates. + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {get(){return 1}}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, f); + } + + callCount++; +} +f(); +assert.sameValue(callCount, 1, 'body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/forbidden-ext/b2/func-decl-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/statements/function/forbidden-ext/b2/func-decl-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..2e50f86d61 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/forbidden-ext/b2/func-decl-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-value.case +// - src/function-forms/forbidden-extensions/bullet-two/func-decl.template +/*--- +description: Forbidden extension, o.caller (function declaration) +esid: sec-definitions-runtime-semantics-instantiatefunctionobject +flags: [generated, noStrict] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +function f() { + "use strict"; + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + // the same templates. + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {value: 1}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, f); + } + + callCount++; +} +f(); +assert.sameValue(callCount, 1, 'body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/forbidden-ext/b2/func-decl-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/statements/function/forbidden-ext/b2/func-decl-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..c00df08a17 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/forbidden-ext/b2/func-decl-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-two/func-decl.template +/*--- +description: Forbidden extension, o.caller (function declaration) +esid: sec-definitions-runtime-semantics-instantiatefunctionobject +flags: [generated, noStrict] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +function f() { + "use strict"; + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + // the same templates. + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && false) { + Object.defineProperty(inner, "caller", {}); + } + var result = inner(); + if (descriptor && descriptor.configurable && false) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, f); + } + + callCount++; +} +f(); +assert.sameValue(callCount, 1, 'body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/statements/function/forbidden-ext/b2/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/function/forbidden-ext/browser.js b/js/src/tests/test262/language/statements/function/forbidden-ext/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/function/forbidden-ext/shell.js b/js/src/tests/test262/language/statements/function/forbidden-ext/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/function/invalid-2-names.js b/js/src/tests/test262/language/statements/function/invalid-2-names.js new file mode 100644 index 0000000000..06ee6ac865 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/invalid-2-names.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.0-1 +description: > + 13.0 - multiple names in one function declaration is not allowed, + two function names +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function x, y() {} diff --git a/js/src/tests/test262/language/statements/function/invalid-3-names.js b/js/src/tests/test262/language/statements/function/invalid-3-names.js new file mode 100644 index 0000000000..24c29baa3e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/invalid-3-names.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.0-2 +description: > + 13.0 - multiple names in one function declaration is not allowed, + three function names +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function x,y,z(){} diff --git a/js/src/tests/test262/language/statements/function/invalid-function-body-1.js b/js/src/tests/test262/language/statements/function/invalid-function-body-1.js new file mode 100644 index 0000000000..ebc94ad540 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/invalid-function-body-1.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The FunctionBody must be SourceElements +es5id: 13_A7_T2 +description: > + Inserting elements that is different from SourceElements into the + FunctionBody +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function __func(){/ ABC} diff --git a/js/src/tests/test262/language/statements/function/invalid-function-body-2.js b/js/src/tests/test262/language/statements/function/invalid-function-body-2.js new file mode 100644 index 0000000000..3078d4f403 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/invalid-function-body-2.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The FunctionBody must be SourceElements +es5id: 13_A7_T2 +description: > + Inserting elements that is different from SourceElements into the + FunctionBody +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function __func(){&1} diff --git a/js/src/tests/test262/language/statements/function/invalid-function-body-3.js b/js/src/tests/test262/language/statements/function/invalid-function-body-3.js new file mode 100644 index 0000000000..785a5b33cf --- /dev/null +++ b/js/src/tests/test262/language/statements/function/invalid-function-body-3.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The FunctionBody must be SourceElements +es5id: 13_A7_T2 +description: > + Inserting elements that is different from SourceElements into the + FunctionBody +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function __func(){# ABC} diff --git a/js/src/tests/test262/language/statements/function/invalid-name-dot.js b/js/src/tests/test262/language/statements/function/invalid-name-dot.js new file mode 100644 index 0000000000..9a12bd3a96 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/invalid-name-dot.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.0-3 +description: > + 13.0 - property names in function definition is not allowed, add a + new property into object +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function obj.tt() {} diff --git a/js/src/tests/test262/language/statements/function/invalid-name-two-dots.js b/js/src/tests/test262/language/statements/function/invalid-name-two-dots.js new file mode 100644 index 0000000000..19dadd5fdb --- /dev/null +++ b/js/src/tests/test262/language/statements/function/invalid-name-two-dots.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.0-4 +description: > + 13.0 - multiple names in one function declaration is not allowed, + add a new property into a property which is a object +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function obj.tt.ss() {} diff --git a/js/src/tests/test262/language/statements/function/length-dflt.js b/js/src/tests/test262/language/statements/function/length-dflt.js new file mode 100644 index 0000000000..e778ff2b9f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/length-dflt.js @@ -0,0 +1,62 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +function f1(x = 42) {} + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +function f2(x = 42, y) {} + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +function f3(x, y = 42) {} + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +function f4(x, y = 42, z) {} + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/line-terminator.js b/js/src/tests/test262/language/statements/function/line-terminator.js new file mode 100644 index 0000000000..f841d2e85e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/line-terminator.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: Any separators are admitted between declaration chunks +es5id: 13_A16 +description: Inserting separators between declaration chunks +---*/ + +function +x +( +) +{ +} +; + +x(); + +function y ( ) {}; + +y(); + +function + +z + +( + +) + +{ + +} + +; + +z(); + +// The following function expression is expressed with literal unicode +// characters so that parsers may benefit from this test. The included code +// points are as follows: +// +// "function\u0009\u2029w(\u000C)\u00A0{\u000D}" + +function 
w( ) { } + +w(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/name-arguments-non-strict.js b/js/src/tests/test262/language/statements/function/name-arguments-non-strict.js new file mode 100644 index 0000000000..97deb71691 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/name-arguments-non-strict.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: 13.1-3-7 +description: > + arguments allowed as function identifier in non-strict function + declaration +flags: [noStrict] +---*/ + +function arguments (){} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/name-arguments-strict-body.js b/js/src/tests/test262/language/statements/function/name-arguments-strict-body.js new file mode 100644 index 0000000000..e91e3fe4de --- /dev/null +++ b/js/src/tests/test262/language/statements/function/name-arguments-strict-body.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.1-40-s +description: > + StrictMode - SyntaxError is thrown if 'arguments' occurs as the + Identifier of a FunctionDeclaration whose FunctionBody is + contained in strict code +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +function arguments() { 'use strict'; } diff --git a/js/src/tests/test262/language/statements/function/name-arguments-strict-strict.js b/js/src/tests/test262/language/statements/function/name-arguments-strict-strict.js new file mode 100644 index 0000000000..40465ca380 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/name-arguments-strict-strict.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.1-13-s +description: > + StrictMode - SyntaxError is thrown if 'arguments' occurs as the + function name of a FunctionDeclaration in strict mode +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +function arguments() { } diff --git a/js/src/tests/test262/language/statements/function/name-eval-non-strict.js b/js/src/tests/test262/language/statements/function/name-eval-non-strict.js new file mode 100644 index 0000000000..d1d8f2c358 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/name-eval-non-strict.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: 13.1-3-1 +description: > + eval allowed as function identifier in non-strict function + declaration +flags: [noStrict] +---*/ + +function eval(){} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/name-eval-strict-body.js b/js/src/tests/test262/language/statements/function/name-eval-strict-body.js new file mode 100644 index 0000000000..5a4d885cba --- /dev/null +++ b/js/src/tests/test262/language/statements/function/name-eval-strict-body.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.1-36-s +description: > + StrictMode - SyntaxError is thrown if 'eval' occurs as the + function name of a FunctionDeclaration whose FunctionBody is in + strict mode +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +function eval() { 'use strict'; } diff --git a/js/src/tests/test262/language/statements/function/name-eval-strict-strict.js b/js/src/tests/test262/language/statements/function/name-eval-strict-strict.js new file mode 100644 index 0000000000..a76ad3cb4e --- /dev/null +++ b/js/src/tests/test262/language/statements/function/name-eval-strict-strict.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 13.1-11-s +description: > + StrictMode - SyntaxError is thrown if 'eval' occurs as the + function name of a FunctionDeclaration in strict mode +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +function eval() { } diff --git a/js/src/tests/test262/language/statements/function/name-eval-stricteval.js b/js/src/tests/test262/language/statements/function/name-eval-stricteval.js new file mode 100644 index 0000000000..216b38e314 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/name-eval-stricteval.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. + +/*--- +es5id: 13.1-35-s +description: > + StrictMode - SyntaxError is thrown if 'eval' occurs as the + function name of a FunctionDeclaration in strict eval code +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("'use strict'; function eval() { };") +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/name-unicode.js b/js/src/tests/test262/language/statements/function/name-unicode.js new file mode 100644 index 0000000000..da927b78b1 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/name-unicode.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Unicode symbols in function name are allowed +es5id: 13_A14 +description: Defining function name with unicode symbols +---*/ + +var funcA = eval("function __func\u0041(__arg){return __arg;}; __funcA"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof funcA !== "function") { + throw new Test262Error('#1: unicode symbols in function name are allowed'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/name.js b/js/src/tests/test262/language/statements/function/name.js new file mode 100644 index 0000000000..93338dfdd9 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/name.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. + +/*--- +es6id: 14.1.19 +description: Assignment of function `name` attribute +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + 1. Let name be StringValue of BindingIdentifier. + 2. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, scope, strict). + 3. Perform MakeConstructor(F). + 4. Perform SetFunctionName(F, name). + 5. Return F. +includes: [propertyHelper.js] +---*/ + +function func() {} + +assert.sameValue(func.name, 'func'); +verifyNotEnumerable(func, 'name'); +verifyNotWritable(func, 'name'); +verifyConfigurable(func, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/object-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/function/object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..149dd218e2 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/object-destructuring-param-strict-body.js @@ -0,0 +1,134 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/object-destructuring-param-strict-body.case +// - src/function-forms/syntax/func-decl.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +function f({property}) { + "use strict"; +} diff --git a/js/src/tests/test262/language/statements/function/param-arguments-non-strict.js b/js/src/tests/test262/language/statements/function/param-arguments-non-strict.js new file mode 100644 index 0000000000..a2560e4ddc --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-arguments-non-strict.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: 13.1-2-5 +description: > + arguments allowed as formal parameter name of a non-strict + function declaration +flags: [noStrict] +---*/ + +function foo(arguments){} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/param-arguments-strict-body.js b/js/src/tests/test262/language/statements/function/param-arguments-strict-body.js new file mode 100644 index 0000000000..00f6f5eaff --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-arguments-strict-body.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs within a FormalParameterList + of a strict mode FunctionDeclaration or FunctionExpression. +es5id: 13.1-20-s +description: > + StrictMode - SyntaxError is thrown if the identifier 'arguments' + appears within a FormalParameterList of a strict mode + FunctionDeclaration when FuctionBody is strict code +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_1_20_fun(arguments) { 'use strict'; } diff --git a/js/src/tests/test262/language/statements/function/param-arguments-strict-strict.js b/js/src/tests/test262/language/statements/function/param-arguments-strict-strict.js new file mode 100644 index 0000000000..d44504efe9 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-arguments-strict-strict.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs within a FormalParameterList + of a strict mode FunctionDeclaration or FunctionExpression. +es5id: 13.1-3-s +description: > + Strict Mode - SyntaxError is thrown if the identifier 'arguments' + appears within a FormalParameterList of a strict mode + FunctionDeclaration +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_1_3_fun(arguments) { } diff --git a/js/src/tests/test262/language/statements/function/param-dflt-yield-non-strict.js b/js/src/tests/test262/language/statements/function/param-dflt-yield-non-strict.js new file mode 100644 index 0000000000..88e2dfa599 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-dflt-yield-non-strict.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-function-definitions +es6id: 14.1 +description: > + The `yield` token is interpreted as an IdentifierReference within a generator + and outside of strict mode +info: | + FunctionDeclaration[Yield, Default] : + function BindingIdentifier[?Yield] ( FormalParameters ) { FunctionBody } +features: [generators, default-parameters] +flags: [noStrict] +---*/ + +var yield = 23; +var paramValue; + +function *g() { + function f(x = yield) { + paramValue = x; + } + + f(); +} + +g().next(); + +assert.sameValue(paramValue, 23); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/param-dflt-yield-strict-strict.js b/js/src/tests/test262/language/statements/function/param-dflt-yield-strict-strict.js new file mode 100644 index 0000000000..fbe3a93199 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-dflt-yield-strict-strict.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +'use strict'; +// 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-function-definitions +es6id: 14.1 +description: > + The `yield` token is interpreted as an IdentifierReference within a generator + and outside of strict mode +info: | + FunctionDeclaration[Yield, Default] : + function BindingIdentifier[?Yield] ( FormalParameters ) { FunctionBody } +features: [generators, default-parameters] +flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function *g() { + function f(x = yield) { + paramValue = x; + } +} diff --git a/js/src/tests/test262/language/statements/function/param-duplicated-non-strict.js b/js/src/tests/test262/language/statements/function/param-duplicated-non-strict.js new file mode 100644 index 0000000000..af154b8f3a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-duplicated-non-strict.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: 13.1-1-1 +description: > + Duplicate identifier allowed in non-strict function declaration + parameter list +flags: [noStrict] +---*/ + +function foo(a,a){} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/param-duplicated-strict-1-strict.js b/js/src/tests/test262/language/statements/function/param-duplicated-strict-1-strict.js new file mode 100644 index 0000000000..f441c2c604 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-duplicated-strict-1-strict.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if any Identifier value occurs more than once within a FormalParameterList of a strict mode + FunctionDeclaration or FunctionExpression. +es5id: 13.1-5-s +description: > + Strict Mode - SyntaxError is thrown if a function is declared in + 'strict mode' using a FunctionDeclaration and the function has two + identical parameters +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_1_5_fun(param, param) { } diff --git a/js/src/tests/test262/language/statements/function/param-duplicated-strict-2-strict.js b/js/src/tests/test262/language/statements/function/param-duplicated-strict-2-strict.js new file mode 100644 index 0000000000..6aac7f99d0 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-duplicated-strict-2-strict.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if any Identifier value occurs more than once within a FormalParameterList of a strict mode + FunctionDeclaration or FunctionExpression. +es5id: 13.1-6-s +description: > + Strict Mode - SyntaxError is thrown if a function is created in + 'strict mode' using a FunctionDeclaration and the function has two + identical parameters, which are separated by a unique parameter + name +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_1_6_fun(param1, param2, param1) { } diff --git a/js/src/tests/test262/language/statements/function/param-duplicated-strict-3-strict.js b/js/src/tests/test262/language/statements/function/param-duplicated-strict-3-strict.js new file mode 100644 index 0000000000..8fed56b53f --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-duplicated-strict-3-strict.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if any Identifier value occurs more than once within a FormalParameterList of a strict mode + FunctionDeclaration or FunctionExpression. +es5id: 13.1-7-s +description: > + Strict Mode - SyntaxError is thrown if a function is created in + 'strict mode' using a FunctionDeclaration and the function has + three identical parameters +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_1_7_fun(param, param, param) { } diff --git a/js/src/tests/test262/language/statements/function/param-duplicated-strict-body-1.js b/js/src/tests/test262/language/statements/function/param-duplicated-strict-body-1.js new file mode 100644 index 0000000000..80a96a8223 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-duplicated-strict-body-1.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if any Identifier value occurs more than once within a FormalParameterList of a strict mode + FunctionDeclaration or FunctionExpression. +es5id: 13.1-24-s +description: > + Strict Mode - SyntaxError is thrown if a function is created using + a FunctionDeclaration whose FunctionBody is contained in strict + code and the function has two identical parameters +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_1_24_fun(param, param) { 'use strict'; } diff --git a/js/src/tests/test262/language/statements/function/param-duplicated-strict-body-2.js b/js/src/tests/test262/language/statements/function/param-duplicated-strict-body-2.js new file mode 100644 index 0000000000..e7aa120deb --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-duplicated-strict-body-2.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if any Identifier value occurs more than once within a FormalParameterList of a strict mode + FunctionDeclaration or FunctionExpression. +es5id: 13.1-26-s +description: > + Strict Mode - SyntaxError is thrown if a function is created using + a FunctionDeclaration whose FunctionBody is contained in strict + code and the function has two identical parameters which are + separated by a unique parameter name +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_1_26_fun(param1, param2, param1) { 'use strict'; } diff --git a/js/src/tests/test262/language/statements/function/param-duplicated-strict-body-3.js b/js/src/tests/test262/language/statements/function/param-duplicated-strict-body-3.js new file mode 100644 index 0000000000..436895af98 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-duplicated-strict-body-3.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if any Identifier value occurs more than once within a FormalParameterList of a strict mode + FunctionDeclaration or FunctionExpression. +es5id: 13.1-28-s +description: > + Strict Mode - SyntaxError is thrown if a function is created using + a FunctionDeclaration whose FunctionBody is contained in strict + code and the function has three identical parameters +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_1_28_fun(param, param, param) { 'use strict'; } diff --git a/js/src/tests/test262/language/statements/function/param-eval-non-strict-is-correct-value.js b/js/src/tests/test262/language/statements/function/param-eval-non-strict-is-correct-value.js new file mode 100644 index 0000000000..9ff385873a --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-eval-non-strict-is-correct-value.js @@ -0,0 +1,23 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-strict-mode-of-ecmascript +description: > + eval allowed as formal parameter name of a non-strict function declaration +flags: [noStrict] +---*/ + +let exprCallCount = 0; +let evalValue = {}; + +function foo(eval) { + assert.sameValue(eval, evalValue); + exprCallCount += 1; +} + +foo(evalValue); + +assert.sameValue(exprCallCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/param-eval-non-strict.js b/js/src/tests/test262/language/statements/function/param-eval-non-strict.js new file mode 100644 index 0000000000..71c2e5865b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-eval-non-strict.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: 13.1-2-1 +description: > + eval allowed as formal parameter name of a non-strict function + declaration +flags: [noStrict] +---*/ + +function foo(eval){}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/param-eval-strict-body.js b/js/src/tests/test262/language/statements/function/param-eval-strict-body.js new file mode 100644 index 0000000000..f98ff29772 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-eval-strict-body.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs within a FormalParameterList + of a strict mode FunctionDeclaration or FunctionExpression. +es5id: 13.1-16-s +description: > + StrictMode - SyntaxError is thrown if the identifier 'eval' + appears within a FormalParameterList of a strict mode + FunctionDeclaration when FuctionBody is strict code +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_1_16_fun(eval) { 'use strict'; } diff --git a/js/src/tests/test262/language/statements/function/param-eval-strict-strict.js b/js/src/tests/test262/language/statements/function/param-eval-strict-strict.js new file mode 100644 index 0000000000..870befd911 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-eval-strict-strict.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs within a FormalParameterList + of a strict mode FunctionDeclaration or FunctionExpression. +es5id: 13.1-1-s +description: > + Strict Mode - SyntaxError is thrown if the identifier 'eval' + appears within a FormalParameterList of a strict mode + FunctionDeclaration +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +function _13_1_1_fun(eval) { } diff --git a/js/src/tests/test262/language/statements/function/param-eval-stricteval.js b/js/src/tests/test262/language/statements/function/param-eval-stricteval.js new file mode 100644 index 0000000000..5d956fdc2c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/param-eval-stricteval.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. + +/*--- +info: | + Refer 13.1; + It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs within a FormalParameterList + of a strict mode FunctionDeclaration or FunctionExpression. +es5id: 13.1-15-s +description: > + Strict Mode - SyntaxError is thrown if the identifier 'eval' + appears within a FormalParameterList of a strict mode + FunctionDeclaration in strict eval code +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + eval("'use strict';function _13_1_15_fun(eval) { }"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/params-dflt-args-unmapped.js b/js/src/tests/test262/language/statements/function/params-dflt-args-unmapped.js new file mode 100644 index 0000000000..83269032e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/params-dflt-args-unmapped.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. +/*--- +description: Referencing the arguments object from a default parameter (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +function f(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; +} + +f(); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/params-dflt-ref-arguments.js b/js/src/tests/test262/language/statements/function/params-dflt-ref-arguments.js new file mode 100644 index 0000000000..522c276e85 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/params-dflt-ref-arguments.js @@ -0,0 +1,63 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +function f(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; +} + +f(undefined, undefined, 'third', 'fourth'); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/params-trailing-comma-multiple.js b/js/src/tests/test262/language/statements/function/params-trailing-comma-multiple.js new file mode 100644 index 0000000000..82db4f96c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/params-trailing-comma-multiple.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/func-decl.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +// Stores a reference `ref` for case evaluation +function ref(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +} + +ref(42, 39, 1); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +assert.sameValue(ref.length, 2, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/params-trailing-comma-single.js b/js/src/tests/test262/language/statements/function/params-trailing-comma-single.js new file mode 100644 index 0000000000..cd55376ce2 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/params-trailing-comma-single.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/func-decl.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +// Stores a reference `ref` for case evaluation +function ref(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; +} + +ref(42, 39); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/rest-param-strict-body.js b/js/src/tests/test262/language/statements/function/rest-param-strict-body.js new file mode 100644 index 0000000000..ef15c27e73 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/rest-param-strict-body.js @@ -0,0 +1,134 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/func-decl.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.13 Static Semantics: IsSimpleParameterList + + FormalParameters : FormalParameterList , FunctionRestParameter + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +function f(a,...rest) { + "use strict"; +} diff --git a/js/src/tests/test262/language/statements/function/rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/statements/function/rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..0b40bf27cf --- /dev/null +++ b/js/src/tests/test262/language/statements/function/rest-params-trailing-comma-early-error.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-params-trailing-comma-early-error.case +// - src/function-forms/syntax/func-decl.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ +$DONOTEVALUATE(); + +function f(...a,) { + +} diff --git a/js/src/tests/test262/language/statements/function/scope-body-lex-distinct.js b/js/src/tests/test262/language/statements/function/scope-body-lex-distinct.js new file mode 100644 index 0000000000..6a7fb51413 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/scope-body-lex-distinct.js @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Creation of new lexical environment (distinct from the variable + environment) for the function body outside of strict mode +info: | + [...] + 29. If strict is false, then + a. Let lexEnv be NewDeclarativeEnvironment(varEnv). + b. NOTE: Non-strict functions use a separate lexical Environment Record + for top-level lexical declarations so that a direct eval can + determine whether any var scoped declarations introduced by the eval + code conflict with pre-existing top-level lexically scoped + declarations. This is not needed for strict functions because a + strict direct eval always places all declarations into a new + Environment Record. + [...] + + 18.2.1.3 Runtime Semantics: EvalDeclarationInstantiation + + [...] + 5. If strict is false, then + [...] + b. Let thisLex be lexEnv. + c. Assert: The following loop will terminate. + d. Repeat while thisLex is not the same as varEnv, + i. Let thisEnvRec be thisLex's EnvironmentRecord. + ii. If thisEnvRec is not an object Environment Record, then + 1. NOTE: The environment of with statements cannot contain any + lexical declaration so it doesn't need to be checked for + var/let hoisting conflicts. + 2. For each name in varNames, do + a. If thisEnvRec.HasBinding(name) is true, then + i. Throw a SyntaxError exception. + ii. NOTE: Annex B.3.5 defines alternate semantics for the + above step. + b. NOTE: A direct eval will not hoist var declaration over a + like-named lexical declaration. + iii. Let thisLex be thisLex's outer environment reference. +flags: [noStrict] +features: [let] +---*/ + +function f() { + let x; + eval('var x;'); +} + +assert.throws(SyntaxError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/scope-param-elem-var-close.js b/js/src/tests/test262/language/statements/function/scope-param-elem-var-close.js new file mode 100644 index 0000000000..4917660fe5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/scope-param-elem-var-close.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-functiondeclarationinstantiation +description: > + sloppy direct evals in params introduce vars +info: | + [...] + 20. Else, + a. NOTE: A separate Environment Record is needed to ensure that bindings created by direct eval calls in the formal parameter list are outside the environment where parameters are declared. + b. Let calleeEnv be the LexicalEnvironment of calleeContext. + c. Let env be NewDeclarativeEnvironment(calleeEnv). + d. Let envRec be env's EnvironmentRecord. + [...] +flags: [noStrict] +---*/ + +var x = 'outside'; +var probe1, probe2, probeBody; + +function f( + _ = (eval('var x = "inside";'), probe1 = function() { return x; }), + __ = probe2 = function() { return x; } + ) { + probeBody = function() { return x; }; +} +f(); + +assert.sameValue(probe1(), 'inside'); +assert.sameValue(probe2(), 'inside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/scope-param-elem-var-open.js b/js/src/tests/test262/language/statements/function/scope-param-elem-var-open.js new file mode 100644 index 0000000000..fa797f651b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/scope-param-elem-var-open.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-functiondeclarationinstantiation +description: > + sloppy direct evals in params introduce vars +info: | + [...] + 20. Else, + a. NOTE: A separate Environment Record is needed to ensure that bindings created by direct eval calls in the formal parameter list are outside the environment where parameters are declared. + b. Let calleeEnv be the LexicalEnvironment of calleeContext. + c. Let env be NewDeclarativeEnvironment(calleeEnv). + d. Let envRec be env's EnvironmentRecord. + [...] +flags: [noStrict] +---*/ + +var x = 'outside'; +var probe1, probe2; + +function f( + _ = probe1 = function() { return x; }, + __ = (eval('var x = "inside";'), probe2 = function() { return x; }) + ) { +} +f(); + +assert.sameValue(probe1(), 'inside'); +assert.sameValue(probe2(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/scope-param-rest-elem-var-close.js b/js/src/tests/test262/language/statements/function/scope-param-rest-elem-var-close.js new file mode 100644 index 0000000000..60a9300041 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/scope-param-rest-elem-var-close.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-functiondeclarationinstantiation +description: > + sloppy direct evals in params introduce vars +info: | + [...] + 20. Else, + a. NOTE: A separate Environment Record is needed to ensure that bindings created by direct eval calls in the formal parameter list are outside the environment where parameters are declared. + b. Let calleeEnv be the LexicalEnvironment of calleeContext. + c. Let env be NewDeclarativeEnvironment(calleeEnv). + d. Let envRec be env's EnvironmentRecord. + [...] +flags: [noStrict] +---*/ + +var x = 'outside'; +var probeParam, probeBody; + +function f( + ...[_ = (eval('var x = "inside";'), probeParam = function() { return x; })] + ) { + probeBody = function() { return x; } +} +f(); + +assert.sameValue(probeParam(), 'inside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/scope-param-rest-elem-var-open.js b/js/src/tests/test262/language/statements/function/scope-param-rest-elem-var-open.js new file mode 100644 index 0000000000..d51883fa90 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/scope-param-rest-elem-var-open.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-functiondeclarationinstantiation +description: > + sloppy direct evals in params introduce vars +info: | + [...] + 20. Else, + a. NOTE: A separate Environment Record is needed to ensure that bindings created by direct eval calls in the formal parameter list are outside the environment where parameters are declared. + b. Let calleeEnv be the LexicalEnvironment of calleeContext. + c. Let env be NewDeclarativeEnvironment(calleeEnv). + d. Let envRec be env's EnvironmentRecord. + [...] +flags: [noStrict] +---*/ + +var x = 'outside'; +var probe1, probe2; + +function f( + _ = probe1 = function() { return x; }, + ...[__ = (eval('var x = "inside";'), probe2 = function() { return x; })] + ) { +} +f(); + +assert.sameValue(probe1(), 'inside'); +assert.sameValue(probe2(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/scope-paramsbody-var-close.js b/js/src/tests/test262/language/statements/function/scope-paramsbody-var-close.js new file mode 100644 index 0000000000..bf46717b5b --- /dev/null +++ b/js/src/tests/test262/language/statements/function/scope-paramsbody-var-close.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Disposal of variable environment for the function body +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +---*/ + +var probe; + +// A parameter expression is necessary to trigger the creation of the scope +// under test. +function f(_ = null) { + var x = 'inside'; + probe = function() { return x; }; +} +f(); + +var x = 'outside'; + +assert.sameValue(probe(), 'inside'); +assert.sameValue(x, 'outside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/scope-paramsbody-var-open.js b/js/src/tests/test262/language/statements/function/scope-paramsbody-var-open.js new file mode 100644 index 0000000000..84c38b197c --- /dev/null +++ b/js/src/tests/test262/language/statements/function/scope-paramsbody-var-open.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-functiondeclarationinstantiation +description: > + Creation of new variable environment for the function body (as distinct from + that for the function's parameters) +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +---*/ + +var x = 'outside'; +var probeParams, probeBody; + +function f(_ = probeParams = function() { return x; }) { + var x = 'inside'; + probeBody = function() { return x; }; +} +f(); + +assert.sameValue(probeParams(), 'outside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/shell.js b/js/src/tests/test262/language/statements/function/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/function/static-init-await-binding-invalid.js b/js/src/tests/test262/language/statements/function/static-init-await-binding-invalid.js new file mode 100644 index 0000000000..2804c05f85 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/static-init-await-binding-invalid.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: BindingIdentifier may not be `await` within class static blocks +info: | + BindingIdentifier : Identifier + + [...] + - It is a Syntax Error if the code matched by this production is nested, + directly or indirectly (but not crossing function or static initialization + block boundaries), within a ClassStaticBlock and the StringValue of + Identifier is "await". +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +class C { + static { + function await() {} + } +} + diff --git a/js/src/tests/test262/language/statements/function/static-init-await-binding-valid.js b/js/src/tests/test262/language/statements/function/static-init-await-binding-valid.js new file mode 100644 index 0000000000..671a7906ce --- /dev/null +++ b/js/src/tests/test262/language/statements/function/static-init-await-binding-valid.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: The `await` keyword is interpreted as an identifier within arrow function bodies +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + [...] + - It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. +features: [class-static-block] +---*/ + +class C { + static { + (() => { function await() {} }); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/unscopables-with-in-nested-fn.js b/js/src/tests/test262/language/statements/function/unscopables-with-in-nested-fn.js new file mode 100644 index 0000000000..cce6cfb641 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/unscopables-with-in-nested-fn.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/unscopables-with-in-nested-fn.case +// - src/function-forms/default/func-decl.template +/*--- +description: Symbol.unscopables behavior across scope boundaries (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [globalThis, Symbol.unscopables] +flags: [generated, noStrict] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + ... + Let envRec be lex's EnvironmentRecord. + Let exists be ? envRec.HasBinding(name). + + HasBinding + + ... + If the withEnvironment flag of envRec is false, return true. + Let unscopables be ? Get(bindings, @@unscopables). + If Type(unscopables) is Object, then + Let blocked be ToBoolean(? Get(unscopables, N)). + If blocked is true, return false. + + (The `with` Statement) Runtime Semantics: Evaluation + + ... + Set the withEnvironment flag of newEnv’s EnvironmentRecord to true. + ... + +---*/ +let count = 0; +var v = 1; +globalThis[Symbol.unscopables] = { + v: true, +}; + +{ + count++; + +var callCount = 0; +// Stores a reference `ref` for case evaluation +function ref(x) { + (function() { + count++; + with (globalThis) { + count++; + assert.sameValue(v, 1, 'The value of `v` is 1'); + } + })(); + (function() { + count++; + var v = x; + with (globalThis) { + count++; + assert.sameValue(v, 10, 'The value of `v` is 10'); + v = 20; + } + assert.sameValue(v, 20, 'The value of `v` is 20'); + assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1'); + })(); + assert.sameValue(v, 1, 'The value of `v` is 1'); + assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1'); + callCount = callCount + 1; +} + +ref(10); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); + + count++; +} +assert.sameValue(count, 6, 'The value of `count` is 6'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/unscopables-with.js b/js/src/tests/test262/language/statements/function/unscopables-with.js new file mode 100644 index 0000000000..ddbef97778 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/unscopables-with.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/unscopables-with.case +// - src/function-forms/default/func-decl.template +/*--- +description: Symbol.unscopables behavior across scope boundaries (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +features: [globalThis, Symbol.unscopables] +flags: [generated, noStrict] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + ... + Let envRec be lex's EnvironmentRecord. + Let exists be ? envRec.HasBinding(name). + + HasBinding + + ... + If the withEnvironment flag of envRec is false, return true. + Let unscopables be ? Get(bindings, @@unscopables). + If Type(unscopables) is Object, then + Let blocked be ToBoolean(? Get(unscopables, N)). + If blocked is true, return false. + + (The `with` Statement) Runtime Semantics: Evaluation + + ... + Set the withEnvironment flag of newEnv’s EnvironmentRecord to true. + ... + +---*/ +let count = 0; +var v = 1; +globalThis[Symbol.unscopables] = { + v: true, +}; + +{ + count++; + +var callCount = 0; +// Stores a reference `ref` for case evaluation +function ref(x) { + count++; + with (globalThis) { + count++; + assert.sameValue(v, undefined, 'The value of `v` is expected to equal `undefined`'); + } + count++; + var v = x; + with (globalThis) { + count++; + assert.sameValue(v, 10, 'The value of `v` is 10'); + v = 20; + } + assert.sameValue(v, 20, 'The value of `v` is 20'); + assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1'); + callCount = callCount + 1; +} + +ref(10); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); + + count++; +} +assert.sameValue(count, 6, 'The value of `count` is 6'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/function/use-strict-with-non-simple-param.js b/js/src/tests/test262/language/statements/function/use-strict-with-non-simple-param.js new file mode 100644 index 0000000000..676d0a47c5 --- /dev/null +++ b/js/src/tests/test262/language/statements/function/use-strict-with-non-simple-param.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-function-definitions-static-semantics-early-errors +description: > + A SyntaxError is thrown if a function contains a non-simple parameter list and a UseStrict directive. +info: | + Static Semantics: Early Errors + + It is a Syntax Error if ContainsUseStrict of FunctionBody is true and IsSimpleParameterList of FormalParameters is false. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function f(a = 0) { + "use strict"; +} -- cgit v1.2.3