summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/for
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/language/statements/for')
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-1.js25
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-10.js25
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-11.js23
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-12.js23
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-13.js23
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-14.js23
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-15.js23
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-16.js23
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-17.js24
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-18.js23
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-19.js24
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-2.js25
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-20.js24
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-21.js24
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-3.js25
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-4.js25
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-5.js25
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-6.js25
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-7.js25
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-8.js25
-rw-r--r--js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-9.js25
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A1.js37
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A10.1_T1.js114
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A10.1_T2.js115
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A10_T1.js54
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A10_T2.js55
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A11.1_T1.js25
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A11.1_T2.js64
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A11.1_T3.js30
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A11_T1.js25
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A11_T2.js64
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A11_T3.js30
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A12.1_T1.js25
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A12.1_T2.js65
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A12.1_T3.js30
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A12_T1.js25
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A12_T2.js65
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A12_T3.js30
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A13.js27
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A14.js48
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A15.js25
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A2.1.js27
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A2.2.js27
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A2.js35
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A3.js46
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A4.1.js27
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A4_T1.js27
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A4_T2.js27
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A5.js47
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A6.js35
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A7.1_T1.js24
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A7.1_T2.js24
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A7_T1.js24
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A7_T2.js24
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A8.1_T1.js24
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A8.1_T2.js24
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A8.1_T3.js24
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A8_T1.js24
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A8_T2.js24
-rw-r--r--js/src/tests/test262/language/statements/for/S12.6.3_A8_T3.js24
-rw-r--r--js/src/tests/test262/language/statements/for/browser.js0
-rw-r--r--js/src/tests/test262/language/statements/for/cptn-decl-expr-iter.js34
-rw-r--r--js/src/tests/test262/language/statements/for/cptn-decl-expr-no-iter.js30
-rw-r--r--js/src/tests/test262/language/statements/for/cptn-expr-expr-iter.js37
-rw-r--r--js/src/tests/test262/language/statements/for/cptn-expr-expr-no-iter.js32
-rw-r--r--js/src/tests/test262/language/statements/for/decl-async-fun.js21
-rw-r--r--js/src/tests/test262/language/statements/for/decl-async-gen.js21
-rw-r--r--js/src/tests/test262/language/statements/for/decl-cls.js15
-rw-r--r--js/src/tests/test262/language/statements/for/decl-const.js15
-rw-r--r--js/src/tests/test262/language/statements/for/decl-fun.js15
-rw-r--r--js/src/tests/test262/language/statements/for/decl-gen.js16
-rw-r--r--js/src/tests/test262/language/statements/for/decl-let.js15
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/browser.js0
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-close.js72
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-get-err-array-prototype.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-get-err.js57
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-no-close.js72
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-name-iter-val.js71
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elem-init.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elem-iter.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elision-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elision-iter.js67
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-empty-init.js66
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-empty-iter.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-rest-init.js67
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-rest-iter.js70
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-val-null.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-exhausted.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-arrow.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-class.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-cover.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-fn.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-gen.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-hole.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-skipped.js67
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-throws.js55
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-undef.js61
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-unresolvable.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-complete.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-done.js60
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-step-err.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-val-array-prototype.js81
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-val-err.js75
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-val.js71
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-id-init.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-id.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-prop-id-init.js73
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-prop-id.js73
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-val-null.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-val-undef.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision-exhausted.js68
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision-iter-close.js54
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision-step-err.js71
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision.js77
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-empty.js60
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-elem.js84
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-elision.js90
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-empty.js73
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-rest.js69
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-direct.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-elision-next-err.js57
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-elision.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-exhausted.js61
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-iter-close.js54
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-iter-step-err.js68
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-iter-val-err.js70
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-init-ary.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-init-id.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-init-obj.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-not-final-ary.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-not-final-id.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-not-final-obj.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-obj-id.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-obj-prop-id.js69
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-init-null.js51
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-init-undefined.js51
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-empty.js61
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-get-value-err.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-arrow.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-class.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-cover.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-fn.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-gen.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-skipped.js66
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-throws.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-unresolvable.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-trailing-comma.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-list-err.js59
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary-init.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary-trailing-comma.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary-value-null.js53
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-eval-err.js55
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-get-value-err.js60
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init-skipped.js78
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init-throws.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init-unresolvable.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init.js59
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-trailing-comma.js60
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id.js59
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj-init.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj-value-null.js53
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj-value-undef.js53
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-rest-getter.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-rest-skip-non-enumerable.js66
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-rest-val-obj.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-close.js72
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-get-err-array-prototype.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-get-err.js57
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-no-close.js72
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-name-iter-val.js71
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elem-init.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elem-iter.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elision-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elision-iter.js67
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-empty-init.js66
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-empty-iter.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-rest-init.js67
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-rest-iter.js70
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-val-null.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-exhausted.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-arrow.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-class.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-cover.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-fn.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-gen.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-hole.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-skipped.js67
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-throws.js55
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-undef.js61
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-unresolvable.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-complete.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-done.js60
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-step-err.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-val-array-prototype.js81
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-val-err.js75
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-val.js71
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-id-init.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-id.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-prop-id-init.js73
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-prop-id.js73
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-val-null.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-val-undef.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision-exhausted.js68
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision-iter-close.js54
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision-step-err.js71
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision.js77
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-empty.js60
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-elem.js84
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-elision.js90
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-empty.js73
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-rest.js69
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-direct.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-elision-next-err.js57
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-elision.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-exhausted.js61
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-iter-close.js54
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-iter-step-err.js68
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-iter-val-err.js70
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-init-ary.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-init-id.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-init-obj.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-not-final-ary.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-not-final-id.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-not-final-obj.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-obj-id.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-obj-prop-id.js69
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-init-null.js51
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-init-undefined.js51
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-empty.js61
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-get-value-err.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-arrow.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-class.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-cover.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-fn.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-gen.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-skipped.js66
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-throws.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-unresolvable.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-trailing-comma.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-list-err.js59
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary-init.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary-trailing-comma.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary-value-null.js53
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-eval-err.js55
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-get-value-err.js60
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init-skipped.js78
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init-throws.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init-unresolvable.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init.js59
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-trailing-comma.js60
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id.js59
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj-init.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj-value-null.js53
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj-value-undef.js53
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-rest-getter.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-rest-skip-non-enumerable.js66
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-rest-val-obj.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/shell.js0
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-close.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-get-err-array-prototype.js57
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-get-err.js51
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-no-close.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-name-iter-val.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elem-init.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elem-iter.js57
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elision-init.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elision-iter.js60
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-empty-init.js59
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-empty-iter.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-rest-init.js60
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-rest-iter.js63
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-val-null.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-exhausted.js55
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-arrow.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-class.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-cover.js57
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-fn.js57
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-gen.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-hole.js51
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-skipped.js60
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-throws.js49
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-undef.js54
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-unresolvable.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-complete.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-done.js53
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-step-err.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-val-array-prototype.js74
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-val-err.js69
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-val.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-id-init.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-id.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-prop-id-init.js66
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-prop-id.js66
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-val-null.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-val-undef.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision-exhausted.js61
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision-iter-close.js48
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision-step-err.js65
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision.js70
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-empty.js53
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-elem.js77
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-elision.js83
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-empty.js66
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-rest.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-direct.js57
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-elision-next-err.js51
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-elision.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-exhausted.js54
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-iter-close.js48
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-iter-step-err.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-iter-val-err.js64
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id.js55
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-init-ary.js51
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-init-id.js51
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-init-obj.js51
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-not-final-ary.js51
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-not-final-id.js51
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-not-final-obj.js51
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-obj-id.js55
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-obj-prop-id.js62
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-init-null.js45
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-init-undefined.js45
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-empty.js54
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-get-value-err.js52
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-arrow.js55
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-class.js57
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-cover.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-fn.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-gen.js57
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-skipped.js59
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-throws.js52
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-unresolvable.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-trailing-comma.js49
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-list-err.js53
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary-init.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary-trailing-comma.js49
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary-value-null.js47
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-eval-err.js49
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-get-value-err.js54
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init-skipped.js71
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init-throws.js52
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init-unresolvable.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init.js52
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-trailing-comma.js53
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id.js52
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj-init.js58
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj-value-null.js47
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj-value-undef.js47
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj.js56
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-rest-getter.js51
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-rest-skip-non-enumerable.js59
-rw-r--r--js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-rest-val-obj.js58
-rw-r--r--js/src/tests/test262/language/statements/for/head-const-bound-names-in-stmt.js23
-rw-r--r--js/src/tests/test262/language/statements/for/head-const-fresh-binding-per-iteration.js16
-rw-r--r--js/src/tests/test262/language/statements/for/head-init-async-of.js18
-rw-r--r--js/src/tests/test262/language/statements/for/head-init-expr-check-empty-inc-empty-completion.js19
-rw-r--r--js/src/tests/test262/language/statements/for/head-init-expr-check-empty-inc-empty-syntax.js15
-rw-r--r--js/src/tests/test262/language/statements/for/head-init-var-check-empty-inc-empty-completion.js18
-rw-r--r--js/src/tests/test262/language/statements/for/head-init-var-check-empty-inc-empty-syntax.js13
-rw-r--r--js/src/tests/test262/language/statements/for/head-let-bound-names-in-stmt.js23
-rw-r--r--js/src/tests/test262/language/statements/for/head-let-destructuring.js32
-rw-r--r--js/src/tests/test262/language/statements/for/head-let-fresh-binding-per-iteration.js16
-rw-r--r--js/src/tests/test262/language/statements/for/head-lhs-let.js43
-rw-r--r--js/src/tests/test262/language/statements/for/head-var-bound-names-in-stmt.js19
-rw-r--r--js/src/tests/test262/language/statements/for/labelled-fn-stmt-const.js19
-rw-r--r--js/src/tests/test262/language/statements/for/labelled-fn-stmt-expr.js19
-rw-r--r--js/src/tests/test262/language/statements/for/labelled-fn-stmt-let.js19
-rw-r--r--js/src/tests/test262/language/statements/for/labelled-fn-stmt-var.js19
-rw-r--r--js/src/tests/test262/language/statements/for/let-array-with-newline.js22
-rw-r--r--js/src/tests/test262/language/statements/for/let-block-with-newline.js18
-rw-r--r--js/src/tests/test262/language/statements/for/let-identifier-with-newline.js18
-rw-r--r--js/src/tests/test262/language/statements/for/scope-body-lex-boundary.js45
-rw-r--r--js/src/tests/test262/language/statements/for/scope-body-lex-open.js48
-rw-r--r--js/src/tests/test262/language/statements/for/scope-body-var-none.js113
-rw-r--r--js/src/tests/test262/language/statements/for/scope-head-lex-close.js41
-rw-r--r--js/src/tests/test262/language/statements/for/scope-head-lex-open.js41
-rw-r--r--js/src/tests/test262/language/statements/for/scope-head-var-none.js44
-rw-r--r--js/src/tests/test262/language/statements/for/shell.js16
-rw-r--r--js/src/tests/test262/language/statements/for/tco-const-body-strict.js25
-rw-r--r--js/src/tests/test262/language/statements/for/tco-let-body-strict.js25
-rw-r--r--js/src/tests/test262/language/statements/for/tco-lhs-body-strict.js26
-rw-r--r--js/src/tests/test262/language/statements/for/tco-var-body-strict.js25
389 files changed, 20588 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-1.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-1.js
new file mode 100644
index 0000000000..c337a1302d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-1.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-1
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is an Object with value false
+---*/
+
+ var accessed = false;
+ var obj = { value: false };
+ for (var i = 0; obj; ) {
+ accessed = true;
+ break;
+ }
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-10.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-10.js
new file mode 100644
index 0000000000..a02e76edef
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-10.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-10
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a String object (value is '1')
+---*/
+
+ var accessed = false;
+ var strObj = new String("1");
+ for (var i = 0; strObj;) {
+ accessed = true;
+ break;
+ }
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-11.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-11.js
new file mode 100644
index 0000000000..07e91cfd7d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-11.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-11
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is undefined
+---*/
+
+ var count = 0;
+ for (var i = 0; undefined;) {
+ count++;
+ }
+
+assert.sameValue(count, 0, 'count');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-12.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-12.js
new file mode 100644
index 0000000000..fdaf1f751d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-12.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-12
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is null
+---*/
+
+ var count = 0;
+ for (var i = 0; null;) {
+ count++;
+ }
+
+assert.sameValue(count, 0, 'count');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-13.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-13.js
new file mode 100644
index 0000000000..ae34a2917d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-13.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-13
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a boolean (value is false)
+---*/
+
+ var count = 0;
+ for (var i = 0; false;) {
+ count++;
+ }
+
+assert.sameValue(count, 0, 'count');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-14.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-14.js
new file mode 100644
index 0000000000..1b455c1ac0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-14.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-14
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a number (value is NaN)
+---*/
+
+ var count = 0;
+ for (var i = 0; NaN;) {
+ count++;
+ }
+
+assert.sameValue(count, 0, 'count');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-15.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-15.js
new file mode 100644
index 0000000000..26060a95d8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-15.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-15
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a number (value is +0)
+---*/
+
+ var count = 0;
+ for (var i = 0; +0;) {
+ count++;
+ }
+
+assert.sameValue(count, 0, 'count');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-16.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-16.js
new file mode 100644
index 0000000000..1b3125a691
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-16.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-16
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a number (value is -0)
+---*/
+
+ var count = 0;
+ for (var i = 0; -0;) {
+ count++;
+ }
+
+assert.sameValue(count, 0, 'count');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-17.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-17.js
new file mode 100644
index 0000000000..4fd130f7c8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-17.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-17
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a number (value is a positive)
+---*/
+
+ var accessed = false;
+ for (var i = 0; 2;) {
+ accessed = true;
+ break;
+ }
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-18.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-18.js
new file mode 100644
index 0000000000..1d2676a07f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-18.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-18
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a string (value is empty string)
+---*/
+
+ var count = 0;
+ for (var i = 0; "";) {
+ count++;
+ }
+
+assert.sameValue(count, 0, 'count');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-19.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-19.js
new file mode 100644
index 0000000000..6681abc773
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-19.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-19
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a string (value is 'undefined')
+---*/
+
+ var accessed = false;
+ for (var i = 0; "undefined";) {
+ accessed = true;
+ break;
+ }
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-2.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-2.js
new file mode 100644
index 0000000000..1ae1af7d08
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-2.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-2
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a Boolean object
+---*/
+
+ var accessed = false;
+ var boolObj = new Boolean(false);
+ for (var i = 0; boolObj;) {
+ accessed = true;
+ break;
+ }
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-20.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-20.js
new file mode 100644
index 0000000000..7b5c8cbf46
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-20.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-20
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a string (value is 'null')
+---*/
+
+ var accessed = false;
+ for (var i = 0; "null";) {
+ accessed = true;
+ break;
+ }
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-21.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-21.js
new file mode 100644
index 0000000000..01cfc0da72
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-21.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-21
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a string (value is '1')
+---*/
+
+ var accessed = false;
+ for (var i = 0; "1";) {
+ accessed = true;
+ break;
+ }
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-3.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-3.js
new file mode 100644
index 0000000000..8d00480e0d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-3.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-3
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a Number object (value is NaN)
+---*/
+
+ var accessed = false;
+ var numObj = new Number(NaN);
+ for (var i = 0; numObj;) {
+ accessed = true;
+ break;
+ }
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-4.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-4.js
new file mode 100644
index 0000000000..c9e9a84750
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-4.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-4
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a Number object (value is +0)
+---*/
+
+ var accessed = false;
+ var numObj = new Number(+0);
+ for (var i = 0; numObj;) {
+ accessed = true;
+ break;
+ }
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-5.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-5.js
new file mode 100644
index 0000000000..55a88c0387
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-5.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-5
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a Number object (value is -0)
+---*/
+
+ var accessed = false;
+ var numObj = new Number(-0);
+ for (var i = 0; numObj;) {
+ accessed = true;
+ break;
+ }
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-6.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-6.js
new file mode 100644
index 0000000000..78e7059eb1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-6.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-6
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a Number object (value is a positive)
+---*/
+
+ var accessed = false;
+ var numObj = new Number(12);
+ for (var i = 0; numObj;) {
+ accessed = true;
+ break;
+ }
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-7.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-7.js
new file mode 100644
index 0000000000..c7e9bd29d9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-7.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-7
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a String object (value is empty string)
+---*/
+
+ var accessed = false;
+ var strObj = new String("");
+ for (var i = 0; strObj;) {
+ accessed = true;
+ break;
+ }
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-8.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-8.js
new file mode 100644
index 0000000000..678b538288
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-8.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-8
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a String object (value is 'undefined')
+---*/
+
+ var accessed = false;
+ var strObj = new String("undefined");
+ for (var i = 0; strObj;) {
+ accessed = true;
+ break;
+ }
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-9.js b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-9.js
new file mode 100644
index 0000000000..2fc3a7b5e8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/12.6.3_2-3-a-ii-9.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Refer 12.6.3;
+ The production
+ IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ; Expressionopt ) Statement
+ is evaluated as follows:
+es5id: 12.6.3_2-3-a-ii-9
+description: >
+ The for Statement - (normal, V, empty) will be returned when first
+ Expression is a String object (value is 'null')
+---*/
+
+ var accessed = false;
+ var strObj = new String("null");
+ for (var i = 0; strObj;) {
+ accessed = true;
+ break;
+ }
+
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A1.js b/js/src/tests/test262/language/statements/for/S12.6.3_A1.js
new file mode 100644
index 0000000000..ad9d1e1beb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A1.js
@@ -0,0 +1,37 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ The "for {;;}" for Statement with empty expressions is allowed and leads
+ to performing an infinite loop
+es5id: 12.6.3_A1
+description: Breaking an infinite loop by throwing exception
+---*/
+
+var __in__for = 0;
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+try {
+ for (;;){
+ //__in__for++;
+ if(++__in__for>100)throw 1;
+}
+} catch (e) {
+ if (e !== 1) {
+ throw new Test262Error('#1: for {;;} is admitted and leads to infinite loop');
+ }
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__in__for !== 101) {
+ throw new Test262Error('#2: __in__for === 101. Actual: __in__for ==='+ __in__for );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A10.1_T1.js b/js/src/tests/test262/language/statements/for/S12.6.3_A10.1_T1.js
new file mode 100644
index 0000000000..9a33fbb53e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A10.1_T1.js
@@ -0,0 +1,114 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Nested "var-loops" nine blocks depth is evaluated properly
+es5id: 12.6.3_A10.1
+description: >
+ Checking if executing nested "var-loops" nine blocks depth is
+ evaluated properly
+flags: [noStrict]
+---*/
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+try {
+ __in__deepest__loop=__in__deepest__loop;
+} catch (e) {
+ throw new Test262Error('#1: "__in__deepest__loop=__in__deepest__loop" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+try {
+ index0=index0;
+} catch (e) {
+ throw new Test262Error('#2: "index0=index0" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#3
+try {
+ index1=index1;
+} catch (e) {
+ throw new Test262Error('#3: "index1=index1" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#4
+try {
+ index4=index4;
+} catch (e) {
+ throw new Test262Error('#4: "index4=index4" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#5
+try {
+ index5=index5;
+} catch (e) {
+ throw new Test262Error('#4: "index5=index5" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#6
+try {
+ index7=index7;
+} catch (e) {
+ throw new Test262Error('#6: "index7=index7" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#7
+try {
+ index8=index8;
+} catch (e) {
+ throw new Test262Error('#7: "index8=index8" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+__str="";
+
+for( var index0=0; index0<=1; index0++) {
+ for(var index1=0; index1<=index0; index1++) {
+ for( index2=0; index2<=index1; index2++) {
+ for( index3=0; index3<=index2; index3++) {
+ for(var index4=0; index4<=index3; index4++) {
+ for(var index5=0; index5<=index4; index5++) {
+ for( index6=0; index6<=index5; index6++) {
+ for(var index7=0; index7<=index6; index7++) {
+ for(var index8=0; index8<=index1; index8++) {
+ var __in__deepest__loop;
+ __str+=""+index0+index1+index2+index3+index4+index5+index6+index7+index8+'\n';
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__str!== "000000000\n100000000\n110000000\n110000001\n111000000\n111000001\n111100000\n111100001\n111110000\n111110001\n111111000\n111111001\n111111100\n111111101\n111111110\n111111111\n") {
+ throw new Test262Error('#2: __str === "000000000\\n100000000\\n110000000\\n110000001\\n111000000\\n111000001\\n111100000\\n111100001\\n111110000\\n111110001\\n111111000\\n111111001\\n111111100\\n111111101\\n111111110\\n111111111\\n". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A10.1_T2.js b/js/src/tests/test262/language/statements/for/S12.6.3_A10.1_T2.js
new file mode 100644
index 0000000000..cea5e89e7a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A10.1_T2.js
@@ -0,0 +1,115 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Nested "var-loops" nine blocks depth is evaluated properly
+es5id: 12.6.3_A10.1
+description: >
+ Checking if executing nested "var-loops" nine blocks depth is
+ evaluated properly
+---*/
+
+var __str, index2, index3, index6;
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+try {
+ __in__deepest__loop=__in__deepest__loop;
+} catch (e) {
+ throw new Test262Error('#1: "__in__deepest__loop=__in__deepest__loop" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+try {
+ index0=index0;
+} catch (e) {
+ throw new Test262Error('#2: "index0=index0" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#3
+try {
+ index1=index1;
+} catch (e) {
+ throw new Test262Error('#3: "index1=index1" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#4
+try {
+ index4=index4;
+} catch (e) {
+ throw new Test262Error('#4: "index4=index4" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#5
+try {
+ index5=index5;
+} catch (e) {
+ throw new Test262Error('#4: "index5=index5" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#6
+try {
+ index7=index7;
+} catch (e) {
+ throw new Test262Error('#6: "index7=index7" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#7
+try {
+ index8=index8;
+} catch (e) {
+ throw new Test262Error('#7: "index8=index8" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+__str="";
+
+for( var index0=0; index0<=1; index0++) {
+ for(var index1=0; index1<=index0; index1++) {
+ for( index2=0; index2<=index1; index2++) {
+ for( index3=0; index3<=index2; index3++) {
+ for(var index4=0; index4<=index3; index4++) {
+ for(var index5=0; index5<=index4; index5++) {
+ for( index6=0; index6<=index5; index6++) {
+ for(var index7=0; index7<=index6; index7++) {
+ for(var index8=0; index8<=index1; index8++) {
+ var __in__deepest__loop;
+ __str+=""+index0+index1+index2+index3+index4+index5+index6+index7+index8+'\n';
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__str!== "000000000\n100000000\n110000000\n110000001\n111000000\n111000001\n111100000\n111100001\n111110000\n111110001\n111111000\n111111001\n111111100\n111111101\n111111110\n111111111\n") {
+ throw new Test262Error('#2: __str === "000000000\\n100000000\\n110000000\\n110000001\\n111000000\\n111000001\\n111100000\\n111100001\\n111110000\\n111110001\\n111111000\\n111111001\\n111111100\\n111111101\\n111111110\\n111111111\\n". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A10_T1.js b/js/src/tests/test262/language/statements/for/S12.6.3_A10_T1.js
new file mode 100644
index 0000000000..6f0ba53944
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A10_T1.js
@@ -0,0 +1,54 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Nested "var-loops" nine blocks depth is evaluated properly
+es5id: 12.6.3_A10
+description: >
+ Checking if executing nested "var-loops" nine blocks depth is
+ evaluated properly
+flags: [noStrict]
+---*/
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#
+try {
+ __in__deepest__loop=__in__deepest__loop;
+} catch (e) {
+ throw new Test262Error('#1: "__in__deepest__loop=__in__deepest__loop" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+__str="";
+
+for( index0=0; index0<=1; index0++) {
+ for( index1=0; index1<=index0; index1++) {
+ for( index2=0; index2<=index1; index2++) {
+ for( index3=0; index3<=index2; index3++) {
+ for( index4=0; index4<=index3; index4++) {
+ for( index5=0; index5<=index4; index5++) {
+ for( index6=0; index6<=index5; index6++) {
+ for( index7=0; index7<=index6; index7++) {
+ for( index8=0; index8<=index1; index8++) {
+ var __in__deepest__loop;
+ __str+=""+index0+index1+index2+index3+index4+index5+index6+index7+index8+'\n';
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__str!== "000000000\n100000000\n110000000\n110000001\n111000000\n111000001\n111100000\n111100001\n111110000\n111110001\n111111000\n111111001\n111111100\n111111101\n111111110\n111111111\n") {
+ throw new Test262Error('#2: __str === "000000000\\n100000000\\n110000000\\n110000001\\n111000000\\n111000001\\n111100000\\n111100001\\n111110000\\n111110001\\n111111000\\n111111001\\n111111100\\n111111101\\n111111110\\n111111111\\n". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A10_T2.js b/js/src/tests/test262/language/statements/for/S12.6.3_A10_T2.js
new file mode 100644
index 0000000000..49d3a67eb7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A10_T2.js
@@ -0,0 +1,55 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Nested "var-loops" nine blocks depth is evaluated properly
+es5id: 12.6.3_A10
+description: >
+ Checking if executing nested "var-loops" nine blocks depth is
+ evaluated properly
+---*/
+
+var __str, index0, index1, index2, index3, index4, index5, index6, index7, index8;
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#
+try {
+ __in__deepest__loop=__in__deepest__loop;
+} catch (e) {
+ throw new Test262Error('#1: "__in__deepest__loop=__in__deepest__loop" does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+__str="";
+
+for( index0=0; index0<=1; index0++) {
+ for( index1=0; index1<=index0; index1++) {
+ for( index2=0; index2<=index1; index2++) {
+ for( index3=0; index3<=index2; index3++) {
+ for( index4=0; index4<=index3; index4++) {
+ for( index5=0; index5<=index4; index5++) {
+ for( index6=0; index6<=index5; index6++) {
+ for( index7=0; index7<=index6; index7++) {
+ for( index8=0; index8<=index1; index8++) {
+ var __in__deepest__loop;
+ __str+=""+index0+index1+index2+index3+index4+index5+index6+index7+index8+'\n';
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__str!== "000000000\n100000000\n110000000\n110000001\n111000000\n111000001\n111100000\n111100001\n111110000\n111110001\n111111000\n111111001\n111111100\n111111101\n111111110\n111111111\n") {
+ throw new Test262Error('#2: __str === "000000000\\n100000000\\n110000000\\n110000001\\n111000000\\n111000001\\n111100000\\n111100001\\n111110000\\n111110001\\n111111000\\n111111001\\n111111100\\n111111101\\n111111110\\n111111111\\n". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A11.1_T1.js b/js/src/tests/test262/language/statements/for/S12.6.3_A11.1_T1.js
new file mode 100644
index 0000000000..b3d47480b6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A11.1_T1.js
@@ -0,0 +1,25 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ If (Evaluate Statement).type is "continue" and (Evaluate
+ Statement).target is in the current label set, iteration of labeled
+ "var-loop" breaks
+es5id: 12.6.3_A11.1_T1
+description: Using "continue" in order to continue a loop
+---*/
+
+var __str;
+__str=""
+
+for(var index=0; index<10; index+=1) {
+ if (index<5)continue;
+ __str+=index;
+}
+
+if (__str!=="56789") {
+ throw new Test262Error('#1: __str === "56789". Actual: __str ==='+ __str );
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A11.1_T2.js b/js/src/tests/test262/language/statements/for/S12.6.3_A11.1_T2.js
new file mode 100644
index 0000000000..b805332fea
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A11.1_T2.js
@@ -0,0 +1,64 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ If (Evaluate Statement).type is "continue" and (Evaluate
+ Statement).target is in the current label set, iteration of labeled
+ "var-loop" breaks
+es5id: 12.6.3_A11.1_T2
+description: Embedded loops
+---*/
+
+var __str;
+__str="";
+
+outer : for(var index=0; index<4; index+=1) {
+ nested : for(var index_n=0; index_n<=index; index_n++) {
+ if (index*index_n == 6)continue nested;
+ __str+=""+index+index_n;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (__str !== "001011202122303133") {
+ throw new Test262Error('#1: __str === "001011202122303133". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+__str="";
+
+outer : for(var index=0; index<4; index+=1) {
+ nested : for(var index_n=0; index_n<=index; index_n++) {
+ if (index*index_n == 6)continue outer;
+ __str+=""+index+index_n;
+ }
+}
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__str !== "0010112021223031") {
+ throw new Test262Error('#2: __str === "0010112021223031". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+__str="";
+
+outer : for(var index=0; index<4; index+=1) {
+ nested : for(var index_n=0; index_n<=index; index_n++) {
+ if (index*index_n == 6)continue ;
+ __str+=""+index+index_n;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#3
+if (__str !== "001011202122303133") {
+ throw new Test262Error('#3: __str === "001011202122303133". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A11.1_T3.js b/js/src/tests/test262/language/statements/for/S12.6.3_A11.1_T3.js
new file mode 100644
index 0000000000..c754761f9a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A11.1_T3.js
@@ -0,0 +1,30 @@
+// |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: |
+ If (Evaluate Statement).type is "continue" and (Evaluate
+ Statement).target is in the current label set, iteration of labeled
+ "var-loop" breaks
+es5id: 12.6.3_A11.1_T3
+description: Trying to continue non-existent label
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+__str="";
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+outer:for(var index=0;index<4;index+=1){
+ nested:for(var index_n=0;index_n<=index;index_n++){
+ if(index*index_n == 6)continue nonexist;
+ __str+=""+index+index_n;
+ }
+}
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A11_T1.js b/js/src/tests/test262/language/statements/for/S12.6.3_A11_T1.js
new file mode 100644
index 0000000000..a60d2cf56f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A11_T1.js
@@ -0,0 +1,25 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ If (Evaluate Statement).type is "continue" and (Evaluate
+ Statement).target is in the current label set, iteration of labeled loop
+ breaks
+es5id: 12.6.3_A11_T1
+description: Simple test of continue loop with using "continue"
+---*/
+
+var __str, index;
+__str=""
+
+for(index=0; index<10; index+=1) {
+ if (index<5)continue;
+ __str+=index;
+}
+
+if (__str!=="56789") {
+ throw new Test262Error('#1: __str === "56789". Actual: __str ==='+ __str );
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A11_T2.js b/js/src/tests/test262/language/statements/for/S12.6.3_A11_T2.js
new file mode 100644
index 0000000000..ad315eb00a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A11_T2.js
@@ -0,0 +1,64 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ If (Evaluate Statement).type is "continue" and (Evaluate
+ Statement).target is in the current label set, iteration of labeled loop
+ breaks
+es5id: 12.6.3_A11_T2
+description: Embedded loops
+---*/
+
+var __str, index, index_n;
+__str="";
+
+outer : for(index=0; index<4; index+=1) {
+ nested : for(index_n=0; index_n<=index; index_n++) {
+ if (index*index_n == 6)continue nested;
+ __str+=""+index+index_n;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (__str !== "001011202122303133") {
+ throw new Test262Error('#1: __str === "001011202122303133". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+__str="";
+
+outer : for(index=0; index<4; index+=1) {
+ nested : for(index_n=0; index_n<=index; index_n++) {
+ if (index*index_n == 6)continue outer;
+ __str+=""+index+index_n;
+ }
+}
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__str !== "0010112021223031") {
+ throw new Test262Error('#2: __str === "0010112021223031". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+__str="";
+
+outer : for(index=0; index<4; index+=1) {
+ nested : for(index_n=0; index_n<=index; index_n++) {
+ if (index*index_n == 6)continue ;
+ __str+=""+index+index_n;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#3
+if (__str !== "001011202122303133") {
+ throw new Test262Error('#3: __str === "001011202122303133". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A11_T3.js b/js/src/tests/test262/language/statements/for/S12.6.3_A11_T3.js
new file mode 100644
index 0000000000..f122b39247
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A11_T3.js
@@ -0,0 +1,30 @@
+// |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: |
+ If (Evaluate Statement).type is "continue" and (Evaluate
+ Statement).target is in the current label set, iteration of labeled loop
+ breaks
+es5id: 12.6.3_A11_T3
+description: Trying to continue non-existent label
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+__str="";
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#
+outer:for(index=0;index<4;index+=1){
+ nested:for(index_n=0;index_n<=index;index_n++){
+ if(index*index_n == 6)continue nonexist;
+ __str+=""+index+index_n;
+ }
+}
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A12.1_T1.js b/js/src/tests/test262/language/statements/for/S12.6.3_A12.1_T1.js
new file mode 100644
index 0000000000..e3d68943fb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A12.1_T1.js
@@ -0,0 +1,25 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ If (Evaluate Statement).type is "break" and (Evaluate Statement).target
+ is in the current label set, (normal, (Evaluate Statement), empty) is
+ returned while evaluating a "var-loop"
+es5id: 12.6.3_A12.1_T1
+description: Breaking a loop with "break"
+---*/
+
+var __str;
+__str=""
+
+for(var index=0; index<10; index+=1) {
+ if (index>5)break;
+ __str+=index;
+}
+
+if (__str!=="012345") {
+ throw new Test262Error('#1: __str === "012345". Actual: __str ==='+ __str );
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A12.1_T2.js b/js/src/tests/test262/language/statements/for/S12.6.3_A12.1_T2.js
new file mode 100644
index 0000000000..7d02e4afa1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A12.1_T2.js
@@ -0,0 +1,65 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ If (Evaluate Statement).type is "break" and (Evaluate Statement).target
+ is in the current label set, (normal, (Evaluate Statement), empty) is
+ returned while evaluating a "var-loop"
+es5id: 12.6.3_A12.1_T2
+description: Embedded loops
+---*/
+
+var __str;
+__str="";
+
+outer : for(var index=0; index<4; index+=1) {
+ nested : for(var index_n=0; index_n<=index; index_n++) {
+ if (index*index_n >= 4)break nested;
+ __str+=""+index+index_n;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (__str !== "00101120213031") {
+ throw new Test262Error('#1: __str === "00101120213031". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+__str="";
+
+outer : for(var index=0; index<4; index+=1) {
+ nested : for(var index_n=0; index_n<=index; index_n++) {
+ if (index*index_n >= 4)break outer;
+ __str+=""+index+index_n;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__str !== "0010112021") {
+ throw new Test262Error('#2: __str === "0010112021". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+__str="";
+
+outer : for(var index=0; index<4; index+=1) {
+ nested : for(var index_n=0; index_n<=index; index_n++) {
+ if (index*index_n >= 4)break ;
+ __str+=""+index+index_n;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#3
+if (__str !== "00101120213031") {
+ throw new Test262Error('#3: __str === "00101120213031". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A12.1_T3.js b/js/src/tests/test262/language/statements/for/S12.6.3_A12.1_T3.js
new file mode 100644
index 0000000000..1dddd219a5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A12.1_T3.js
@@ -0,0 +1,30 @@
+// |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: |
+ If (Evaluate Statement).type is "break" and (Evaluate Statement).target
+ is in the current label set, (normal, (Evaluate Statement), empty) is
+ returned while evaluating a "var-loop"
+es5id: 12.6.3_A12.1_T3
+description: Trying to break non-existent label
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+__str="";
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+outer:for(var index=0;index<4;index+=1){
+ nested:for(var index_n=0;index_n<=index;index_n++){
+ if(index*index_n >= 4)break nonexist;
+ __str+=""+index+index_n;
+ }
+}
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A12_T1.js b/js/src/tests/test262/language/statements/for/S12.6.3_A12_T1.js
new file mode 100644
index 0000000000..e0b1ab218a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A12_T1.js
@@ -0,0 +1,25 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ If (Evaluate Statement).type is "break" and (Evaluate Statement).target
+ is in the current label set, (normal, (Evaluate Statement), empty) is
+ returned while evaluating a loop
+es5id: 12.6.3_A12_T1
+description: Breaking a loop with "break"
+---*/
+
+var __str, index;
+__str=""
+
+for(index=0; index<10; index+=1) {
+ if (index>5)break;
+ __str+=index;
+}
+
+if (__str!=="012345") {
+ throw new Test262Error('#1:__str === "012345". Actual: __str ==='+__str );
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A12_T2.js b/js/src/tests/test262/language/statements/for/S12.6.3_A12_T2.js
new file mode 100644
index 0000000000..c696a9150c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A12_T2.js
@@ -0,0 +1,65 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ If (Evaluate Statement).type is "break" and (Evaluate Statement).target
+ is in the current label set, (normal, (Evaluate Statement), empty) is
+ returned while evaluating a loop
+es5id: 12.6.3_A12_T2
+description: Embedded loops
+---*/
+
+var __str, index, index_n;
+__str="";
+
+outer : for(index=0; index<4; index+=1) {
+ nested : for(index_n=0; index_n<=index; index_n++) {
+ if (index*index_n >= 4)break nested;
+ __str+=""+index+index_n;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (__str !== "00101120213031") {
+ throw new Test262Error('#1: __str === "00101120213031". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+__str="";
+
+outer : for(index=0; index<4; index+=1) {
+ nested : for(index_n=0; index_n<=index; index_n++) {
+ if (index*index_n >= 4)break outer;
+ __str+=""+index+index_n;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__str !== "0010112021") {
+ throw new Test262Error('#2: __str === "0010112021". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+__str="";
+
+outer : for(index=0; index<4; index+=1) {
+ nested : for(index_n=0; index_n<=index; index_n++) {
+ if (index*index_n >= 4)break ;
+ __str+=""+index+index_n;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#3
+if (__str !== "00101120213031") {
+ throw new Test262Error('#3: __str === "00101120213031". Actual: __str ==='+ __str );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A12_T3.js b/js/src/tests/test262/language/statements/for/S12.6.3_A12_T3.js
new file mode 100644
index 0000000000..1b1016fb47
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A12_T3.js
@@ -0,0 +1,30 @@
+// |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: |
+ If (Evaluate Statement).type is "break" and (Evaluate Statement).target
+ is in the current label set, (normal, (Evaluate Statement), empty) is
+ returned while evaluating a loop
+es5id: 12.6.3_A12_T3
+description: Trying to break non-existent label
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+__str="";
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#4
+outer:for(index=0;index<4;index+=1){
+ nested:for(index_n=0;index_n<=index;index_n++){
+ if(index*index_n >= 4)break nonexist;
+ __str+=""+index+index_n;
+ }
+};
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A13.js b/js/src/tests/test262/language/statements/for/S12.6.3_A13.js
new file mode 100644
index 0000000000..7ea5f84ef7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A13.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: |
+ VariableDeclaration in "var VariableDeclarationListNoIn" of for
+ IterationStatement is allowed
+es5id: 12.6.3_A13
+description: Declaring variable in "for" ExpressionNoIn
+---*/
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+try {
+ index = index;
+} catch (e) {
+ throw new Test262Error('#1: VariableDeclaration in "var VariableDeclarationListNoIn" of for IterationStatement is allowed');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+
+for(var index=0; index<6; index++) {
+ ;
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A14.js b/js/src/tests/test262/language/statements/for/S12.6.3_A14.js
new file mode 100644
index 0000000000..49c3b859e9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A14.js
@@ -0,0 +1,48 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ The production IterationStatement: "for (var VariableDeclarationListNoIn;
+ Expression; Expression) Statement"
+es5id: 12.6.3_A14
+description: Using +,*,/, as the second Expression
+---*/
+
+//CHECK#1
+for(var i=0;i<10;i++){}
+if (i!==10) throw new Test262Error('#1: i === 10. Actual: i ==='+ i );
+
+//CHECK#2
+var j=0;
+for(var i=1;i<10;i*=2){
+ j++;
+}
+if (i!==16) throw new Test262Error('#2.1: i === 16. Actual: i ==='+ i );
+if (j!==4) throw new Test262Error('#2.2: j === 4. Actual: j ==='+ j );
+
+//CHECK#3
+var j=0;
+for(var i=16;i>1;i=i/2){
+ j++;
+}
+if (i!==1) throw new Test262Error('#3.1: i === 1. Actual: i ==='+ i );
+if (j!==4) throw new Test262Error('#3.2: j === 4. Actual: j ==='+ j );
+
+//CHECK#4
+var j=0;
+for(var i=10;i>1;i--){
+ j++;
+}
+if (i!==1) throw new Test262Error('#4.1: i === 1. Actual: i ==='+ i );
+if (j!==9) throw new Test262Error('#4.2: j === 9. Actual: j ==='+ j );
+
+//CHECK#5
+var j=0;
+for(var i=2;i<10;i*=i){
+ j++;
+}
+if (i!==16) throw new Test262Error('#5.1: i === 16. Actual: i ==='+ i );
+if (j!==2) throw new Test262Error('#5.2: j === 2. Actual: j ==='+ j );
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A15.js b/js/src/tests/test262/language/statements/for/S12.6.3_A15.js
new file mode 100644
index 0000000000..f64d5e5cb5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A15.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 production IterationStatement: "for (var VariableDeclarationListNoIn;
+ Expression; Expression) Statement"
+es5id: 12.6.3_A15
+description: Statement must be evaluated before second Expression is evaluated
+---*/
+
+//CHECK#1
+for(var i=0;i<10;i++){
+ i*=2;
+ break;
+}
+if (i!==0) throw new Test262Error('#1: i === 0. Actual: i ==='+ i );
+
+//CHECK#2
+for(var i=0;i<10;i++){
+ i*=2;
+ if (i===3) throw new Test262Error('#2: i !== 3');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A2.1.js b/js/src/tests/test262/language/statements/for/S12.6.3_A2.1.js
new file mode 100644
index 0000000000..9eff956a4e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A2.1.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: |
+ While evaluating "for (ExpressionNoIn ; ; Expression) Statement",
+ Statement is evaulated first
+es5id: 12.6.3_A2.1
+description: Using "(function(){throw "NoInExpression"})()" as ExpressionNoIn
+---*/
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+try {
+ for((function(){throw "NoInExpression"})(); ;(function(){throw "SecondExpression"})()) {
+ throw "Statement";
+ }
+ throw new Test262Error('#1: (function(){throw "NoInExpression"})() lead to throwing exception');
+} catch (e) {
+ if (e !== "NoInExpression") {
+ throw new Test262Error('#2: When for (ExpressionNoIn ; ; Expression) Statement is evaluated NoInExpression evaluates first');
+ }
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A2.2.js b/js/src/tests/test262/language/statements/for/S12.6.3_A2.2.js
new file mode 100644
index 0000000000..fce84ba3de
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A2.2.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: |
+ While evaluating "for (ExpressionNoIn;;) Statement", Statement is
+ evaulated first
+es5id: 12.6.3_A2.2
+description: Using "(function(){throw "NoInExpression"})()" as ExpressionNoIn
+---*/
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+try {
+ for((function(){throw "NoInExpression"})();;) {
+ throw "Statement";
+ }
+ throw new Test262Error('#1: (function(){throw "NoInExpression"})() lead to throwing exception');
+} catch (e) {
+ if (e !== "NoInExpression") {
+ throw new Test262Error('#1: When for (ExpressionNoIn ; ; ) Statement is evaluated NoInExpression evaluates first');
+ }
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A2.js b/js/src/tests/test262/language/statements/for/S12.6.3_A2.js
new file mode 100644
index 0000000000..01386e3457
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A2.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: |
+ While evaluating "for (ExpressionNoIn; Expression; Expression)
+ Statement", ExpressionNoIn is evaulated first
+es5id: 12.6.3_A2
+description: Using "(function(){throw "NoInExpression"})()" as ExpressionNoIn
+---*/
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+try {
+ for((function(){throw "NoInExpression";})(); (function(){throw "FirstExpression";})(); (function(){throw "SecondExpression";})()) {
+ var in_for = "reached";
+ }
+ throw new Test262Error('#1: (function(){throw "NoInExpression";})() lead to throwing exception');
+} catch (e) {
+ if (e !== "NoInExpression") {
+ throw new Test262Error('#1: When for (ExpressionNoIn ; Expression ; Expression) Statement is evaluated ExpressionNoIn evaluates first');
+ }
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (in_for !== undefined) {
+ throw new Test262Error('#2: in_for === undefined. Actual: in_for ==='+ in_for );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A3.js b/js/src/tests/test262/language/statements/for/S12.6.3_A3.js
new file mode 100644
index 0000000000..a43f6502d0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A3.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: |
+ While evaluating "for (ExpressionNoIn; FirstExpression; SecondExpression)
+ Statement", ExpressionNoIn is evaulated first, FirstExpressoin is
+ evaluated second
+es5id: 12.6.3_A3
+description: Using "(function(){throw "FirstExpression"})()" as FirstExpression
+---*/
+
+var __in__NotInExpression__, __in__NotInExpression__2, __in__for;
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+try {
+ for((function(){__in__NotInExpression__ = "checked";__in__NotInExpression__2 = "passed";})(); (function(){throw "FirstExpression"})(); (function(){throw "SecondExpression"})()) {
+ __in__for="reached";
+ }
+ throw new Test262Error('#1: (function(){throw "SecondExpression"} lead to throwing exception');
+} catch (e) {
+ if (e !== "FirstExpression") {
+ throw new Test262Error('#1: When for (ExpressionNoIn ; FirstExpression ; SecondExpression) Statement is evaluated first evaluates ExpressionNoIn then FirstExpression');
+ }
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if ((__in__NotInExpression__ !== "checked")&(__in__NotInExpression__2!=="passed")) {
+ throw new Test262Error('#2: (__in__NotInExpression__ === "checked")&(__in__NotInExpression__2==="passed")');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#3
+if (typeof __in__for !== "undefined") {
+ throw new Test262Error('#3: typeof __in__for === "undefined". Actual: typeof __in__for ==='+ typeof __in__for );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A4.1.js b/js/src/tests/test262/language/statements/for/S12.6.3_A4.1.js
new file mode 100644
index 0000000000..5eba293fbd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A4.1.js
@@ -0,0 +1,27 @@
+// |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: |
+ "in"-expression is not allowed as a ExpressionNoIn in "for
+ (ExpressionNoIn; FirstExpression; SecondExpression) Statement"
+ IterationStatement
+es5id: 12.6.3_A4.1
+description: Checking if execution of "for (var a in arr;1;){}" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+arr = [1,2,3,4,5];
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+for (var a in arr;1;){
+ break;
+}
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A4_T1.js b/js/src/tests/test262/language/statements/for/S12.6.3_A4_T1.js
new file mode 100644
index 0000000000..0c35e9b3c3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A4_T1.js
@@ -0,0 +1,27 @@
+// |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: |
+ "in"-expression is not allowed as a ExpressionNoIn in "for
+ (ExpressionNoIn; FirstExpression; SecondExpression) Statement"
+ IterationStatement
+es5id: 12.6.3_A4_T1
+description: Checking if execution of "for (a in arr;1;){}" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+arr = [1,2,3,4,5];
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+for (a in arr;1;){
+ break;
+}
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A4_T2.js b/js/src/tests/test262/language/statements/for/S12.6.3_A4_T2.js
new file mode 100644
index 0000000000..d91dc7cb6b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A4_T2.js
@@ -0,0 +1,27 @@
+// |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: |
+ "in"-expression is not allowed as a ExpressionNoIn in "for
+ (ExpressionNoIn; FirstExpression; SecondExpression) Statement"
+ IterationStatement
+es5id: 12.6.3_A4_T2
+description: Checking if execution of "for (1 in arr;1;){}" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+arr = [1,2,3,4,5];
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+for(1 in arr;1;) {
+ break;
+}
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A5.js b/js/src/tests/test262/language/statements/for/S12.6.3_A5.js
new file mode 100644
index 0000000000..326a843c48
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A5.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: |
+ "in"-expression wrapped into "eval" statement is allowed as a
+ ExpressionNoIn in "for (ExpressionNoIn; FirstExpression;
+ SecondExpression) Statement" IterationStatement
+es5id: 12.6.3_A5
+description: Using eval "for(eval("i in arr");1;)"
+---*/
+
+var arr, i;
+
+arr = [1,2,3,4,5];
+i = 1;
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+try {
+ for(eval("i in arr");1;) {break;};
+} catch (e) {
+ throw new Test262Error('#1.1: for(eval("i in arr");1;) {break;}; does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+try {
+ for(eval("var i = 1 in arr");1;) {break;};
+} catch (e) {
+ throw new Test262Error('#2.1: for(eval("var i = 1 in arr");1;) {break;}; does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#3
+try {
+ for(eval("1 in arr");1;) {break;};
+} catch (e) {
+ throw new Test262Error('#3.1: for(eval("1 in arr");1;) {break;}; does not lead to throwing exception');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A6.js b/js/src/tests/test262/language/statements/for/S12.6.3_A6.js
new file mode 100644
index 0000000000..4b7333c0f3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A6.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: |
+ While evaluating "for ( ; ; Expression) Statement", Statement is
+ evaluated first and then Expression is evaluated
+es5id: 12.6.3_A6
+description: Using "(function(){throw "SecondExpression";})()" as an Expression
+---*/
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+try {
+ for(;;(function(){throw "SecondExpression";})()){
+ var __in__for = "reached";
+ }
+ throw new Test262Error('#1: (function(){throw "SecondExpression"}() lead to throwing exception');
+} catch (e) {
+ if (e !== "SecondExpression") {
+ throw new Test262Error('#1: When for ( ; ; Expression) Statement is evaluated Statement evaluates first then Expression evaluates');
+ }
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__in__for !== "reached") {
+ throw new Test262Error('#2: __in__for === "reached". Actual: __in__for ==='+ __in__for );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A7.1_T1.js b/js/src/tests/test262/language/statements/for/S12.6.3_A7.1_T1.js
new file mode 100644
index 0000000000..c559744eb9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A7.1_T1.js
@@ -0,0 +1,24 @@
+// |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: |
+ Only three expressions and two semicolons in "for(with var)" braces are allowed.
+ Appearing of for (ExpressionNoIn_opt ; Expression_opt ; Expression_opt; Expression_opt; Expression_opt;) statement leads to SyntaxError
+es5id: 12.6.3_A7.1_T1
+description: >
+ Checking if execution of "for(var index=0; index<10; index++;
+ index--)" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+for(var index=0; index<10; index++; index--);
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A7.1_T2.js b/js/src/tests/test262/language/statements/for/S12.6.3_A7.1_T2.js
new file mode 100644
index 0000000000..b92537a908
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A7.1_T2.js
@@ -0,0 +1,24 @@
+// |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: |
+ Only three expressions and two semicolons in "for(with var)" braces are allowed.
+ Appearing of for (ExpressionNoIn_opt ; Expression_opt ; Expression_opt; Expression_opt; Expression_opt;) statement leads to SyntaxError
+es5id: 12.6.3_A7.1_T2
+description: >
+ Checking if execution of "for(var index=0; index<10; index+=4;
+ index++; index--)" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+for(var index=0; index<10; index+=4; index++; index--) ;
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A7_T1.js b/js/src/tests/test262/language/statements/for/S12.6.3_A7_T1.js
new file mode 100644
index 0000000000..67bbcec565
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A7_T1.js
@@ -0,0 +1,24 @@
+// |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: |
+ Only three expressions and two semicolons in "for" braces are allowed.
+ Appearing of for (ExpressionNoIn_opt ; Expression_opt ; Expression_opt; Expression_opt; Expression_opt;) statement leads to SyntaxError
+es5id: 12.6.3_A7_T1
+description: >
+ Checking if execution of "for(index=0; index<10; index++;
+ index--)" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+for(index=0; index<10; index++; index--) ;
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A7_T2.js b/js/src/tests/test262/language/statements/for/S12.6.3_A7_T2.js
new file mode 100644
index 0000000000..1c096168ad
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A7_T2.js
@@ -0,0 +1,24 @@
+// |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: |
+ Only three expressions and two semicolons in "for" braces are allowed.
+ Appearing of for (ExpressionNoIn_opt ; Expression_opt ; Expression_opt; Expression_opt; Expression_opt;) statement leads to SyntaxError
+es5id: 12.6.3_A7_T2
+description: >
+ Checking if execution of "for(index=0; index<10; index+=4;
+ index++; index--)" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+for(index=0; index<10; index+=4; index++; index--) ;
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A8.1_T1.js b/js/src/tests/test262/language/statements/for/S12.6.3_A8.1_T1.js
new file mode 100644
index 0000000000..0f39351c30
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A8.1_T1.js
@@ -0,0 +1,24 @@
+// |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: Blocks within "for(with var)" braces are not allowed
+es5id: 12.6.3_A8.1_T1
+description: >
+ Checking if execution of "for(var index=0; index<100; {index++;
+ index*2;}) { arr.add(""+index);}" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+var arr = [];
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+for(var index=0; index<100; {index++; index*2;}) { arr.add(""+index);};
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A8.1_T2.js b/js/src/tests/test262/language/statements/for/S12.6.3_A8.1_T2.js
new file mode 100644
index 0000000000..178959911f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A8.1_T2.js
@@ -0,0 +1,24 @@
+// |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: Blocks within "for(with var)" braces are not allowed
+es5id: 12.6.3_A8.1_T2
+description: >
+ Checking if execution of "for(var index=0; {index++;index<100;};
+ index*2;) { arr.add(""+index);}" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+var arr = [];
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+for(var index=0; {index++;index<100;}; index*2;) { arr.add(""+index);};
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A8.1_T3.js b/js/src/tests/test262/language/statements/for/S12.6.3_A8.1_T3.js
new file mode 100644
index 0000000000..ce23f03e5b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A8.1_T3.js
@@ -0,0 +1,24 @@
+// |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: Blocks within "for(with var)" braces are not allowed
+es5id: 12.6.3_A8.1_T3
+description: >
+ Checking if execution of "for({var index=0; index+=1;}
+ index++<=10; index*2;) { arr.add(""+index);}" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+var arr = [];
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#3
+for({var index=0; index+=1;} index++<=10; index*2;) { arr.add(""+index);};
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A8_T1.js b/js/src/tests/test262/language/statements/for/S12.6.3_A8_T1.js
new file mode 100644
index 0000000000..d05ab70c44
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A8_T1.js
@@ -0,0 +1,24 @@
+// |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: Blocks within "for" braces are not allowed
+es5id: 12.6.3_A8_T1
+description: >
+ Checking if execution of "for(index=0; index<100; {index++;
+ index*2;}) { arr.add(""+index);}" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+var arr = [];
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+for(index=0; index<100; {index++; index*2;}) { arr.add(""+index);};
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A8_T2.js b/js/src/tests/test262/language/statements/for/S12.6.3_A8_T2.js
new file mode 100644
index 0000000000..d9723488c0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A8_T2.js
@@ -0,0 +1,24 @@
+// |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: Blocks within "for" braces are not allowed
+es5id: 12.6.3_A8_T2
+description: >
+ Checking if execution of "for(index=0; {index++;index<100;};
+ index*2;) { arr.add(""+index);}" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+var arr = [];
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+for(index=0; {index++;index<100;}; index*2;) { arr.add(""+index);};
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/S12.6.3_A8_T3.js b/js/src/tests/test262/language/statements/for/S12.6.3_A8_T3.js
new file mode 100644
index 0000000000..2869385ad0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/S12.6.3_A8_T3.js
@@ -0,0 +1,24 @@
+// |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: Blocks within "for" braces are not allowed
+es5id: 12.6.3_A8_T3
+description: >
+ Checking if execution of "for({index=0; index+=1;} index++<=10;
+ index*2;) { arr.add(""+index);}" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+var arr = [];
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+for({index=0; index+=1;} index++<=10; index*2;) { arr.add(""+index);};
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/for/browser.js b/js/src/tests/test262/language/statements/for/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/browser.js
diff --git a/js/src/tests/test262/language/statements/for/cptn-decl-expr-iter.js b/js/src/tests/test262/language/statements/for/cptn-decl-expr-iter.js
new file mode 100644
index 0000000000..9785901687
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/cptn-decl-expr-iter.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.7.4.7
+description: >
+ Completion value when head has a declaration and a "test" expression and iteration occurs
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(varDcl).
+ 3. Return ForBodyEvaluation(the first Expression, the second Expression,
+ Statement, « », labelSet).
+
+ 13.7.4.8 Runtime Semantics: ForBodyEvaluation
+ 1. Let V = undefined.
+ [...]
+ 4. Repeat
+ a. If test is not [empty], then
+ i. Let testRef be the result of evaluating test.
+ ii. Let testValue be GetValue(testRef).
+ iii. ReturnIfAbrupt(testValue).
+ iv. If ToBoolean(testValue) is false, return NormalCompletion(V).
+---*/
+
+assert.sameValue(
+ eval('1; for (var runA = true; runA; runA = false) { }'), undefined
+);
+assert.sameValue(
+ eval('2; for (var runB = true; runB; runB = false) { 3; }'), 3
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/cptn-decl-expr-no-iter.js b/js/src/tests/test262/language/statements/for/cptn-decl-expr-no-iter.js
new file mode 100644
index 0000000000..e0d0603f94
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/cptn-decl-expr-no-iter.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.7.4.7
+description: >
+ Completion value when head has a declaration and a "test" expression and no iteration occurs
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(varDcl).
+ 3. Return ForBodyEvaluation(the first Expression, the second Expression,
+ Statement, « », labelSet).
+
+ 13.7.4.8 Runtime Semantics: ForBodyEvaluation
+ 1. Let V = undefined.
+ [...]
+ 4. Repeat
+ a. If test is not [empty], then
+ i. Let testRef be the result of evaluating test.
+ ii. Let testValue be GetValue(testRef).
+ iii. ReturnIfAbrupt(testValue).
+ iv. If ToBoolean(testValue) is false, return NormalCompletion(V).
+---*/
+
+assert.sameValue(eval('1; for (var run = false; run; ) { }'), undefined);
+assert.sameValue(eval('2; for (var run = false; run; ) { 3; }'), undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/cptn-expr-expr-iter.js b/js/src/tests/test262/language/statements/for/cptn-expr-expr-iter.js
new file mode 100644
index 0000000000..471aa47a9e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/cptn-expr-expr-iter.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.
+/*---
+es6id: 13.7.4.7
+description: >
+ Completion value when head has no declaration and a "test" expression and
+ iteration occurs
+info: |
+ IterationStatement :
+ for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement
+
+ 1. If the first Expression is present, then
+ a. Let exprRef be the result of evaluating the first Expression.
+ b. Let exprValue be GetValue(exprRef).
+ c. ReturnIfAbrupt(exprValue).
+ 2. Return ForBodyEvaluation(the second Expression, the third Expression,
+ Statement, « », labelSet).
+
+ 13.7.4.8 Runtime Semantics: ForBodyEvaluation
+ 1. Let V = undefined.
+ [...]
+ 4. Repeat
+ a. If test is not [empty], then
+ i. Let testRef be the result of evaluating test.
+ ii. Let testValue be GetValue(testRef).
+ iii. ReturnIfAbrupt(testValue).
+ iv. If ToBoolean(testValue) is false, return NormalCompletion(V).
+---*/
+
+assert.sameValue(
+ eval('var runA; 1; for (runA = true; runA; runA = false) { }'), undefined
+);
+assert.sameValue(
+ eval('var runB; 2; for (runB = true; runB; runB = false) { 3; }'), 3
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/cptn-expr-expr-no-iter.js b/js/src/tests/test262/language/statements/for/cptn-expr-expr-no-iter.js
new file mode 100644
index 0000000000..9397a63d5f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/cptn-expr-expr-no-iter.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.
+/*---
+es6id: 13.7.4.7
+description: >
+ Completion value when head has no declaration and a "test" expression and no iteration occurs
+info: |
+ IterationStatement :
+ for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement
+
+ 1. If the first Expression is present, then
+ a. Let exprRef be the result of evaluating the first Expression.
+ b. Let exprValue be GetValue(exprRef).
+ c. ReturnIfAbrupt(exprValue).
+ 2. Return ForBodyEvaluation(the second Expression, the third Expression,
+ Statement, « », labelSet).
+
+ 13.7.4.8 Runtime Semantics: ForBodyEvaluation
+ 1. Let V = undefined.
+ [...]
+ 4. Repeat
+ a. If test is not [empty], then
+ i. Let testRef be the result of evaluating test.
+ ii. Let testValue be GetValue(testRef).
+ iii. ReturnIfAbrupt(testValue).
+ iv. If ToBoolean(testValue) is false, return NormalCompletion(V).
+---*/
+
+assert.sameValue(eval('1; for ( ; false; ) { }'), undefined);
+assert.sameValue(eval('2; for ( ; false; ) { 3; }'), undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/decl-async-fun.js b/js/src/tests/test262/language/statements/for/decl-async-fun.js
new file mode 100644
index 0000000000..4e3999054d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/decl-async-fun.js
@@ -0,0 +1,21 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-for-statement
+description: >
+ AsyncFunctionDeclaration is not allowed in statement position
+info: |
+ ExpressionStatement[Yield, Await] :
+ [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
+ Expression[+In, ?Yield, ?Await] ;
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-functions]
+---*/
+
+$DONOTEVALUATE();
+
+for ( ; false; ) async function f() {}
diff --git a/js/src/tests/test262/language/statements/for/decl-async-gen.js b/js/src/tests/test262/language/statements/for/decl-async-gen.js
new file mode 100644
index 0000000000..5cdc92d353
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/decl-async-gen.js
@@ -0,0 +1,21 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-for-statement
+description: >
+ AsyncGeneratorDeclaration is not allowed in statement position
+info: |
+ ExpressionStatement[Yield, Await] :
+ [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
+ Expression[+In, ?Yield, ?Await] ;
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-iteration]
+---*/
+
+$DONOTEVALUATE();
+
+for ( ; false; ) async function* g() {}
diff --git a/js/src/tests/test262/language/statements/for/decl-cls.js b/js/src/tests/test262/language/statements/for/decl-cls.js
new file mode 100644
index 0000000000..7bed947edd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/decl-cls.js
@@ -0,0 +1,15 @@
+// |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.
+/*---
+description: Class declaration not allowed in statement position
+esid: sec-for-statement
+es6id: 13.7.4
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+for ( ; false; ) class C {}
diff --git a/js/src/tests/test262/language/statements/for/decl-const.js b/js/src/tests/test262/language/statements/for/decl-const.js
new file mode 100644
index 0000000000..80e7509f65
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/decl-const.js
@@ -0,0 +1,15 @@
+// |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.
+/*---
+description: Lexical declaration (const) not allowed in statement position
+esid: sec-for-statement
+es6id: 13.7.4
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+for ( ; false; ) const x = null;
diff --git a/js/src/tests/test262/language/statements/for/decl-fun.js b/js/src/tests/test262/language/statements/for/decl-fun.js
new file mode 100644
index 0000000000..edf212db56
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/decl-fun.js
@@ -0,0 +1,15 @@
+// |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.
+/*---
+description: Function declaration not allowed in statement position
+esid: sec-for-statement
+es6id: 13.7.4
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+for ( ; false; ) function f() {}
diff --git a/js/src/tests/test262/language/statements/for/decl-gen.js b/js/src/tests/test262/language/statements/for/decl-gen.js
new file mode 100644
index 0000000000..94de156ced
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/decl-gen.js
@@ -0,0 +1,16 @@
+// |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.
+/*---
+description: Generator declaration not allowed in statement position
+esid: sec-for-statement
+es6id: 13.7.4
+negative:
+ phase: parse
+ type: SyntaxError
+features: [generators]
+---*/
+
+$DONOTEVALUATE();
+
+for ( ; false; ) function* g() {}
diff --git a/js/src/tests/test262/language/statements/for/decl-let.js b/js/src/tests/test262/language/statements/for/decl-let.js
new file mode 100644
index 0000000000..626d01ff39
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/decl-let.js
@@ -0,0 +1,15 @@
+// |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.
+/*---
+description: Lexical declaration (let) not allowed in statement position
+esid: sec-for-statement
+es6id: 13.7.4
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+for ( ; false; ) let x;
diff --git a/js/src/tests/test262/language/statements/for/dstr/browser.js b/js/src/tests/test262/language/statements/for/dstr/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/browser.js
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-close.js
new file mode 100644
index 0000000000..82b8dcccb5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-close.js
@@ -0,0 +1,72 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-init-iter-close.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [x] = iter; iterCount < 1; ) {
+ assert.sameValue(doneCallCount, 1);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-get-err-array-prototype.js
new file mode 100644
index 0000000000..a8a6141051
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-get-err-array-prototype.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Abrupt completion returned by GetIterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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];
+
+assert.throws(TypeError, function() {
+ for (const [x, y, z] = [1, 2, 3]; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-get-err.js
new file mode 100644
index 0000000000..b2d551a7f3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-get-err.js
@@ -0,0 +1,57 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-init-iter-get-err.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Abrupt completion returned by GetIterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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();
+};
+
+assert.throws(Test262Error, function() {
+ for (const [x] = iter; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..f2a591d689
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-init-iter-no-close.js
@@ -0,0 +1,72 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-init-iter-no-close.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [x] = iter; iterCount < 1; ) {
+ assert.sameValue(doneCallCount, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-name-iter-val.js
new file mode 100644
index 0000000000..1155e61c1c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-name-iter-val.js
@@ -0,0 +1,71 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-name-iter-val.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: SingleNameBinding with normal value iteration (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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 iterCount = 0;
+
+for (const [x, y, z] = [1, 2, 3]; iterCount < 1; ) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..d9ae3db7bb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [[x, y, z] = [4, 5, 6]] = []; iterCount < 1; ) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..8aeffa2527
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]; iterCount < 1; ) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..633be24808
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,70 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [[,] = g()] = []; iterCount < 1; ) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..d99f5f3c9b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,67 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [[,] = g()] = [[]]; iterCount < 1; ) {
+ assert.sameValue(callCount, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..9d0d0edbfd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,66 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [[] = function() { initCount += 1; return iter; }()] = []; iterCount < 1; ) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..41cb484112
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [[] = function() { initCount += 1; }()] = [[23]]; iterCount < 1; ) {
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..e999f90e58
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,67 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [[...x] = values] = []; iterCount < 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);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..cf579a270b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,70 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [[...x] = function() { initCount += 1; }()] = [values]; iterCount < 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);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-val-null.js
new file mode 100644
index 0000000000..9d27df4662
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-ary-val-null.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Nested array destructuring with a null value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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).
+---*/
+
+assert.throws(TypeError, function() {
+ for (const [[x]] = [null]; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..bd92b0f02f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [x = 23] = []; iterCount < 1; ) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..e799ee7f5d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,63 @@
+// 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/for-const.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [arrow = () => {}] = []; iterCount < 1; ) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..e51e737b3c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,65 @@
+// 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/for-const.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []; iterCount < 1; ) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..982e819c20
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,64 @@
+// 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/for-const.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [cover = (function () {}), xCover = (0, function() {})] = []; iterCount < 1; ) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..ed27fff8c0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,64 @@
+// 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/for-const.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [fn = function () {}, xFn = function x() {}] = []; iterCount < 1; ) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..34ecbf8f24
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,65 @@
+// 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/for-const.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [gen = function* () {}, xGen = function* x() {}] = []; iterCount < 1; ) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..eb79898c9c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Destructuring initializer with a "hole" (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [x = 23] = [,]; iterCount < 1; ) {
+ assert.sameValue(x, 23);
+ // another statement
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..2ee1c9d75a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,67 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']; iterCount < 1; ) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-throws.js
new file mode 100644
index 0000000000..0196c4863f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-throws.js
@@ -0,0 +1,55 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Destructuring initializer returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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).
+---*/
+
+assert.throws(Test262Error, function() {
+ for (const [x = (function() { throw new Test262Error(); })()] = [undefined]; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..40ffe0553d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,61 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Destructuring initializer with an undefined value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [x = 23] = [undefined]; iterCount < 1; ) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-unresolvable.js
new file mode 100644
index 0000000000..dfacdf5de4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-init-unresolvable.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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.
+---*/
+
+assert.throws(ReferenceError, function() {
+ for (const [ x = unresolvableReference ] = []; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..b897e7ee3f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,65 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: SingleNameBinding when value iteration completes (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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,
+ [...]
+ 5. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 8. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+for (const [x] = []; iterCount < 1; ) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..36b1422ed1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,60 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [_, x] = []; iterCount < 1; ) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-step-err.js
new file mode 100644
index 0000000000..a728f01648
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-step-err.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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).
+
+---*/
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next: function() {
+ throw new Test262Error();
+ }
+ };
+};
+
+assert.throws(Test262Error, function() {
+ for (const [x] = g; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-val-array-prototype.js
new file mode 100644
index 0000000000..98ae3362c4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-val-array-prototype.js
@@ -0,0 +1,81 @@
+// 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/for-const.template
+/*---
+description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [x, y, z] = [1, 2, 3]; iterCount < 1; ) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 42);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-val-err.js
new file mode 100644
index 0000000000..81fcf8b192
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-val-err.js
@@ -0,0 +1,75 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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).
+
+---*/
+var poisonedValue = Object.defineProperty({}, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next: function() {
+ return poisonedValue;
+ }
+ };
+};
+
+assert.throws(Test262Error, function() {
+ for (const [x] = g; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..bca24af5b8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,71 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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 iterCount = 0;
+
+for (const [x, y, z] = [1, 2, 3]; iterCount < 1; ) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..3aa212bb2d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] = []; iterCount < 1; ) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..8f19eb03d9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]; iterCount < 1; ) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..daa57464db
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,73 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []; iterCount < 1; ) {
+ 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;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..7af2967d3d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,73 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]; iterCount < 1; ) {
+ 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;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-val-null.js
new file mode 100644
index 0000000000..a3327710d8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-val-null.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Nested object destructuring with a null value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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).
+---*/
+
+assert.throws(TypeError, function() {
+ for (const [{ x }] = [null]; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-val-undef.js
new file mode 100644
index 0000000000..6c8646eecd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elem-obj-val-undef.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Nested object destructuring with a value of `undefined` (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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).
+---*/
+
+assert.throws(TypeError, function() {
+ for (const [{ x }] = []; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..cf5b500fb9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,68 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Elision accepts exhausted iterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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
+ [...]
+ 2. Return NormalCompletion(empty).
+
+---*/
+var iter = function*() {}();
+iter.next();
+
+var iterCount = 0;
+
+for (const [,] = iter; iterCount < 1; ) {
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision-iter-close.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision-iter-close.js
new file mode 100644
index 0000000000..711f4efb8a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision-iter-close.js
@@ -0,0 +1,54 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elision-iter-close.case
+// - src/dstr-binding/iter-close/for-const.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+function fn() {
+ for (const [,] = iter; ; ) {
+ return;
+ }
+}
+
+fn();
+
+assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision-step-err.js
new file mode 100644
index 0000000000..a0ee1f3409
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision-step-err.js
@@ -0,0 +1,71 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elision-step-err.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Elision advances iterator and forwards abrupt completions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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).
+
+---*/
+var following = 0;
+var iter =function* () {
+ throw new Test262Error();
+ following += 1;
+}();
+
+assert.throws(Test262Error, function() {
+ for (const [,] = iter; ; ) {
+ return;
+ }
+});
+
+iter.next();
+assert.sameValue(following, 0, 'Iterator was properly closed.');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision.js
new file mode 100644
index 0000000000..dacc91f8e5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-elision.js
@@ -0,0 +1,77 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elision.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Elision advances iterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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 iterCount = 0;
+
+for (const [,] = g(); iterCount < 1; ) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-empty.js
new file mode 100644
index 0000000000..511fcbbd64
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-empty.js
@@ -0,0 +1,60 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-empty.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+for (const [] = iter; iterCount < 1; ) {
+ assert.sameValue(iterations, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..8dc450d5eb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,84 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [...[x, y, z]] = [3, 4, 5]; iterCount < 1; ) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..b32cf05e5c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,90 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Rest element containing an elision (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [...[,]] = g(); iterCount < 1; ) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..6f2bed0ff0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,73 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Rest element containing an "empty" array pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [...[]] = iter; iterCount < 1; ) {
+ assert.sameValue(iterations, 1);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..916036de12
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,69 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Rest element containing a rest element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [...[...x]] = values; iterCount < 1; ) {
+ 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);
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-direct.js
new file mode 100644
index 0000000000..27cf937eb1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-direct.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-direct.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Lone rest element (direct binding) (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+includes: [compareArray.js]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [...x] = [1]; iterCount < 1; ) {
+ assert(Array.isArray(x));
+ assert.compareArray(x, [1]);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-elision-next-err.js
new file mode 100644
index 0000000000..0f9ff83330
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-elision-next-err.js
@@ -0,0 +1,57 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Rest element following elision elements (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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(); })();
+
+assert.throws(Test262Error, function() {
+ for (const [, ...x] = iter; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..661a007a00
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,65 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Rest element following elision elements (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [ , , ...x] = values; iterCount < 1; ) {
+ 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);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..7535e7ad0e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,61 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: RestElement applied to an exhausted iterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [, , ...x] = [1, 2]; iterCount < 1; ) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-iter-close.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-iter-close.js
new file mode 100644
index 0000000000..6944224356
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-iter-close.js
@@ -0,0 +1,54 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-iter-close.case
+// - src/dstr-binding/iter-close/for-const.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+function fn() {
+ for (const [...x] = iter; ; ) {
+ return;
+ }
+}
+
+fn();
+
+assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-iter-step-err.js
new file mode 100644
index 0000000000..08002818b2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-iter-step-err.js
@@ -0,0 +1,68 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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;
+}();
+
+assert.throws(Test262Error, function() {
+ for (const [...x] = iter; ; ) {
+ return;
+ }
+});
+
+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/for/dstr/const-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-iter-val-err.js
new file mode 100644
index 0000000000..3bd553bc52
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id-iter-val-err.js
@@ -0,0 +1,70 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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;
+ }
+ };
+};
+
+assert.throws(Test262Error, function() {
+ for (const [...x] = iter; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..fb77daed83
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-id.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Lone rest element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [...x] = values; iterCount < 1; ) {
+ 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);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..4110b965a5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,58 @@
+// |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/for-const.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (const [...[ x ] = []] = []; iterCount < 1; ) {
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..dcb35c356c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-init-id.js
@@ -0,0 +1,58 @@
+// |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/for-const.template
+/*---
+description: Rest element (identifier) does not support initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (const [...x = []] = []; iterCount < 1; ) {
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..5af8cddb87
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,58 @@
+// |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/for-const.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (const [...{ x } = []] = []; iterCount < 1; ) {
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..585619c48f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,58 @@
+// |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/for-const.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (const [...[x], y] = [1, 2, 3]; iterCount < 1; ) {
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..df2ffe4347
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,58 @@
+// |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/for-const.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (const [...x, y] = [1, 2, 3]; iterCount < 1; ) {
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..b8fdc570ee
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,58 @@
+// |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/for-const.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (const [...{ x }, y] = [1, 2, 3]; iterCount < 1; ) {
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..07b35b16ae
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Rest element containing an object binding pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [...{ length }] = [1, 2, 3]; iterCount < 1; ) {
+ assert.sameValue(length, 3);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..6a9e1e0d4a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,69 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Rest element containing an object binding pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const [...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]; iterCount < 1; ) {
+ 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");
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-init-null.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-init-null.js
new file mode 100644
index 0000000000..68ef6e2d0b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-init-null.js
@@ -0,0 +1,51 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-init-null.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (null) (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+assert.throws(TypeError, function() {
+ for (const {} = null; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-init-undefined.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-init-undefined.js
new file mode 100644
index 0000000000..ad8c5af4da
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-init-undefined.js
@@ -0,0 +1,51 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-init-undefined.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (undefined) (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+assert.throws(TypeError, function() {
+ for (const {} = undefined; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-empty.js
new file mode 100644
index 0000000000..bf2a673944
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-empty.js
@@ -0,0 +1,61 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-empty.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+
+for (const {} = obj; iterCount < 1; ) {
+ assert.sameValue(accessCount, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-get-value-err.js
new file mode 100644
index 0000000000..03babd9f86
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-get-value-err.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-get-value-err.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ for (const { poisoned } = poisonedProperty; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..994be64197
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const { arrow = () => {} } = {}; iterCount < 1; ) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..1c74976df0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}; iterCount < 1; ) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..948ebc828b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const { cover = (function () {}), xCover = (0, function() {}) } = {}; iterCount < 1; ) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..126b172d8a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const { fn = function () {}, xFn = function x() {} } = {}; iterCount < 1; ) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..d911b27e27
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const { gen = function* () {}, xGen = function* x() {} } = {}; iterCount < 1; ) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..221f28a559
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,66 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const { w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }; iterCount < 1; ) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-throws.js
new file mode 100644
index 0000000000..e06d8b8ade
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-throws.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-throws.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Error thrown when evaluating the initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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();
+}
+
+assert.throws(Test262Error, function() {
+ for (const { x = thrower() } = {}; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-unresolvable.js
new file mode 100644
index 0000000000..ac987849aa
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-init-unresolvable.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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.
+---*/
+
+assert.throws(ReferenceError, function() {
+ for (const { x = unresolvableReference } = {}; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..4dff9fa61b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+for (const { x, } = { x: 23 }; iterCount < 1; ) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-list-err.js
new file mode 100644
index 0000000000..a4b4e86927
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-list-err.js
@@ -0,0 +1,59 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-list-err.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Binding property list evaluation is interrupted by an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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();
+}
+
+assert.throws(Test262Error, function() {
+ for (const { a, b = thrower(), c = ++initCount } = {}; ; ) {
+ return;
+ }
+});
+
+assert.sameValue(initCount, 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..7aedeedf91
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,65 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const { w: [x, y, z] = [4, 5, 6] } = {}; iterCount < 1; ) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..ec65932309
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+for (const { x: [y], } = { x: [45] }; iterCount < 1; ) {
+ assert.sameValue(y,45);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary-value-null.js
new file mode 100644
index 0000000000..f411e7aa64
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary-value-null.js
@@ -0,0 +1,53 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Object binding pattern with "nested" array binding pattern taking the `null` value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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.
+---*/
+
+assert.throws(TypeError, function() {
+ for (const { w: [x, y, z] = [4, 5, 6] } = { w: null }; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..38ccfb74e1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-ary.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-ary.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const { w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }; iterCount < 1; ) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-eval-err.js
new file mode 100644
index 0000000000..4a827b7bc8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-eval-err.js
@@ -0,0 +1,55 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-eval-err.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Evaluation of property name returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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();
+}
+
+assert.throws(Test262Error, function() {
+ for (const { [thrower()]: x } = {}; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-get-value-err.js
new file mode 100644
index 0000000000..5a3b29e4e6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-get-value-err.js
@@ -0,0 +1,60 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ for (const { poisoned: x = ++initEvalCount } = poisonedProperty; ; ) {
+ return;
+ }
+});
+
+assert.sameValue(initEvalCount, 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..0368f83485
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,78 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }; iterCount < 1; ) {
+ 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;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init-throws.js
new file mode 100644
index 0000000000..408eed7502
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init-throws.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Error thrown when evaluating the initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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();
+}
+
+assert.throws(Test262Error, function() {
+ for (const { x: y = thrower() } = {}; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init-unresolvable.js
new file mode 100644
index 0000000000..946f6274bd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init-unresolvable.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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.
+---*/
+
+assert.throws(ReferenceError, function() {
+ for (const { x: y = unresolvableReference } = {}; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..0ec7e0c7e4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-init.js
@@ -0,0 +1,59 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-init.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializeropt
+
+ [...]
+ 8. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+for (const { x: y = 33 } = { }; iterCount < 1; ) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..17c0198427
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,60 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+for (const { x: y, } = { x: 23 }; iterCount < 1; ) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..9fe44433ae
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-id.js
@@ -0,0 +1,59 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Binding as specified via property name and identifier (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializeropt
+
+ [...]
+ 8. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+for (const { x: y } = { x: 23 }; iterCount < 1; ) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..01c5de1836
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,65 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }; iterCount < 1; ) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj-value-null.js
new file mode 100644
index 0000000000..0074f7be11
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj-value-null.js
@@ -0,0 +1,53 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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.
+---*/
+
+assert.throws(TypeError, function() {
+ for (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj-value-undef.js
new file mode 100644
index 0000000000..bde5850380
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj-value-undef.js
@@ -0,0 +1,53 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case
+// - src/dstr-binding/error/for-const.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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.
+---*/
+
+assert.throws(TypeError, function() {
+ for (const { w: { x, y, z } = undefined } = { }; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..0952820109
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-prop-obj.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-obj.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }; iterCount < 1; ) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..0c1e3bac81
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-rest-getter.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-rest-getter.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding]
+flags: [generated]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+---*/
+var count = 0;
+
+var iterCount = 0;
+
+for (const {...x} = { get v() { count++; return 2; } }; iterCount < 1; ) {
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..cc1e0ba07a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,66 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding]
+flags: [generated]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+
+for (const {...rest} = o; iterCount < 1; ) {
+ 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
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..5e5831fcc4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/const-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,65 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding/default/for-const.template
+/*---
+description: Rest object contains just unextracted data (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding]
+flags: [generated]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+---*/
+
+var iterCount = 0;
+
+for (const {a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}; iterCount < 1; ) {
+ 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
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-close.js
new file mode 100644
index 0000000000..b46d5fd597
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-close.js
@@ -0,0 +1,72 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-init-iter-close.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [x] = iter; iterCount < 1; ) {
+ assert.sameValue(doneCallCount, 1);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-get-err-array-prototype.js
new file mode 100644
index 0000000000..beb50ef2c8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-get-err-array-prototype.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Abrupt completion returned by GetIterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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];
+
+assert.throws(TypeError, function() {
+ for (let [x, y, z] = [1, 2, 3]; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-get-err.js
new file mode 100644
index 0000000000..790cc5eb81
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-get-err.js
@@ -0,0 +1,57 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-init-iter-get-err.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Abrupt completion returned by GetIterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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();
+};
+
+assert.throws(Test262Error, function() {
+ for (let [x] = iter; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..245bc645cd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-init-iter-no-close.js
@@ -0,0 +1,72 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-init-iter-no-close.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [x] = iter; iterCount < 1; ) {
+ assert.sameValue(doneCallCount, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-name-iter-val.js
new file mode 100644
index 0000000000..b4b1112b23
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-name-iter-val.js
@@ -0,0 +1,71 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-name-iter-val.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: SingleNameBinding with normal value iteration (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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 iterCount = 0;
+
+for (let [x, y, z] = [1, 2, 3]; iterCount < 1; ) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..0f3756a158
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [[x, y, z] = [4, 5, 6]] = []; iterCount < 1; ) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..94de4d43ba
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]; iterCount < 1; ) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..445298a95b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,70 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [[,] = g()] = []; iterCount < 1; ) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..99458724a9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,67 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [[,] = g()] = [[]]; iterCount < 1; ) {
+ assert.sameValue(callCount, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..3c9585ccf5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,66 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [[] = function() { initCount += 1; return iter; }()] = []; iterCount < 1; ) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..466820ed07
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [[] = function() { initCount += 1; }()] = [[23]]; iterCount < 1; ) {
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..436a374073
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,67 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [[...x] = values] = []; iterCount < 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);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..a7d995ea65
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,70 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [[...x] = function() { initCount += 1; }()] = [values]; iterCount < 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);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-val-null.js
new file mode 100644
index 0000000000..635ba4adb5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-ary-val-null.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Nested array destructuring with a null value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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).
+---*/
+
+assert.throws(TypeError, function() {
+ for (let [[x]] = [null]; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..b295973196
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [x = 23] = []; iterCount < 1; ) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..94209b3b63
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,63 @@
+// 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/for-let.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [arrow = () => {}] = []; iterCount < 1; ) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..b46b359b97
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,65 @@
+// 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/for-let.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []; iterCount < 1; ) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..d65aab5bd7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,64 @@
+// 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/for-let.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [cover = (function () {}), xCover = (0, function() {})] = []; iterCount < 1; ) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..69cdf63467
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,64 @@
+// 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/for-let.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [fn = function () {}, xFn = function x() {}] = []; iterCount < 1; ) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..4e070e3c7e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,65 @@
+// 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/for-let.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [gen = function* () {}, xGen = function* x() {}] = []; iterCount < 1; ) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..f13bdb02ef
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Destructuring initializer with a "hole" (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [x = 23] = [,]; iterCount < 1; ) {
+ assert.sameValue(x, 23);
+ // another statement
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..03debf5045
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,67 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']; iterCount < 1; ) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-throws.js
new file mode 100644
index 0000000000..641a491813
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-throws.js
@@ -0,0 +1,55 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Destructuring initializer returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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).
+---*/
+
+assert.throws(Test262Error, function() {
+ for (let [x = (function() { throw new Test262Error(); })()] = [undefined]; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..832c202585
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,61 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Destructuring initializer with an undefined value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [x = 23] = [undefined]; iterCount < 1; ) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-unresolvable.js
new file mode 100644
index 0000000000..d15504afe8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-init-unresolvable.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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.
+---*/
+
+assert.throws(ReferenceError, function() {
+ for (let [ x = unresolvableReference ] = []; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..4bce1d556a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,65 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: SingleNameBinding when value iteration completes (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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,
+ [...]
+ 5. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 8. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+for (let [x] = []; iterCount < 1; ) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..8205a32305
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,60 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [_, x] = []; iterCount < 1; ) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-step-err.js
new file mode 100644
index 0000000000..9eba7c8eaf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-step-err.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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).
+
+---*/
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next: function() {
+ throw new Test262Error();
+ }
+ };
+};
+
+assert.throws(Test262Error, function() {
+ for (let [x] = g; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-val-array-prototype.js
new file mode 100644
index 0000000000..008f32cf8d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-val-array-prototype.js
@@ -0,0 +1,81 @@
+// 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/for-let.template
+/*---
+description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [x, y, z] = [1, 2, 3]; iterCount < 1; ) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 42);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-val-err.js
new file mode 100644
index 0000000000..62d54f3f50
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-val-err.js
@@ -0,0 +1,75 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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).
+
+---*/
+var poisonedValue = Object.defineProperty({}, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next: function() {
+ return poisonedValue;
+ }
+ };
+};
+
+assert.throws(Test262Error, function() {
+ for (let [x] = g; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..cea92a6f26
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,71 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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 iterCount = 0;
+
+for (let [x, y, z] = [1, 2, 3]; iterCount < 1; ) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..02f6a50032
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] = []; iterCount < 1; ) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..6ce4298e86
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]; iterCount < 1; ) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..ddb13b3454
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,73 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []; iterCount < 1; ) {
+ 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;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..82aa90dc5d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,73 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]; iterCount < 1; ) {
+ 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;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-val-null.js
new file mode 100644
index 0000000000..14454e0d69
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-val-null.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Nested object destructuring with a null value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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).
+---*/
+
+assert.throws(TypeError, function() {
+ for (let [{ x }] = [null]; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-val-undef.js
new file mode 100644
index 0000000000..503cf609ca
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elem-obj-val-undef.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Nested object destructuring with a value of `undefined` (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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).
+---*/
+
+assert.throws(TypeError, function() {
+ for (let [{ x }] = []; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..1f500678fd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,68 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Elision accepts exhausted iterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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
+ [...]
+ 2. Return NormalCompletion(empty).
+
+---*/
+var iter = function*() {}();
+iter.next();
+
+var iterCount = 0;
+
+for (let [,] = iter; iterCount < 1; ) {
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision-iter-close.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision-iter-close.js
new file mode 100644
index 0000000000..b7925772cc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision-iter-close.js
@@ -0,0 +1,54 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elision-iter-close.case
+// - src/dstr-binding/iter-close/for-let.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+function fn() {
+ for (let [,] = iter; ; ) {
+ return;
+ }
+}
+
+fn();
+
+assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision-step-err.js
new file mode 100644
index 0000000000..6b8e6d793d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision-step-err.js
@@ -0,0 +1,71 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elision-step-err.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Elision advances iterator and forwards abrupt completions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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).
+
+---*/
+var following = 0;
+var iter =function* () {
+ throw new Test262Error();
+ following += 1;
+}();
+
+assert.throws(Test262Error, function() {
+ for (let [,] = iter; ; ) {
+ return;
+ }
+});
+
+iter.next();
+assert.sameValue(following, 0, 'Iterator was properly closed.');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision.js
new file mode 100644
index 0000000000..ee609a1dfd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-elision.js
@@ -0,0 +1,77 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elision.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Elision advances iterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env 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 iterCount = 0;
+
+for (let [,] = g(); iterCount < 1; ) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-empty.js
new file mode 100644
index 0000000000..113b950db5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-empty.js
@@ -0,0 +1,60 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-empty.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+for (let [] = iter; iterCount < 1; ) {
+ assert.sameValue(iterations, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..b4de8e4e9c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,84 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [...[x, y, z]] = [3, 4, 5]; iterCount < 1; ) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..df1a046293
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,90 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Rest element containing an elision (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [...[,]] = g(); iterCount < 1; ) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..1527a0298f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,73 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Rest element containing an "empty" array pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [...[]] = iter; iterCount < 1; ) {
+ assert.sameValue(iterations, 1);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..2538b698a7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,69 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Rest element containing a rest element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [...[...x]] = values; iterCount < 1; ) {
+ 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);
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-direct.js
new file mode 100644
index 0000000000..fb4bf0d235
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-direct.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-direct.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Lone rest element (direct binding) (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+includes: [compareArray.js]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [...x] = [1]; iterCount < 1; ) {
+ assert(Array.isArray(x));
+ assert.compareArray(x, [1]);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-elision-next-err.js
new file mode 100644
index 0000000000..a4e11ba5fd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-elision-next-err.js
@@ -0,0 +1,57 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Rest element following elision elements (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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(); })();
+
+assert.throws(Test262Error, function() {
+ for (let [, ...x] = iter; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..51e1dcf888
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,65 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Rest element following elision elements (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [ , , ...x] = values; iterCount < 1; ) {
+ 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);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..cc520886d9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,61 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: RestElement applied to an exhausted iterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [, , ...x] = [1, 2]; iterCount < 1; ) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-iter-close.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-iter-close.js
new file mode 100644
index 0000000000..6eeeced81b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-iter-close.js
@@ -0,0 +1,54 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-iter-close.case
+// - src/dstr-binding/iter-close/for-let.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+function fn() {
+ for (let [...x] = iter; ; ) {
+ return;
+ }
+}
+
+fn();
+
+assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-iter-step-err.js
new file mode 100644
index 0000000000..42349f9537
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-iter-step-err.js
@@ -0,0 +1,68 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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;
+}();
+
+assert.throws(Test262Error, function() {
+ for (let [...x] = iter; ; ) {
+ return;
+ }
+});
+
+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/for/dstr/let-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-iter-val-err.js
new file mode 100644
index 0000000000..4438a09945
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id-iter-val-err.js
@@ -0,0 +1,70 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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;
+ }
+ };
+};
+
+assert.throws(Test262Error, function() {
+ for (let [...x] = iter; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..43336a1d31
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-id.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Lone rest element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [...x] = values; iterCount < 1; ) {
+ 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);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..38325cc35e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,58 @@
+// |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/for-let.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (let [...[ x ] = []] = []; iterCount < 1; ) {
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..7807b11e6c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-init-id.js
@@ -0,0 +1,58 @@
+// |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/for-let.template
+/*---
+description: Rest element (identifier) does not support initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (let [...x = []] = []; iterCount < 1; ) {
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..dbec97b0d5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,58 @@
+// |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/for-let.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (let [...{ x } = []] = []; iterCount < 1; ) {
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..f6429d3d3c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,58 @@
+// |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/for-let.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (let [...[x], y] = [1, 2, 3]; iterCount < 1; ) {
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..43e6e4c30c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,58 @@
+// |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/for-let.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (let [...x, y] = [1, 2, 3]; iterCount < 1; ) {
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..eb725cba74
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,58 @@
+// |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/for-let.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (let [...{ x }, y] = [1, 2, 3]; iterCount < 1; ) {
+
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..334c180952
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Rest element containing an object binding pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [...{ length }] = [1, 2, 3]; iterCount < 1; ) {
+ assert.sameValue(length, 3);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..475e677ed7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,69 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Rest element containing an object binding pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let [...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]; iterCount < 1; ) {
+ 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");
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-init-null.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-init-null.js
new file mode 100644
index 0000000000..1248850347
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-init-null.js
@@ -0,0 +1,51 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-init-null.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (null) (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+assert.throws(TypeError, function() {
+ for (let {} = null; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-init-undefined.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-init-undefined.js
new file mode 100644
index 0000000000..18f71d6b61
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-init-undefined.js
@@ -0,0 +1,51 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-init-undefined.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (undefined) (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+assert.throws(TypeError, function() {
+ for (let {} = undefined; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-empty.js
new file mode 100644
index 0000000000..d2135e7d4d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-empty.js
@@ -0,0 +1,61 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-empty.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+
+for (let {} = obj; iterCount < 1; ) {
+ assert.sameValue(accessCount, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-get-value-err.js
new file mode 100644
index 0000000000..4505dcd718
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-get-value-err.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-get-value-err.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ for (let { poisoned } = poisonedProperty; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..454e3b9376
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let { arrow = () => {} } = {}; iterCount < 1; ) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..a70b17f042
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}; iterCount < 1; ) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..252de0a8a4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let { cover = (function () {}), xCover = (0, function() {}) } = {}; iterCount < 1; ) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..aa0f6e57f8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let { fn = function () {}, xFn = function x() {} } = {}; iterCount < 1; ) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..ed3020e4d9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let { gen = function* () {}, xGen = function* x() {} } = {}; iterCount < 1; ) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..591115ef56
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,66 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let { w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }; iterCount < 1; ) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-throws.js
new file mode 100644
index 0000000000..01a86e5636
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-throws.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-throws.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Error thrown when evaluating the initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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();
+}
+
+assert.throws(Test262Error, function() {
+ for (let { x = thrower() } = {}; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-unresolvable.js
new file mode 100644
index 0000000000..06ece3e50a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-init-unresolvable.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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.
+---*/
+
+assert.throws(ReferenceError, function() {
+ for (let { x = unresolvableReference } = {}; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..c547644141
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+for (let { x, } = { x: 23 }; iterCount < 1; ) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-list-err.js
new file mode 100644
index 0000000000..4683057f6a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-list-err.js
@@ -0,0 +1,59 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-list-err.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Binding property list evaluation is interrupted by an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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();
+}
+
+assert.throws(Test262Error, function() {
+ for (let { a, b = thrower(), c = ++initCount } = {}; ; ) {
+ return;
+ }
+});
+
+assert.sameValue(initCount, 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..bc6f8e301d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,65 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let { w: [x, y, z] = [4, 5, 6] } = {}; iterCount < 1; ) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..61f0b2b0d3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+for (let { x: [y], } = { x: [45] }; iterCount < 1; ) {
+ assert.sameValue(y,45);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary-value-null.js
new file mode 100644
index 0000000000..ce9f1306e9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary-value-null.js
@@ -0,0 +1,53 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Object binding pattern with "nested" array binding pattern taking the `null` value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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.
+---*/
+
+assert.throws(TypeError, function() {
+ for (let { w: [x, y, z] = [4, 5, 6] } = { w: null }; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..9b25e5eee4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-ary.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-ary.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let { w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }; iterCount < 1; ) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-eval-err.js
new file mode 100644
index 0000000000..62215ef8fe
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-eval-err.js
@@ -0,0 +1,55 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-eval-err.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Evaluation of property name returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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();
+}
+
+assert.throws(Test262Error, function() {
+ for (let { [thrower()]: x } = {}; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-get-value-err.js
new file mode 100644
index 0000000000..908a2439d1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-get-value-err.js
@@ -0,0 +1,60 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ for (let { poisoned: x = ++initEvalCount } = poisonedProperty; ; ) {
+ return;
+ }
+});
+
+assert.sameValue(initEvalCount, 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..5225a15d39
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,78 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }; iterCount < 1; ) {
+ 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;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init-throws.js
new file mode 100644
index 0000000000..3c16194865
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init-throws.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Error thrown when evaluating the initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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();
+}
+
+assert.throws(Test262Error, function() {
+ for (let { x: y = thrower() } = {}; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init-unresolvable.js
new file mode 100644
index 0000000000..188d9619ff
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init-unresolvable.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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.
+---*/
+
+assert.throws(ReferenceError, function() {
+ for (let { x: y = unresolvableReference } = {}; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..dd7e1eeede
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-init.js
@@ -0,0 +1,59 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-init.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializeropt
+
+ [...]
+ 8. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+for (let { x: y = 33 } = { }; iterCount < 1; ) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..4acce0897b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,60 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+for (let { x: y, } = { x: 23 }; iterCount < 1; ) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..91b06b0970
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-id.js
@@ -0,0 +1,59 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Binding as specified via property name and identifier (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializeropt
+
+ [...]
+ 8. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+for (let { x: y } = { x: 23 }; iterCount < 1; ) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..69d56260eb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,65 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }; iterCount < 1; ) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj-value-null.js
new file mode 100644
index 0000000000..c37923195d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj-value-null.js
@@ -0,0 +1,53 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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.
+---*/
+
+assert.throws(TypeError, function() {
+ for (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj-value-undef.js
new file mode 100644
index 0000000000..5c576e9690
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj-value-undef.js
@@ -0,0 +1,53 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case
+// - src/dstr-binding/error/for-let.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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.
+---*/
+
+assert.throws(TypeError, function() {
+ for (let { w: { x, y, z } = undefined } = { }; ; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..1b5c431d45
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-prop-obj.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-obj.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the 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 iterCount = 0;
+
+for (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }; iterCount < 1; ) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..9fc329218a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-rest-getter.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-rest-getter.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding]
+flags: [generated]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+---*/
+var count = 0;
+
+var iterCount = 0;
+
+for (let {...x} = { get v() { count++; return 2; } }; iterCount < 1; ) {
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..a96b4e8c1f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,66 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding]
+flags: [generated]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+
+for (let {...rest} = o; iterCount < 1; ) {
+ 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
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..e951bc1079
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/let-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,65 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding/default/for-let.template
+/*---
+description: Rest object contains just unextracted data (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding]
+flags: [generated]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ [...]
+ 7. Let forDcl be the result of evaluating LexicalDeclaration.
+ [...]
+
+ LexicalDeclaration : LetOrConst BindingList ;
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return NormalCompletion(empty).
+
+ BindingList : BindingList , LexicalBinding
+
+ 1. Let next be the result of evaluating BindingList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating LexicalBinding.
+
+ LexicalBinding : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let value be GetValue(rhs).
+ 3. ReturnIfAbrupt(value).
+ 4. Let env be the running execution context’s LexicalEnvironment.
+ 5. Return the result of performing BindingInitialization for BindingPattern
+ using value and env as the arguments.
+---*/
+
+var iterCount = 0;
+
+for (let {a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}; iterCount < 1; ) {
+ 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
+ });
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/shell.js b/js/src/tests/test262/language/statements/for/dstr/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/shell.js
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-close.js
new file mode 100644
index 0000000000..129718d89c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-close.js
@@ -0,0 +1,65 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-init-iter-close.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [x] = iter; iterCount < 1; ) {
+ assert.sameValue(doneCallCount, 1);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-get-err-array-prototype.js
new file mode 100644
index 0000000000..9f73854ed4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-get-err-array-prototype.js
@@ -0,0 +1,57 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Abrupt completion returned by GetIterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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];
+
+assert.throws(TypeError, function() {
+ for (var [x, y, z] = [1, 2, 3]; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-get-err.js
new file mode 100644
index 0000000000..e85b650ba3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-get-err.js
@@ -0,0 +1,51 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-init-iter-get-err.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Abrupt completion returned by GetIterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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();
+};
+
+assert.throws(Test262Error, function() {
+ for (var [x] = iter; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..e732e7cb2d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-init-iter-no-close.js
@@ -0,0 +1,65 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-init-iter-no-close.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [x] = iter; iterCount < 1; ) {
+ assert.sameValue(doneCallCount, 0);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-name-iter-val.js
new file mode 100644
index 0000000000..2ed173c001
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-name-iter-val.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-name-iter-val.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: SingleNameBinding with normal value iteration (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [x, y, z] = [1, 2, 3]; iterCount < 1; ) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..0c1dca7ab5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [[x, y, z] = [4, 5, 6]] = []; iterCount < 1; ) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..63683edd92
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,57 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]; iterCount < 1; ) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..aabe9affb1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [[,] = g()] = []; iterCount < 1; ) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..2b1d75eaed
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,60 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [[,] = g()] = [[]]; iterCount < 1; ) {
+ assert.sameValue(callCount, 0);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..ccf471099b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,59 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [[] = function() { initCount += 1; return iter; }()] = []; iterCount < 1; ) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..4a13b8f650
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [[] = function() { initCount += 1; }()] = [[23]]; iterCount < 1; ) {
+ assert.sameValue(initCount, 0);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..fdc4dd526f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,60 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [[...x] = values] = []; iterCount < 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);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..bf23b35010
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,63 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [[...x] = function() { initCount += 1; }()] = [values]; iterCount < 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);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-val-null.js
new file mode 100644
index 0000000000..b43a20b073
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-ary-val-null.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Nested array destructuring with a null value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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).
+---*/
+
+assert.throws(TypeError, function() {
+ for (var [[x]] = [null]; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..d68bc7555f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,55 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [x = 23] = []; iterCount < 1; ) {
+ assert.sameValue(x, 23);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..50f5ad59e3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,56 @@
+// 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/for-var.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [arrow = () => {}] = []; iterCount < 1; ) {
+ assert.sameValue(arrow.name, 'arrow');
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..5417255ee2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,58 @@
+// 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/for-var.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []; iterCount < 1; ) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..a6a29e3811
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,57 @@
+// 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/for-var.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [cover = (function () {}), xCover = (0, function() {})] = []; iterCount < 1; ) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..28282c1ce4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,57 @@
+// 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/for-var.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [fn = function () {}, xFn = function x() {}] = []; iterCount < 1; ) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..d4f6ed5d07
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,58 @@
+// 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/for-var.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [gen = function* () {}, xGen = function* x() {}] = []; iterCount < 1; ) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..02e831cb1c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,51 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Destructuring initializer with a "hole" (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [x = 23] = [,]; iterCount < 1; ) {
+ assert.sameValue(x, 23);
+ // another statement
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..e722b63540
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,60 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']; iterCount < 1; ) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-throws.js
new file mode 100644
index 0000000000..954647a2c1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-throws.js
@@ -0,0 +1,49 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Destructuring initializer returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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).
+---*/
+
+assert.throws(Test262Error, function() {
+ for (var [x = (function() { throw new Test262Error(); })()] = [undefined]; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..0735d20017
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,54 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Destructuring initializer with an undefined value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [x = 23] = [undefined]; iterCount < 1; ) {
+ assert.sameValue(x, 23);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-unresolvable.js
new file mode 100644
index 0000000000..e4d31ce81e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-init-unresolvable.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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.
+---*/
+
+assert.throws(ReferenceError, function() {
+ for (var [ x = unresolvableReference ] = []; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..8295a4f98a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: SingleNameBinding when value iteration completes (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [x] = []; iterCount < 1; ) {
+ assert.sameValue(x, undefined);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..1ce24f3e06
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,53 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [_, x] = []; iterCount < 1; ) {
+ assert.sameValue(x, undefined);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-step-err.js
new file mode 100644
index 0000000000..a44a5fabc6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-step-err.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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();
+ }
+ };
+};
+
+assert.throws(Test262Error, function() {
+ for (var [x] = g; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-val-array-prototype.js
new file mode 100644
index 0000000000..2ac8c9c875
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-val-array-prototype.js
@@ -0,0 +1,74 @@
+// 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/for-var.template
+/*---
+description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [x, y, z] = [1, 2, 3]; iterCount < 1; ) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 42);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-val-err.js
new file mode 100644
index 0000000000..094dd242f4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-val-err.js
@@ -0,0 +1,69 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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;
+ }
+ };
+};
+
+assert.throws(Test262Error, function() {
+ for (var [x] = g; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..e0a769ee4c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [x, y, z] = [1, 2, 3]; iterCount < 1; ) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..dc2ab3aee9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] = []; iterCount < 1; ) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..0c8e34f38f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]; iterCount < 1; ) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..8c8e23edf5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,66 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []; iterCount < 1; ) {
+ 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;
+ });
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..5a4b153ba5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,66 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]; iterCount < 1; ) {
+ 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;
+ });
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-val-null.js
new file mode 100644
index 0000000000..216a04f957
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-val-null.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Nested object destructuring with a null value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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).
+---*/
+
+assert.throws(TypeError, function() {
+ for (var [{ x }] = [null]; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-val-undef.js
new file mode 100644
index 0000000000..2f9539ef9c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elem-obj-val-undef.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Nested object destructuring with a value of `undefined` (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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).
+---*/
+
+assert.throws(TypeError, function() {
+ for (var [{ x }] = []; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..0a2f99fa8f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,61 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Elision accepts exhausted iterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [,] = iter; iterCount < 1; ) {
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision-iter-close.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision-iter-close.js
new file mode 100644
index 0000000000..99ebd655bb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision-iter-close.js
@@ -0,0 +1,48 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elision-iter-close.case
+// - src/dstr-binding/iter-close/for-var.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+function fn() {
+ for (var [,] = iter; ; ) {
+ return;
+ }
+}
+
+fn();
+
+assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision-step-err.js
new file mode 100644
index 0000000000..34f3d448a8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision-step-err.js
@@ -0,0 +1,65 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elision-step-err.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Elision advances iterator and forwards abrupt completions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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;
+}();
+
+assert.throws(Test262Error, function() {
+ for (var [,] = iter; iterCount < 1; ) {
+ return;
+ }
+});
+
+iter.next();
+assert.sameValue(following, 0, 'Iterator was properly closed.');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision.js
new file mode 100644
index 0000000000..2a811a9707
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-elision.js
@@ -0,0 +1,70 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-elision.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Elision advances iterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [,] = g(); iterCount < 1; ) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-empty.js
new file mode 100644
index 0000000000..444d963a19
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-empty.js
@@ -0,0 +1,53 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-empty.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+for (var [] = iter; iterCount < 1; ) {
+ assert.sameValue(iterations, 0);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..6d614de849
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,77 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [...[x, y, z]] = [3, 4, 5]; iterCount < 1; ) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..881d70548b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,83 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Rest element containing an elision (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [...[,]] = g(); iterCount < 1; ) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..ca48e43467
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,66 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Rest element containing an "empty" array pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [...[]] = iter; iterCount < 1; ) {
+ assert.sameValue(iterations, 1);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..c8c9fdeb91
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Rest element containing a rest element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [...[...x]] = values; iterCount < 1; ) {
+ 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);
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-direct.js
new file mode 100644
index 0000000000..942a0ed9ee
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-direct.js
@@ -0,0 +1,57 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-direct.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Lone rest element (direct binding) (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+includes: [compareArray.js]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [...x] = [1]; iterCount < 1; ) {
+ assert(Array.isArray(x));
+ assert.compareArray(x, [1]);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-elision-next-err.js
new file mode 100644
index 0000000000..c3fa1a7240
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-elision-next-err.js
@@ -0,0 +1,51 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Rest element following elision elements (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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(); })();
+
+assert.throws(Test262Error, function() {
+ for (var [, ...x] = iter; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..7bedba63d7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Rest element following elision elements (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [ , , ...x] = values; iterCount < 1; ) {
+ 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);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..8581df1c5a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,54 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: RestElement applied to an exhausted iterator (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [, , ...x] = [1, 2]; iterCount < 1; ) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-iter-close.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-iter-close.js
new file mode 100644
index 0000000000..58e80c4044
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-iter-close.js
@@ -0,0 +1,48 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-iter-close.case
+// - src/dstr-binding/iter-close/for-var.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+function fn() {
+ for (var [...x] = iter; ; ) {
+ return;
+ }
+}
+
+fn();
+
+assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-iter-step-err.js
new file mode 100644
index 0000000000..be83886322
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-iter-step-err.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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;
+}();
+
+assert.throws(Test262Error, function() {
+ for (var [...x] = iter; iterCount < 1; ) {
+ return;
+ }
+});
+
+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/for/dstr/var-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-iter-val-err.js
new file mode 100644
index 0000000000..602a318e7a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id-iter-val-err.js
@@ -0,0 +1,64 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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;
+ }
+ };
+};
+
+assert.throws(Test262Error, function() {
+ for (var [...x] = iter; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..eeb55e48b4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-id.js
@@ -0,0 +1,55 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-id.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Lone rest element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [...x] = values; iterCount < 1; ) {
+ 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);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..6926feb507
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,51 @@
+// |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/for-var.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (var [...[ x ] = []] = []; iterCount < 1; ) {
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..1ad10c2b12
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-init-id.js
@@ -0,0 +1,51 @@
+// |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/for-var.template
+/*---
+description: Rest element (identifier) does not support initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (var [...x = []] = []; iterCount < 1; ) {
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..dcf432fd60
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,51 @@
+// |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/for-var.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (var [...{ x } = []] = []; iterCount < 1; ) {
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..5f394ad50c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,51 @@
+// |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/for-var.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (var [...[x], y] = [1, 2, 3]; iterCount < 1; ) {
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..86435acbf7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,51 @@
+// |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/for-var.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (var [...x, y] = [1, 2, 3]; iterCount < 1; ) {
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..618185a34a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,51 @@
+// |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/for-var.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+for (var [...{ x }, y] = [1, 2, 3]; iterCount < 1; ) {
+
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..8045fb2d8f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,55 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Rest element containing an object binding pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [...{ length }] = [1, 2, 3]; iterCount < 1; ) {
+ assert.sameValue(length, 3);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..f73b4052f2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,62 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Rest element containing an object binding pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var [...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]; iterCount < 1; ) {
+ 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");
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-init-null.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-init-null.js
new file mode 100644
index 0000000000..0525eb1192
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-init-null.js
@@ -0,0 +1,45 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-init-null.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (null) (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+assert.throws(TypeError, function() {
+ for (var {} = null; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-init-undefined.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-init-undefined.js
new file mode 100644
index 0000000000..6bdd7b18d9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-init-undefined.js
@@ -0,0 +1,45 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-init-undefined.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (undefined) (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+assert.throws(TypeError, function() {
+ for (var {} = undefined; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-empty.js
new file mode 100644
index 0000000000..de5dd79e18
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-empty.js
@@ -0,0 +1,54 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-empty.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+
+for (var {} = obj; iterCount < 1; ) {
+ assert.sameValue(accessCount, 0);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-get-value-err.js
new file mode 100644
index 0000000000..3db67066c7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-get-value-err.js
@@ -0,0 +1,52 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-get-value-err.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ for (var { poisoned } = poisonedProperty; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..8d63ad21ba
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,55 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var { arrow = () => {} } = {}; iterCount < 1; ) {
+ assert.sameValue(arrow.name, 'arrow');
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..75598dad43
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,57 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}; iterCount < 1; ) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..eb56cfa0d7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var { cover = (function () {}), xCover = (0, function() {}) } = {}; iterCount < 1; ) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..40f1d9ce0f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var { fn = function () {}, xFn = function x() {} } = {}; iterCount < 1; ) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..68de800a76
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,57 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var { gen = function* () {}, xGen = function* x() {} } = {}; iterCount < 1; ) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..d03ad26240
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,59 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var { w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }; iterCount < 1; ) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-throws.js
new file mode 100644
index 0000000000..660bfe92d0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-throws.js
@@ -0,0 +1,52 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-throws.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Error thrown when evaluating the initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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();
+}
+
+assert.throws(Test262Error, function() {
+ for (var { x = thrower() } = {}; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-unresolvable.js
new file mode 100644
index 0000000000..e3527c794d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-init-unresolvable.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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.
+---*/
+
+assert.throws(ReferenceError, function() {
+ for (var { x = unresolvableReference } = {}; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..d3cb7fa306
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,49 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+for (var { x, } = { x: 23 }; iterCount < 1; ) {
+ assert.sameValue(x, 23);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-list-err.js
new file mode 100644
index 0000000000..09dc7e4dfc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-list-err.js
@@ -0,0 +1,53 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-list-err.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Binding property list evaluation is interrupted by an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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();
+}
+
+assert.throws(Test262Error, function() {
+ for (var { a, b = thrower(), c = ++initCount } = {}; iterCount < 1; ) {
+ return;
+ }
+});
+
+assert.sameValue(initCount, 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..ad154a1618
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var { w: [x, y, z] = [4, 5, 6] } = {}; iterCount < 1; ) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..525a68a8a7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,49 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+for (var { x: [y], } = { x: [45] }; iterCount < 1; ) {
+ assert.sameValue(y,45);
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary-value-null.js
new file mode 100644
index 0000000000..fbff3585f6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary-value-null.js
@@ -0,0 +1,47 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Object binding pattern with "nested" array binding pattern taking the `null` value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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.
+---*/
+
+assert.throws(TypeError, function() {
+ for (var { w: [x, y, z] = [4, 5, 6] } = { w: null }; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..3c4262b248
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-ary.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-ary.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var { w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }; iterCount < 1; ) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-eval-err.js
new file mode 100644
index 0000000000..12c7faab71
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-eval-err.js
@@ -0,0 +1,49 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-eval-err.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Evaluation of property name returns an abrupt completion (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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();
+}
+
+assert.throws(Test262Error, function() {
+ for (var { [thrower()]: x } = {}; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-get-value-err.js
new file mode 100644
index 0000000000..c6e9060bac
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-get-value-err.js
@@ -0,0 +1,54 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ for (var { poisoned: x = ++initEvalCount } = poisonedProperty; iterCount < 1; ) {
+ return;
+ }
+});
+
+assert.sameValue(initEvalCount, 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..596f91b9ac
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,71 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }; iterCount < 1; ) {
+ 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;
+ });
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init-throws.js
new file mode 100644
index 0000000000..54c7598640
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init-throws.js
@@ -0,0 +1,52 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Error thrown when evaluating the initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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();
+}
+
+assert.throws(Test262Error, function() {
+ for (var { x: y = thrower() } = {}; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init-unresolvable.js
new file mode 100644
index 0000000000..ef159092f7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init-unresolvable.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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.
+---*/
+
+assert.throws(ReferenceError, function() {
+ for (var { x: y = unresolvableReference } = {}; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..d385a4da51
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-init.js
@@ -0,0 +1,52 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-init.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializeropt
+
+ [...]
+ 8. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+for (var { x: y = 33 } = { }; iterCount < 1; ) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..ec712d14ef
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,53 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+for (var { x: y, } = { x: 23 }; iterCount < 1; ) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..54e457a1d0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-id.js
@@ -0,0 +1,52 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-id.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Binding as specified via property name and identifier (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializeropt
+
+ [...]
+ 8. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+for (var { x: y } = { x: 23 }; iterCount < 1; ) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..ecd9bcfe9c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }; iterCount < 1; ) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj-value-null.js
new file mode 100644
index 0000000000..35b6b5a780
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj-value-null.js
@@ -0,0 +1,47 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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.
+---*/
+
+assert.throws(TypeError, function() {
+ for (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj-value-undef.js
new file mode 100644
index 0000000000..e7c991650d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj-value-undef.js
@@ -0,0 +1,47 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case
+// - src/dstr-binding/error/for-var.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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.
+---*/
+
+assert.throws(TypeError, function() {
+ for (var { w: { x, y, z } = undefined } = { }; iterCount < 1; ) {
+ return;
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..d08728ab0f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-prop-obj.js
@@ -0,0 +1,56 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-prop-obj.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [destructuring-binding]
+flags: [generated]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined 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 iterCount = 0;
+
+for (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }; iterCount < 1; ) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..7deeeb3097
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-rest-getter.js
@@ -0,0 +1,51 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-rest-getter.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding]
+flags: [generated]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+---*/
+var count = 0;
+
+var iterCount = 0;
+
+for (var {...x} = { get v() { count++; return 2; } }; iterCount < 1; ) {
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..b20ee225cc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,59 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding]
+flags: [generated]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+
+for (var {...rest} = o; iterCount < 1; ) {
+ 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
+ });
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..ff4410b29a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/dstr/var-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,58 @@
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding/default/for-var.template
+/*---
+description: Rest object contains just unextracted data (for statement)
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding]
+flags: [generated]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
+
+ 1. Let varDcl be the result of evaluating VariableDeclarationList.
+ [...]
+
+ 13.3.2.4 Runtime Semantics: Evaluation
+
+ VariableDeclarationList : VariableDeclarationList , VariableDeclaration
+
+ 1. Let next be the result of evaluating VariableDeclarationList.
+ 2. ReturnIfAbrupt(next).
+ 3. Return the result of evaluating VariableDeclaration.
+
+ VariableDeclaration : BindingPattern Initializer
+
+ 1. Let rhs be the result of evaluating Initializer.
+ 2. Let rval be GetValue(rhs).
+ 3. ReturnIfAbrupt(rval).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing rval and undefined as arguments.
+---*/
+
+var iterCount = 0;
+
+for (var {a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}; iterCount < 1; ) {
+ 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
+ });
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/head-const-bound-names-in-stmt.js b/js/src/tests/test262/language/statements/for/head-const-bound-names-in-stmt.js
new file mode 100644
index 0000000000..46206a83aa
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/head-const-bound-names-in-stmt.js
@@ -0,0 +1,23 @@
+// |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.
+/*---
+description: The body may not re-declare variables declared in the head
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ It is a Syntax Error if any element of the BoundNames of LexicalDeclaration
+ also occurs in the VarDeclaredNames of Statement.
+negative:
+ phase: parse
+ type: SyntaxError
+esid: sec-for-statement
+es6id: 13.7.4
+---*/
+
+$DONOTEVALUATE();
+
+for (const x = 0; false; ) {
+ var x;
+}
diff --git a/js/src/tests/test262/language/statements/for/head-const-fresh-binding-per-iteration.js b/js/src/tests/test262/language/statements/for/head-const-fresh-binding-per-iteration.js
new file mode 100644
index 0000000000..9d19cb4276
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/head-const-fresh-binding-per-iteration.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2011 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.6.4.13
+description: >
+ const ForDeclaration: creates a fresh binding per iteration
+---*/
+
+let z = 1;
+let s = 0;
+for (const x = 1; z < 2; z++) {
+ s += x + z;
+}
+assert.sameValue(s, 2, "The value of `s` is `2`");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/head-init-async-of.js b/js/src/tests/test262/language/statements/for/head-init-async-of.js
new file mode 100644
index 0000000000..4464d20396
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/head-init-async-of.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2021 Kevin Gibbons. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: for statement beginning with `async of`
+info: |
+ `for (async of =>` is the begining of a regular for loop, rather than a for-of
+esid: sec-for-statement
+---*/
+
+var i = 0;
+var counter = 0;
+for (async of => {}; i < 10; ++i) {
+ ++counter;
+}
+assert.sameValue(counter, 10);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/head-init-expr-check-empty-inc-empty-completion.js b/js/src/tests/test262/language/statements/for/head-init-expr-check-empty-inc-empty-completion.js
new file mode 100644
index 0000000000..88cc217c12
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/head-init-expr-check-empty-inc-empty-completion.js
@@ -0,0 +1,19 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ The result of evaluating "for( ExpNoIn;Exp;Exp)" loop is returning
+ (normal, evalValue, empty)
+es5id: 12.6.3_A9.1
+description: Using eval
+---*/
+
+var supreme, count;
+supreme=5;
+
+var __evaluated = eval("for(count=0;;) {if (count===supreme)break;else count++; }");
+
+assert.sameValue(__evaluated, void 0, '#1: __evaluated === 4. Actual: __evaluated ==='+ __evaluated);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/head-init-expr-check-empty-inc-empty-syntax.js b/js/src/tests/test262/language/statements/for/head-init-expr-check-empty-inc-empty-syntax.js
new file mode 100644
index 0000000000..6297aaab7f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/head-init-expr-check-empty-inc-empty-syntax.js
@@ -0,0 +1,15 @@
+// Copyright 2019 Mike Pennisi. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: For head may omit optional expressions
+es5id: 12.6.3_A9.1
+---*/
+
+
+var supreme = 5
+var count;
+
+for(count=0;;) {if (count===supreme)break;else count++; }
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/head-init-var-check-empty-inc-empty-completion.js b/js/src/tests/test262/language/statements/for/head-init-var-check-empty-inc-empty-completion.js
new file mode 100644
index 0000000000..113b250cb6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/head-init-var-check-empty-inc-empty-completion.js
@@ -0,0 +1,18 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ The result of evaluating "for(var ExpNoIn;Exp;Exp)" loop is returning
+ (normal, evalValue, empty)
+es5id: 12.6.3_A9
+description: Using eval
+---*/
+
+var supreme=5;
+
+var __evaluated = eval("for(var count=0;;) {if (count===supreme)break;else count++; }");
+
+assert.sameValue(__evaluated, void 0, '#1: __evaluated === 4. Actual: __evaluated ==='+ __evaluated );
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/head-init-var-check-empty-inc-empty-syntax.js b/js/src/tests/test262/language/statements/for/head-init-var-check-empty-inc-empty-syntax.js
new file mode 100644
index 0000000000..6206cbe01a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/head-init-var-check-empty-inc-empty-syntax.js
@@ -0,0 +1,13 @@
+// Copyright 2019 Mike Pennisi. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: For head may omit optional expressions
+es5id: 12.6.3_A9
+---*/
+
+var supreme=5;
+
+for(var count=0;;) {if (count===supreme)break;else count++; }
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/head-let-bound-names-in-stmt.js b/js/src/tests/test262/language/statements/for/head-let-bound-names-in-stmt.js
new file mode 100644
index 0000000000..c4a38cf2ae
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/head-let-bound-names-in-stmt.js
@@ -0,0 +1,23 @@
+// |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.
+/*---
+description: The body may not re-declare variables declared in the head
+info: |
+ IterationStatement :
+ for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
+
+ It is a Syntax Error if any element of the BoundNames of LexicalDeclaration
+ also occurs in the VarDeclaredNames of Statement.
+negative:
+ phase: parse
+ type: SyntaxError
+esid: sec-for-statement
+es6id: 13.7.4
+---*/
+
+$DONOTEVALUATE();
+
+for (let x; false; ) {
+ var x;
+}
diff --git a/js/src/tests/test262/language/statements/for/head-let-destructuring.js b/js/src/tests/test262/language/statements/for/head-let-destructuring.js
new file mode 100644
index 0000000000..8577f67b48
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/head-let-destructuring.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-iteration-statements
+es6id: 13.7
+description: >
+ The token sequence `let [`is interpreted as the beginning of a destructuring
+ binding pattern
+info: |
+ Syntax
+
+ IterationStatement[Yield, Return]:
+
+ for ( [lookahead ∉ { let [ } ] Expression[~In, ?Yield]opt ;
+ Expression[+In, ?Yield]opt ; Expression[+In, ?Yield]opt )
+ Statement[?Yield, ?Return]
+
+ for ( LexicalDeclaration[~In, ?Yield] Expression[+In, ?Yield]opt ;
+ Expression[+In, ?Yield]opt) Statement[?Yield, ?Return]
+---*/
+
+var value;
+
+for ( let[x] = [23]; ; ) {
+ value = x;
+ break;
+}
+
+assert.sameValue(typeof x, 'undefined', 'binding is block-scoped');
+assert.sameValue(value, 23);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/head-let-fresh-binding-per-iteration.js b/js/src/tests/test262/language/statements/for/head-let-fresh-binding-per-iteration.js
new file mode 100644
index 0000000000..a054b20759
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/head-let-fresh-binding-per-iteration.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2011 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.6.4.13
+description: >
+ let ForDeclaration: creates a fresh binding per iteration
+---*/
+
+let z = 1;
+let s = 0;
+for (let x = 1; z < 2; z++) {
+ s += x + z;
+}
+assert.sameValue(s, 2, "The value of `s` is `2`");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/head-lhs-let.js b/js/src/tests/test262/language/statements/for/head-lhs-let.js
new file mode 100644
index 0000000000..0a094d2954
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/head-lhs-let.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-iteration-statements
+es6id: 13.7
+description: >
+ The `let` token is interpreted as an Identifier when it is not followed by a
+ `[` token
+info: |
+ Syntax
+
+ IterationStatement[Yield, Return]:
+
+ for ( [lookahead ∉ { let [ } ] Expression[~In, ?Yield]opt ;
+ Expression[+In, ?Yield]opt ; Expression[+In, ?Yield]opt )
+ Statement[?Yield, ?Return]
+
+ for ( LexicalDeclaration[~In, ?Yield] Expression[+In, ?Yield]opt ;
+ Expression[+In, ?Yield]opt) Statement[?Yield, ?Return]
+flags: [noStrict]
+---*/
+
+var let;
+
+let = 1;
+for ( let; ; )
+ break;
+
+assert.sameValue(let, 1, 'IdentifierReference');
+
+let = 2;
+for ( let = 3; ; )
+ break;
+
+assert.sameValue(let, 3, 'AssignmentExpression');
+
+let = 4;
+for ( [let][0]; ; )
+ break;
+
+assert.sameValue(let, 4, 'MemberExpression');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/head-var-bound-names-in-stmt.js b/js/src/tests/test262/language/statements/for/head-var-bound-names-in-stmt.js
new file mode 100644
index 0000000000..0e0d248104
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/head-var-bound-names-in-stmt.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: The body may re-declare variables declared in the head
+esid: sec-for-statement
+es6id: 13.7.4
+---*/
+
+var iterCount = 0;
+var first = true;
+
+for (var x; first; first = false) {
+ var x;
+ iterCount += 1;
+}
+
+assert.sameValue(iterCount, 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/labelled-fn-stmt-const.js b/js/src/tests/test262/language/statements/for/labelled-fn-stmt-const.js
new file mode 100644
index 0000000000..a15f95fcce
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/labelled-fn-stmt-const.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.
+/*---
+description: It is a Syntax Error if IsLabelledFunction(Statement) is true.
+negative:
+ phase: parse
+ type: SyntaxError
+esid: sec-semantics-static-semantics-early-errors
+es6id: 13.7.1.1
+info: |
+ Although Annex B describes an extension which permits labelled function
+ declarations outside of strict mode, this early error is applied regardless
+ of the language mode.
+---*/
+
+$DONOTEVALUATE();
+
+for (const x = 0; false; ) label1: label2: function f() {}
diff --git a/js/src/tests/test262/language/statements/for/labelled-fn-stmt-expr.js b/js/src/tests/test262/language/statements/for/labelled-fn-stmt-expr.js
new file mode 100644
index 0000000000..68e75328d0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/labelled-fn-stmt-expr.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.
+/*---
+description: It is a Syntax Error if IsLabelledFunction(Statement) is true.
+negative:
+ phase: parse
+ type: SyntaxError
+esid: sec-semantics-static-semantics-early-errors
+es6id: 13.7.1.1
+info: |
+ Although Annex B describes an extension which permits labelled function
+ declarations outside of strict mode, this early error is applied regardless
+ of the language mode.
+---*/
+
+$DONOTEVALUATE();
+
+for ( ; false; ) label1: label2: function f() {}
diff --git a/js/src/tests/test262/language/statements/for/labelled-fn-stmt-let.js b/js/src/tests/test262/language/statements/for/labelled-fn-stmt-let.js
new file mode 100644
index 0000000000..377fd4c419
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/labelled-fn-stmt-let.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.
+/*---
+description: It is a Syntax Error if IsLabelledFunction(Statement) is true.
+negative:
+ phase: parse
+ type: SyntaxError
+esid: sec-semantics-static-semantics-early-errors
+es6id: 13.7.1.1
+info: |
+ Although Annex B describes an extension which permits labelled function
+ declarations outside of strict mode, this early error is applied regardless
+ of the language mode.
+---*/
+
+$DONOTEVALUATE();
+
+for (let x; false; ) label1: label2: function f() {}
diff --git a/js/src/tests/test262/language/statements/for/labelled-fn-stmt-var.js b/js/src/tests/test262/language/statements/for/labelled-fn-stmt-var.js
new file mode 100644
index 0000000000..84735d443f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/labelled-fn-stmt-var.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.
+/*---
+description: It is a Syntax Error if IsLabelledFunction(Statement) is true.
+negative:
+ phase: parse
+ type: SyntaxError
+esid: sec-semantics-static-semantics-early-errors
+es6id: 13.7.1.1
+info: |
+ Although Annex B describes an extension which permits labelled function
+ declarations outside of strict mode, this early error is applied regardless
+ of the language mode.
+---*/
+
+$DONOTEVALUATE();
+
+for (var x; false; ) label1: label2: function f() {}
diff --git a/js/src/tests/test262/language/statements/for/let-array-with-newline.js b/js/src/tests/test262/language/statements/for/let-array-with-newline.js
new file mode 100644
index 0000000000..f9834339a1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/let-array-with-newline.js
@@ -0,0 +1,22 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-for-statement
+description: >
+ ExpressionStatement has a lookahead restriction for `let [`.
+info: |
+ ExpressionStatement[Yield, Await] :
+ [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
+ Expression[+In, ?Yield, ?Await] ;
+negative:
+ phase: parse
+ type: SyntaxError
+flags: [noStrict]
+---*/
+
+$DONOTEVALUATE();
+
+for (; false; ) let
+[a] = 0;
diff --git a/js/src/tests/test262/language/statements/for/let-block-with-newline.js b/js/src/tests/test262/language/statements/for/let-block-with-newline.js
new file mode 100644
index 0000000000..9749a6a5bd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/let-block-with-newline.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-for-statement
+description: >
+ ExpressionStatement doesn't have a lookahead restriction for `let {`.
+info: |
+ ExpressionStatement[Yield, Await] :
+ [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
+ Expression[+In, ?Yield, ?Await] ;
+flags: [noStrict]
+---*/
+
+for (; false; ) let // ASI
+{}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/let-identifier-with-newline.js b/js/src/tests/test262/language/statements/for/let-identifier-with-newline.js
new file mode 100644
index 0000000000..1b6f5ecb88
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/let-identifier-with-newline.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-for-statement
+description: >
+ ExpressionStatement doesn't have a lookahead restriction for `let <binding-identifier>`.
+info: |
+ ExpressionStatement[Yield, Await] :
+ [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
+ Expression[+In, ?Yield, ?Await] ;
+flags: [noStrict]
+---*/
+
+for (; false; ) let // ASI
+x = 1;
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/scope-body-lex-boundary.js b/js/src/tests/test262/language/statements/for/scope-body-lex-boundary.js
new file mode 100644
index 0000000000..6b777f1838
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/scope-body-lex-boundary.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+description: >
+ Creation of new lexical environment for each evaluation of the statement
+ body
+info: |
+ [...]
+ 11. Let bodyResult be ForBodyEvaluation(the first Expression, the second
+ Expression, Statement, perIterationLets, labelSet).
+ [...]
+
+ 13.7.4.8 Runtime Semantics: ForBodyEvaluation
+
+ [...]
+ 3. Repeat
+ [...]
+ b. Let result be the result of evaluating stmt.
+ [...]
+ e. Perform ? CreatePerIterationEnvironment(perIterationBindings).
+ [...]
+
+ 13.7.4.9 Runtime Semantics: CreatePerIterationEnvironment
+
+ 1. If perIterationBindings has any elements, then
+ [...]
+ e. Let thisIterationEnv be NewDeclarativeEnvironment(outer).
+ f. Let thisIterationEnvRec be thisIterationEnv's EnvironmentRecord.
+features: [let]
+---*/
+
+var probeFirst;
+var probeSecond = null;
+
+for (let x = 'first'; probeSecond === null; x = 'second')
+ if (!probeFirst)
+ probeFirst = function() { return x; };
+ else
+ probeSecond = function() { return x; };
+
+assert.sameValue(probeFirst(), 'first');
+assert.sameValue(probeSecond(), 'second');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/scope-body-lex-open.js b/js/src/tests/test262/language/statements/for/scope-body-lex-open.js
new file mode 100644
index 0000000000..6a06fa30de
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/scope-body-lex-open.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+description: >
+ Creation of new lexical environment for the initial evaluation of the
+ statement body
+info: |
+ [...]
+ 11. Let bodyResult be ForBodyEvaluation(the first Expression, the second
+ Expression, Statement, perIterationLets, labelSet).
+ [...]
+
+ 13.7.4.8 Runtime Semantics: ForBodyEvaluation
+
+ [...]
+ 2. Perform ? CreatePerIterationEnvironment(perIterationBindings).
+ 3. Repeat
+ [...]
+ b. Let result be the result of evaluating stmt.
+ [...]
+ [...]
+
+ 13.7.4.9 Runtime Semantics: CreatePerIterationEnvironment
+
+ 1. If perIterationBindings has any elements, then
+ [...]
+ e. Let thisIterationEnv be NewDeclarativeEnvironment(outer).
+ f. Let thisIterationEnvRec be thisIterationEnv's EnvironmentRecord.
+features: [let]
+---*/
+
+var probeBefore, probeTest, probeIncr, probeBody;
+var run = true;
+
+for (
+ let x = 'outside', _ = probeBefore = function() { return x; };
+ run && (x = 'inside', probeTest = function() { return x; });
+ probeIncr = function() { return x; }
+ )
+ probeBody = function() { return x; }, run = false;
+
+assert.sameValue(probeBefore(), 'outside');
+assert.sameValue(probeTest(), 'inside', 'reference from "test" position');
+assert.sameValue(probeBody(), 'inside', 'reference from statement body');
+assert.sameValue(probeIncr(), 'inside', 'reference from "increment" position');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/scope-body-var-none.js b/js/src/tests/test262/language/statements/for/scope-body-var-none.js
new file mode 100644
index 0000000000..c4074db7da
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/scope-body-var-none.js
@@ -0,0 +1,113 @@
+// 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-for-statement-runtime-semantics-labelledevaluation
+description: >
+ No variable environment is created for each evaluation of the statement
+ body
+info: |
+ [...]
+ 11. Let bodyResult be ForBodyEvaluation(the first Expression, the second
+ Expression, Statement, perIterationLets, labelSet).
+ [...]
+
+ 13.7.4.8 Runtime Semantics: ForBodyEvaluation
+
+ [...]
+ 2. Perform ? CreatePerIterationEnvironment(perIterationBindings).
+ 3. Repeat
+ [...]
+ b. Let result be the result of evaluating stmt.
+ [...]
+ e. Perform ? CreatePerIterationEnvironment(perIterationBindings).
+ [...]
+
+ 13.7.4.9 Runtime Semantics: CreatePerIterationEnvironment
+
+ 1. If perIterationBindings has any elements, then
+ [...]
+ e. Let thisIterationEnv be NewDeclarativeEnvironment(outer).
+ f. Let thisIterationEnvRec be thisIterationEnv's EnvironmentRecord.
+flags: [noStrict]
+---*/
+
+var probeBefore = function() { return [x, y, z]; };
+var probeTest, probeIncr, probeBody;
+var run = true;
+
+for (
+ ;
+ run && (eval('var x = 1;'), probeTest = function() { return [x, y, z]; });
+ eval('var y = 1;'), probeIncr = function() { return [x, y, z]; }
+ )
+ var z = 1, _ = (probeBody = function() { return [x, y, z]; }), run = false;
+
+var x = 2;
+var y = 2;
+var z = 2;
+
+assert.sameValue(
+ probeBefore()[0],
+ 2,
+ 'reference preceding statement (redeclared in "test" position)'
+);
+assert.sameValue(
+ probeBefore()[1],
+ 2,
+ 'reference preceding statement (redeclared in statement body)'
+);
+assert.sameValue(
+ probeBefore()[2],
+ 2,
+ 'reference preceding statement (redeclared in "increment" position)'
+);
+
+assert.sameValue(
+ probeTest()[0],
+ 2,
+ 'reference from "test" position (redeclared in "test" position)'
+);
+assert.sameValue(
+ probeTest()[1],
+ 2,
+ 'reference from "test" position (redeclared in statement body)'
+);
+assert.sameValue(
+ probeTest()[2],
+ 2,
+ 'reference from "test" position (redeclared in "increment" position)'
+);
+
+assert.sameValue(
+ probeBody()[0],
+ 2,
+ 'reference from statement body (redeclared in "test" position)'
+);
+assert.sameValue(
+ probeBody()[1],
+ 2,
+ 'reference from statement body (redeclared in statement body)'
+);
+assert.sameValue(
+ probeBody()[2],
+ 2,
+ 'reference from statement body (redeclared in "increment" position)'
+);
+
+assert.sameValue(
+ probeIncr()[0],
+ 2,
+ 'reference from "increment" position (redeclared in "test" position)'
+);
+assert.sameValue(
+ probeIncr()[1],
+ 2,
+ 'reference from "increment" position (redeclared in statement body)'
+);
+assert.sameValue(
+ probeIncr()[2],
+ 2,
+ 'reference from "increment" position (redeclared in "increment" position)'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/scope-head-lex-close.js b/js/src/tests/test262/language/statements/for/scope-head-lex-close.js
new file mode 100644
index 0000000000..a8f35a18e7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/scope-head-lex-close.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+description: Removal of lexical environment for the statement "head"
+info: |
+ [...]
+ 2. Let loopEnv be NewDeclarativeEnvironment(oldEnv).
+ 3. Let loopEnvRec be loopEnv's EnvironmentRecord.
+ 4. Let isConst be the result of performing IsConstantDeclaration of
+ LexicalDeclaration.
+ 5. Let boundNames be the BoundNames of LexicalDeclaration.
+ 6. For each element dn of boundNames do
+ a. If isConst is true, then
+ i. Perform ! loopEnvRec.CreateImmutableBinding(dn, true).
+ b. Else,
+ i. Perform ! loopEnvRec.CreateMutableBinding(dn, false).
+ 7. Set the running execution context's LexicalEnvironment to loopEnv.
+ [...]
+ 12. Set the running execution context's LexicalEnvironment to oldEnv.
+ 13. Return Completion(bodyResult).
+features: [let]
+---*/
+
+let x = 'outside';
+var run = true;
+var probeTest, probeIncr, probeBody;
+
+for (
+ let x = 'inside';
+ (probeTest = function() { return x; }) && run;
+ probeIncr = function() { return x; }
+ )
+ probeBody = function() { return x; }, run = false;
+
+assert.sameValue(probeBody(), 'inside', 'reference from statement body');
+assert.sameValue(probeIncr(), 'inside', 'reference from "increment" position');
+assert.sameValue(probeTest(), 'inside', 'reference from "test" position');
+assert.sameValue(x, 'outside');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/scope-head-lex-open.js b/js/src/tests/test262/language/statements/for/scope-head-lex-open.js
new file mode 100644
index 0000000000..5d60618fa3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/scope-head-lex-open.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+description: Creation of new lexical environment for the statement "head"
+info: |
+ [...]
+ 2. Let loopEnv be NewDeclarativeEnvironment(oldEnv).
+ 3. Let loopEnvRec be loopEnv's EnvironmentRecord.
+ 4. Let isConst be the result of performing IsConstantDeclaration of
+ LexicalDeclaration.
+ 5. Let boundNames be the BoundNames of LexicalDeclaration.
+ 6. For each element dn of boundNames do
+ a. If isConst is true, then
+ i. Perform ! loopEnvRec.CreateImmutableBinding(dn, true).
+ b. Else,
+ i. Perform ! loopEnvRec.CreateMutableBinding(dn, false).
+ 7. Set the running execution context's LexicalEnvironment to loopEnv.
+ [...]
+features: [let]
+---*/
+
+let x = 'outside';
+var probeBefore = function() { return x; };
+var probeDecl, probeTest, probeIncr, probeBody;
+var run = true;
+
+for (
+ let x = 'inside', _ = probeDecl = function() { return x; };
+ run && (probeTest = function() { return x; });
+ probeIncr = function() { return x; }
+ )
+ probeBody = function() { return x; }, run = false;
+
+assert.sameValue(probeBefore(), 'outside');
+assert.sameValue(probeDecl(), 'inside', 'reference from LexicalDeclaration');
+assert.sameValue(probeTest(), 'inside', 'reference from "test" position');
+assert.sameValue(probeBody(), 'inside', 'reference from statement body');
+assert.sameValue(probeIncr(), 'inside', 'reference from "increment" position');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/scope-head-var-none.js b/js/src/tests/test262/language/statements/for/scope-head-var-none.js
new file mode 100644
index 0000000000..4f1dd70e21
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/scope-head-var-none.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-for-statement-runtime-semantics-labelledevaluation
+description: No variable environment is created for the statement "head"
+info: |
+ [...]
+ 2. Let loopEnv be NewDeclarativeEnvironment(oldEnv).
+ 3. Let loopEnvRec be loopEnv's EnvironmentRecord.
+ 4. Let isConst be the result of performing IsConstantDeclaration of
+ LexicalDeclaration.
+ 5. Let boundNames be the BoundNames of LexicalDeclaration.
+ 6. For each element dn of boundNames do
+ a. If isConst is true, then
+ i. Perform ! loopEnvRec.CreateImmutableBinding(dn, true).
+ b. Else,
+ i. Perform ! loopEnvRec.CreateMutableBinding(dn, false).
+ 7. Set the running execution context's LexicalEnvironment to loopEnv.
+ [...]
+ 12. Set the running execution context's LexicalEnvironment to oldEnv.
+ 13. Return Completion(bodyResult).
+flags: [noStrict]
+---*/
+
+var probeBefore = function() { return x; };
+var probeTest, probeIncr, probeBody;
+var run = true;
+
+for (
+ var _ = eval('var x = 1;');
+ run && (probeTest = function() { return x; });
+ probeIncr = function() { return x; }
+ )
+ probeBody = function() { return x; }, run = false;
+
+var x = 2;
+
+assert.sameValue(probeBefore(), 2, 'reference preceding statement');
+assert.sameValue(probeTest(), 2, 'reference from "test" position');
+assert.sameValue(probeBody(), 2, 'reference from statement body');
+assert.sameValue(probeIncr(), 2, 'reference from "increment" position');
+assert.sameValue(x, 2, 'reference following statement');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/shell.js b/js/src/tests/test262/language/statements/for/shell.js
new file mode 100644
index 0000000000..43295587f4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/shell.js
@@ -0,0 +1,16 @@
+// GENERATED, DO NOT EDIT
+// file: tcoHelper.js
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ This defines the number of consecutive recursive function calls that must be
+ made in order to prove that stack frames are properly destroyed according to
+ ES2015 tail call optimization semantics.
+defines: [$MAX_ITERATIONS]
+---*/
+
+
+
+
+var $MAX_ITERATIONS = 100000;
diff --git a/js/src/tests/test262/language/statements/for/tco-const-body-strict.js b/js/src/tests/test262/language/statements/for/tco-const-body-strict.js
new file mode 100644
index 0000000000..4600b98293
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/tco-const-body-strict.js
@@ -0,0 +1,25 @@
+// |reftest| skip -- tail-call-optimization is not supported
+'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.
+/*---
+description: Statement within statement is a candidate for tail-call optimization.
+esid: sec-static-semantics-hascallintailposition
+flags: [onlyStrict]
+features: [tail-call-optimization]
+includes: [tcoHelper.js]
+---*/
+
+var callCount = 0;
+(function f(n) {
+ if (n === 0) {
+ callCount += 1
+ return;
+ }
+ for (const x = 0; ;) {
+ return f(n - 1);
+ }
+}($MAX_ITERATIONS));
+assert.sameValue(callCount, 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/tco-let-body-strict.js b/js/src/tests/test262/language/statements/for/tco-let-body-strict.js
new file mode 100644
index 0000000000..5db4fa9c7a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/tco-let-body-strict.js
@@ -0,0 +1,25 @@
+// |reftest| skip -- tail-call-optimization is not supported
+'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.
+/*---
+description: Statement within statement is a candidate for tail-call optimization.
+esid: sec-static-semantics-hascallintailposition
+flags: [onlyStrict]
+features: [tail-call-optimization]
+includes: [tcoHelper.js]
+---*/
+
+var callCount = 0;
+(function f(n) {
+ if (n === 0) {
+ callCount += 1
+ return;
+ }
+ for (let x = 0; ;) {
+ return f(n - 1);
+ }
+}($MAX_ITERATIONS));
+assert.sameValue(callCount, 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/tco-lhs-body-strict.js b/js/src/tests/test262/language/statements/for/tco-lhs-body-strict.js
new file mode 100644
index 0000000000..5254f7a3de
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/tco-lhs-body-strict.js
@@ -0,0 +1,26 @@
+// |reftest| skip -- tail-call-optimization is not supported
+'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.
+/*---
+description: Statement within statement is a candidate for tail-call optimization.
+esid: sec-static-semantics-hascallintailposition
+flags: [onlyStrict]
+features: [tail-call-optimization]
+includes: [tcoHelper.js]
+---*/
+
+var callCount = 0;
+(function f(n) {
+ if (n === 0) {
+ callCount += 1
+ return;
+ }
+ var x;
+ for (x = 0; x < 1; ++x) {
+ return f(n - 1);
+ }
+}($MAX_ITERATIONS));
+assert.sameValue(callCount, 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for/tco-var-body-strict.js b/js/src/tests/test262/language/statements/for/tco-var-body-strict.js
new file mode 100644
index 0000000000..8ef5ef4679
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for/tco-var-body-strict.js
@@ -0,0 +1,25 @@
+// |reftest| skip -- tail-call-optimization is not supported
+'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.
+/*---
+description: Statement within statement is a candidate for tail-call optimization.
+esid: sec-static-semantics-hascallintailposition
+flags: [onlyStrict]
+features: [tail-call-optimization]
+includes: [tcoHelper.js]
+---*/
+
+var callCount = 0;
+(function f(n) {
+ if (n === 0) {
+ callCount += 1
+ return;
+ }
+ for (var x = 0; ;) {
+ return f(n - 1);
+ }
+}($MAX_ITERATIONS));
+assert.sameValue(callCount, 1);
+
+reportCompare(0, 0);