From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../statements/try/dstr/ary-init-iter-close.js | 52 ++++++++++++++++ .../dstr/ary-init-iter-get-err-array-prototype.js | 42 +++++++++++++ .../statements/try/dstr/ary-init-iter-get-err.js | 36 +++++++++++ .../statements/try/dstr/ary-init-iter-no-close.js | 52 ++++++++++++++++ .../statements/try/dstr/ary-name-iter-val.js | 51 ++++++++++++++++ .../try/dstr/ary-ptrn-elem-ary-elem-init.js | 43 +++++++++++++ .../try/dstr/ary-ptrn-elem-ary-elem-iter.js | 44 ++++++++++++++ .../try/dstr/ary-ptrn-elem-ary-elision-init.js | 50 ++++++++++++++++ .../try/dstr/ary-ptrn-elem-ary-elision-iter.js | 47 +++++++++++++++ .../try/dstr/ary-ptrn-elem-ary-empty-init.js | 46 ++++++++++++++ .../try/dstr/ary-ptrn-elem-ary-empty-iter.js | 43 +++++++++++++ .../try/dstr/ary-ptrn-elem-ary-rest-init.js | 47 +++++++++++++++ .../try/dstr/ary-ptrn-elem-ary-rest-iter.js | 50 ++++++++++++++++ .../try/dstr/ary-ptrn-elem-ary-val-null.js | 43 +++++++++++++ .../try/dstr/ary-ptrn-elem-id-init-exhausted.js | 42 +++++++++++++ .../dstr/ary-ptrn-elem-id-init-fn-name-arrow.js | 43 +++++++++++++ .../dstr/ary-ptrn-elem-id-init-fn-name-class.js | 45 ++++++++++++++ .../dstr/ary-ptrn-elem-id-init-fn-name-cover.js | 44 ++++++++++++++ .../try/dstr/ary-ptrn-elem-id-init-fn-name-fn.js | 44 ++++++++++++++ .../try/dstr/ary-ptrn-elem-id-init-fn-name-gen.js | 45 ++++++++++++++ .../try/dstr/ary-ptrn-elem-id-init-hole.js | 38 ++++++++++++ .../try/dstr/ary-ptrn-elem-id-init-skipped.js | 47 +++++++++++++++ .../try/dstr/ary-ptrn-elem-id-init-throws.js | 34 +++++++++++ .../try/dstr/ary-ptrn-elem-id-init-undef.js | 41 +++++++++++++ .../try/dstr/ary-ptrn-elem-id-init-unresolvable.js | 41 +++++++++++++ .../try/dstr/ary-ptrn-elem-id-iter-complete.js | 45 ++++++++++++++ .../try/dstr/ary-ptrn-elem-id-iter-done.js | 40 +++++++++++++ .../try/dstr/ary-ptrn-elem-id-iter-step-err.js | 43 +++++++++++++ .../ary-ptrn-elem-id-iter-val-array-prototype.js | 61 +++++++++++++++++++ .../try/dstr/ary-ptrn-elem-id-iter-val-err.js | 54 +++++++++++++++++ .../try/dstr/ary-ptrn-elem-id-iter-val.js | 51 ++++++++++++++++ .../try/dstr/ary-ptrn-elem-obj-id-init.js | 43 +++++++++++++ .../statements/try/dstr/ary-ptrn-elem-obj-id.js | 43 +++++++++++++ .../try/dstr/ary-ptrn-elem-obj-prop-id-init.js | 53 ++++++++++++++++ .../try/dstr/ary-ptrn-elem-obj-prop-id.js | 53 ++++++++++++++++ .../try/dstr/ary-ptrn-elem-obj-val-null.js | 43 +++++++++++++ .../try/dstr/ary-ptrn-elem-obj-val-undef.js | 43 +++++++++++++ .../try/dstr/ary-ptrn-elision-exhausted.js | 48 +++++++++++++++ .../try/dstr/ary-ptrn-elision-step-err.js | 50 ++++++++++++++++ .../statements/try/dstr/ary-ptrn-elision.js | 57 ++++++++++++++++++ .../language/statements/try/dstr/ary-ptrn-empty.js | 40 +++++++++++++ .../statements/try/dstr/ary-ptrn-rest-ary-elem.js | 64 ++++++++++++++++++++ .../try/dstr/ary-ptrn-rest-ary-elision.js | 70 ++++++++++++++++++++++ .../statements/try/dstr/ary-ptrn-rest-ary-empty.js | 53 ++++++++++++++++ .../statements/try/dstr/ary-ptrn-rest-ary-rest.js | 49 +++++++++++++++ .../statements/try/dstr/ary-ptrn-rest-id-direct.js | 44 ++++++++++++++ .../try/dstr/ary-ptrn-rest-id-elision-next-err.js | 36 +++++++++++ .../try/dstr/ary-ptrn-rest-id-elision.js | 45 ++++++++++++++ .../try/dstr/ary-ptrn-rest-id-exhausted.js | 41 +++++++++++++ .../try/dstr/ary-ptrn-rest-id-iter-step-err.js | 47 +++++++++++++++ .../try/dstr/ary-ptrn-rest-id-iter-val-err.js | 49 +++++++++++++++ .../statements/try/dstr/ary-ptrn-rest-id.js | 42 +++++++++++++ .../statements/try/dstr/ary-ptrn-rest-init-ary.js | 38 ++++++++++++ .../statements/try/dstr/ary-ptrn-rest-init-id.js | 38 ++++++++++++ .../statements/try/dstr/ary-ptrn-rest-init-obj.js | 38 ++++++++++++ .../try/dstr/ary-ptrn-rest-not-final-ary.js | 38 ++++++++++++ .../try/dstr/ary-ptrn-rest-not-final-id.js | 38 ++++++++++++ .../try/dstr/ary-ptrn-rest-not-final-obj.js | 38 ++++++++++++ .../statements/try/dstr/ary-ptrn-rest-obj-id.js | 42 +++++++++++++ .../try/dstr/ary-ptrn-rest-obj-prop-id.js | 49 +++++++++++++++ .../language/statements/try/dstr/browser.js | 0 .../language/statements/try/dstr/obj-init-null.js | 30 ++++++++++ .../statements/try/dstr/obj-init-undefined.js | 30 ++++++++++ .../language/statements/try/dstr/obj-ptrn-empty.js | 41 +++++++++++++ .../try/dstr/obj-ptrn-id-get-value-err.js | 37 ++++++++++++ .../try/dstr/obj-ptrn-id-init-fn-name-arrow.js | 42 +++++++++++++ .../try/dstr/obj-ptrn-id-init-fn-name-class.js | 44 ++++++++++++++ .../try/dstr/obj-ptrn-id-init-fn-name-cover.js | 43 +++++++++++++ .../try/dstr/obj-ptrn-id-init-fn-name-fn.js | 43 +++++++++++++ .../try/dstr/obj-ptrn-id-init-fn-name-gen.js | 44 ++++++++++++++ .../try/dstr/obj-ptrn-id-init-skipped.js | 46 ++++++++++++++ .../statements/try/dstr/obj-ptrn-id-init-throws.js | 37 ++++++++++++ .../try/dstr/obj-ptrn-id-init-unresolvable.js | 41 +++++++++++++ .../try/dstr/obj-ptrn-id-trailing-comma.js | 36 +++++++++++ .../statements/try/dstr/obj-ptrn-list-err.js | 38 ++++++++++++ .../statements/try/dstr/obj-ptrn-prop-ary-init.js | 45 ++++++++++++++ .../try/dstr/obj-ptrn-prop-ary-trailing-comma.js | 36 +++++++++++ .../try/dstr/obj-ptrn-prop-ary-value-null.js | 32 ++++++++++ .../statements/try/dstr/obj-ptrn-prop-ary.js | 43 +++++++++++++ .../statements/try/dstr/obj-ptrn-prop-eval-err.js | 34 +++++++++++ .../try/dstr/obj-ptrn-prop-id-get-value-err.js | 39 ++++++++++++ .../try/dstr/obj-ptrn-prop-id-init-skipped.js | 58 ++++++++++++++++++ .../try/dstr/obj-ptrn-prop-id-init-throws.js | 37 ++++++++++++ .../try/dstr/obj-ptrn-prop-id-init-unresolvable.js | 41 +++++++++++++ .../statements/try/dstr/obj-ptrn-prop-id-init.js | 39 ++++++++++++ .../try/dstr/obj-ptrn-prop-id-trailing-comma.js | 40 +++++++++++++ .../statements/try/dstr/obj-ptrn-prop-id.js | 39 ++++++++++++ .../statements/try/dstr/obj-ptrn-prop-obj-init.js | 45 ++++++++++++++ .../try/dstr/obj-ptrn-prop-obj-value-null.js | 32 ++++++++++ .../try/dstr/obj-ptrn-prop-obj-value-undef.js | 32 ++++++++++ .../statements/try/dstr/obj-ptrn-prop-obj.js | 43 +++++++++++++ .../statements/try/dstr/obj-ptrn-rest-getter.js | 38 ++++++++++++ .../try/dstr/obj-ptrn-rest-skip-non-enumerable.js | 46 ++++++++++++++ .../statements/try/dstr/obj-ptrn-rest-val-obj.js | 45 ++++++++++++++ .../test262/language/statements/try/dstr/shell.js | 0 95 files changed, 4052 insertions(+) create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/browser.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/try/dstr/shell.js (limited to 'js/src/tests/test262/language/statements/try/dstr') diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-init-iter-close.js b/js/src/tests/test262/language/statements/try/dstr/ary-init-iter-close.js new file mode 100644 index 0000000000..d41ab2cdac --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-init-iter-close.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/try.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw iter; +} catch ([x]) { + assert.sameValue(doneCallCount, 1); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/try/dstr/ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..f01ceecb54 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/try.template +/*--- +description: Abrupt completion returned by GetIterator (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw [1, 2, 3]; + } catch ([x, y, z]) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/try/dstr/ary-init-iter-get-err.js new file mode 100644 index 0000000000..015d7ce02d --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-init-iter-get-err.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Abrupt completion returned by GetIterator (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw iter; + } catch ([x]) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/try/dstr/ary-init-iter-no-close.js new file mode 100644 index 0000000000..df581d9257 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-init-iter-no-close.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/try.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw iter; +} catch ([x]) { + assert.sameValue(doneCallCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-name-iter-val.js b/js/src/tests/test262/language/statements/try/dstr/ary-name-iter-val.js new file mode 100644 index 0000000000..230c622325 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-name-iter-val.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding with normal value iteration (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [1, 2, 3]; +} catch ([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..7efdc12521 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is used (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw []; +} catch ([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..5c19e09ec1 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [[7, 8, 9]]; +} catch ([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..d351df4dc2 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is used (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw []; +} catch ([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..1d7f26c237 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [[]]; +} catch ([[,] = g()]) { + assert.sameValue(callCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..088fb1a245 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is used (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw []; +} catch ([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..cd1142a4ab --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [[23]]; +} catch ([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..48aac25420 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is used (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw []; +} catch ([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..d33a10a266 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [values]; +} catch ([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..0e6088e9ec --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/try.template +/*--- +description: Nested array destructuring with a null value (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw [null]; + } catch ([[x]]) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..34684ab78b --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/try.template +/*--- +description: Destructuring initializer with an exhausted iterator (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw []; +} catch ([x = 23]) { + assert.sameValue(x, 23); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..99a386d1fd --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,43 @@ +// 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/try.template +/*--- +description: SingleNameBinding does assign name to arrow functions (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw []; +} catch ([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..6f54b97552 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,45 @@ +// 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/try.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw []; +} catch ([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..6eee0b0d32 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,44 @@ +// 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/try.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw []; +} catch ([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..9a0f13ea57 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,44 @@ +// 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/try.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw []; +} catch ([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..78de727bfc --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,45 @@ +// 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/try.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw []; +} catch ([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..643280c006 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/try.template +/*--- +description: Destructuring initializer with a "hole" (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [,]; +} catch ([x = 23]) { + assert.sameValue(x, 23); + // another statement + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..6893e38431 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/try.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [null, 0, false, '']; +} catch ([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..081ab2d6d8 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/try.template +/*--- +description: Destructuring initializer returns an abrupt completion (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw [undefined]; + } catch ([x = (function() { throw new Test262Error(); })()]) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..1deb600a64 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/try.template +/*--- +description: Destructuring initializer with an undefined value (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [undefined]; +} catch ([x = 23]) { + assert.sameValue(x, 23); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..88352786b9 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/try.template +/*--- +description: Destructuring initializer is an unresolvable reference (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw []; + } catch ([ x = unresolvableReference ]) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..418607b613 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding when value iteration completes (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw []; +} catch ([x]) { + assert.sameValue(x, undefined); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..41eb272e1f --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding when value iteration was completed previously (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw []; +} catch ([_, x]) { + assert.sameValue(x, undefined); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..2d71680d83 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw g; + } catch ([x]) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..c9479ccf14 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,61 @@ +// 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/try.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [1, 2, 3]; +} catch ([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..6ce13a0da7 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw g; + } catch ([x]) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..8b1848d36e --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding when value iteration was completed previously (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [1, 2, 3]; +} catch ([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..094218a510 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with object binding pattern and initializer is used (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw []; +} catch ([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..fd578d90a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-id.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [{ x: 11, y: 22, z: 33 }]; +} catch ([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..8ff30194e9 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with object binding pattern and initializer is used (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw []; +} catch ([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..2d87609e0a --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [{ u: 777, w: 888, y: 999 }]; +} catch ([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..a31061b40a --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/try.template +/*--- +description: Nested object destructuring with a null value (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw [null]; + } catch ([{ x }]) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..cb201ef7a2 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/try.template +/*--- +description: Nested object destructuring with a value of `undefined` (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw []; + } catch ([{ x }]) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..548c23271b --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elision-exhausted.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/try.template +/*--- +description: Elision accepts exhausted iterator (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw iter; +} catch ([,]) { + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..61b2b4a2fa --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elision-step-err.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Elision advances iterator and forwards abrupt completions (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw iter; + } catch ([,]) {} +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elision.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elision.js new file mode 100644 index 0000000000..9d4a12470e --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elision.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/try.template +/*--- +description: Elision advances iterator (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw g(); +} catch ([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-empty.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-empty.js new file mode 100644 index 0000000000..21ffbd3fd7 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-empty.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/try.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var ranCatch = false; + +try { + throw iter; +} catch ([]) { + assert.sameValue(iterations, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..fbba3cbe50 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-elem.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element containing an array BindingElementList pattern (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [3, 4, 5]; +} catch ([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..7f7162bc84 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-elision.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element containing an elision (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw g(); +} catch ([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..c193f1b75c --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-empty.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element containing an "empty" array pattern (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw iter; +} catch ([...[]]) { + assert.sameValue(iterations, 1); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..c7516b95bf --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-ary-rest.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element containing a rest element (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw values; +} catch ([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..af9ad6c4f6 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-direct.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/try.template +/*--- +description: Lone rest element (direct binding) (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +includes: [compareArray.js] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [1]; +} catch ([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..21f0a58f66 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Rest element following elision elements (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw iter; + } catch ([, ...x]) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..be5b0791a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-elision.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element following elision elements (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw values; +} catch ([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..5bf9eef652 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/try.template +/*--- +description: RestElement applied to an exhausted iterator (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [1, 2]; +} catch ([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..2bbd1c296d --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw iter; + } catch ([...x]) {} +}); + +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/try/dstr/ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..dca33915de --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw iter; + } catch ([...x]) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id.js new file mode 100644 index 0000000000..bf01791203 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/try.template +/*--- +description: Lone rest element (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw values; +} catch ([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..dd1b187d98 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-init-ary.js @@ -0,0 +1,38 @@ +// |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/try.template +/*--- +description: Rest element (nested array pattern) does not support initializer (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var ranCatch = false; + +try { + throw []; +} catch ([...[ x ] = []]) { + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..c61b65927f --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-init-id.js @@ -0,0 +1,38 @@ +// |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/try.template +/*--- +description: Rest element (identifier) does not support initializer (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var ranCatch = false; + +try { + throw []; +} catch ([...x = []]) { + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..cea566a275 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-init-obj.js @@ -0,0 +1,38 @@ +// |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/try.template +/*--- +description: Rest element (nested object pattern) does not support initializer (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var ranCatch = false; + +try { + throw []; +} catch ([...{ x } = []]) { + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..a056a5472f --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,38 @@ +// |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/try.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var ranCatch = false; + +try { + throw [1, 2, 3]; +} catch ([...[x], y]) { + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..54763c08e2 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-not-final-id.js @@ -0,0 +1,38 @@ +// |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/try.template +/*--- +description: Rest element (identifier) may not be followed by any element (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var ranCatch = false; + +try { + throw [1, 2, 3]; +} catch ([...x, y]) { + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..179a4cfbd7 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,38 @@ +// |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/try.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var ranCatch = false; + +try { + throw [1, 2, 3]; +} catch ([...{ x }, y]) { + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..bc04d33472 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-obj-id.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element containing an object binding pattern (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [1, 2, 3]; +} catch ([...{ length }]) { + assert.sameValue(length, 3); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..6e2d42230a --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element containing an object binding pattern (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw [7, 8, 9]; +} catch ([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/browser.js b/js/src/tests/test262/language/statements/try/dstr/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-init-null.js b/js/src/tests/test262/language/statements/try/dstr/obj-init-null.js new file mode 100644 index 0000000000..291971cbd0 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-init-null.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/try.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + try { + throw null; + } catch ({}) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-init-undefined.js b/js/src/tests/test262/language/statements/try/dstr/obj-init-undefined.js new file mode 100644 index 0000000000..6eec2d6a48 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-init-undefined.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/try.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + try { + throw undefined; + } catch ({}) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-empty.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-empty.js new file mode 100644 index 0000000000..549b80531b --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-empty.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/try.template +/*--- +description: No property access occurs for an "empty" object binding pattern (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var ranCatch = false; + +try { + throw obj; +} catch ({}) { + assert.sameValue(accessCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..a3b7d820f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-get-value-err.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw poisonedProperty; + } catch ({ poisoned }) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..cfc6fbee3e --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw {}; +} catch ({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..ea50c490a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw {}; +} catch ({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..51fe56bc2b --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw {}; +} catch ({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..a80ed00fb0 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw {}; +} catch ({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..97103ccdb4 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw {}; +} catch ({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..e4282b7dcf --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-skipped.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/try.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw { w: null, x: 0, y: false, z: '' }; +} catch ({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..11930c89eb --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-throws.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/try.template +/*--- +description: Error thrown when evaluating the initializer (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw {}; + } catch ({ x = thrower() }) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..b078767f64 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/try.template +/*--- +description: Destructuring initializer is an unresolvable reference (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw {}; + } catch ({ x = unresolvableReference }) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..b8ab86d372 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-trailing-comma.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/try.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var ranCatch = false; + +try { + throw { x: 23 }; +} catch ({ x, }) { + assert.sameValue(x, 23); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-list-err.js new file mode 100644 index 0000000000..560b49bc04 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-list-err.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw {}; + } catch ({ a, b = thrower(), c = ++initCount }) {} +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..988cec6e7f --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary-init.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/try.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw {}; +} catch ({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..4407d98762 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/try.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var ranCatch = false; + +try { + throw { x: [45] }; +} catch ({ x: [y], }) { + assert.sameValue(y,45); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..6161491155 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/try.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw { w: null }; + } catch ({ w: [x, y, z] = [4, 5, 6] }) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..0d2d737803 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-ary.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/try.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw { w: [7, undefined, ] }; +} catch ({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..714a3e2343 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-eval-err.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Evaluation of property name returns an abrupt completion (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw {}; + } catch ({ [thrower()]: x }) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..c02a9aaa45 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw poisonedProperty; + } catch ({ poisoned: x = ++initEvalCount }) {} +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..93a7e09e5e --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/try.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw { s: null, u: 0, w: false, y: '' }; +} catch ({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..dfa4fd11c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/try.template +/*--- +description: Error thrown when evaluating the initializer (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw {}; + } catch ({ x: y = thrower() }) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..6edb704086 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/try.template +/*--- +description: Destructuring initializer is an unresolvable reference (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw {}; + } catch ({ x: y = unresolvableReference }) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..c4e9d47964 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-init.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/try.template +/*--- +description: Binding as specified via property name, identifier, and initializer (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw { }; +} catch ({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..6d64a66c42 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/try.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var ranCatch = false; + +try { + throw { x: 23 }; +} catch ({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id.js new file mode 100644 index 0000000000..827f3a3699 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-id.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/try.template +/*--- +description: Binding as specified via property name and identifier (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw { x: 23 }; +} catch ({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..4730f557ae --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj-init.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/try.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw { w: undefined }; +} catch ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..2bc8fd29d0 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/try.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw { w: null }; + } catch ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..5e368068f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/try.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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() { + try { + throw { }; + } catch ({ w: { x, y, z } = undefined }) {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..538a5a8137 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-prop-obj.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/try.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv 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 ranCatch = false; + +try { + throw { w: { x: undefined, z: 7 } }; +} catch ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..1ea2ac5a86 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-rest-getter.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/try.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] +---*/ +var count = 0; + +var ranCatch = false; + +try { + throw { get v() { count++; return 2; } }; +} catch ({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..c9fd0c7f96 --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest object doesn't contain non-enumerable properties (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var ranCatch = false; + +try { + throw o; +} catch ({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..c5390b4a2c --- /dev/null +++ b/js/src/tests/test262/language/statements/try/dstr/obj-ptrn-rest-val-obj.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest object contains just unextracted data (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] +---*/ + +var ranCatch = false; + +try { + throw {x: 1, y: 2, a: 5, b: 3}; +} catch ({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/try/dstr/shell.js b/js/src/tests/test262/language/statements/try/dstr/shell.js new file mode 100644 index 0000000000..e69de29bb2 -- cgit v1.2.3