diff --git a/features.txt b/features.txt index d30744f6b5b29e9ff1264fe83799962ab21d80fb..abfde8e562df5d7bdcb9d6be823b501af78be026 100644 --- a/features.txt +++ b/features.txt @@ -21,6 +21,10 @@ Symbol.asyncIterator object-rest object-spread +# Optional Catch Binding +# https://github.com/tc39/proposal-optional-catch-binding +optional-catch-binding + # RegExp s (dotAll) flag # https://github.com/tc39/proposal-regexp-dotall-flag regexp-dotall diff --git a/test/language/statements/try/S12.14_A16_T4.js b/test/language/statements/try/S12.14_A16_T4.js deleted file mode 100644 index 8b46842fbd1f32065ba7052609bd5ff241f2f6c5..0000000000000000000000000000000000000000 --- a/test/language/statements/try/S12.14_A16_T4.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: > - TryStatement: "try Block Catch" or "try Block Finally" or "try Block - Catch Finally" -es5id: 12.14_A16_T4 -description: > - Catch: "catch (Identifier ) Block". Checking if execution of - "catch" that takes no arguments fails -negative: - phase: early - type: SyntaxError ----*/ - -throw "Test262: This statement should not be evaluated."; - -// CHECK#1 -try{} -catch{} diff --git a/test/language/statements/try/optional-catch-binding-finally.js b/test/language/statements/try/optional-catch-binding-finally.js new file mode 100644 index 0000000000000000000000000000000000000000..531da49a2f38f82c3f9d63022e2d6b8bad9b6f52 --- /dev/null +++ b/test/language/statements/try/optional-catch-binding-finally.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 Lucas Azzola. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Lucas Azzola +esid: pending +description: try/catch/finally syntax with omission of the catch binding +features: [optional-catch-binding] +info: | + Optional Catch Binding + + Catch[Yield, Await, Return]: + (...) + catch Block[?Yield, ?Await, ?Return] +---*/ + +try {} catch {} finally {} diff --git a/test/language/statements/try/optional-catch-binding-lexical.js b/test/language/statements/try/optional-catch-binding-lexical.js new file mode 100644 index 0000000000000000000000000000000000000000..ad0f55aa5dc1ba2d31c67feccce7a34c8f0d7104 --- /dev/null +++ b/test/language/statements/try/optional-catch-binding-lexical.js @@ -0,0 +1,38 @@ +// Copyright (C) 2017 Lucas Azzola. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Lucas Azzola +esid: pending +description: lexical environment runtime semantics for optional catch binding +features: [optional-catch-binding] +info: | + Runtime Semantics: CatchClauseEvaluation + + Catch : catch Block + Let oldEnv be the running execution context's LexicalEnvironment. + Let catchEnv be NewDeclarativeEnvironment(oldEnv). + Set the running execution context's LexicalEnvironment to catchEnv. + (...) + Set the running execution context's LexicalEnvironment to oldEnv. + Return Completion(B). +---*/ + +let x = 1; +let ranCatch = false; + +try { + x = 2; + throw new Error(); +} catch { + let x = 3; + let y = true; + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); +assert.sameValue(x, 2); + +assert.throws(ReferenceError, function() { + y; +}); diff --git a/test/language/statements/try/optional-catch-binding-parens.js b/test/language/statements/try/optional-catch-binding-parens.js new file mode 100644 index 0000000000000000000000000000000000000000..649a76bf86032ba390d1f6da9afe20b9deec5afb --- /dev/null +++ b/test/language/statements/try/optional-catch-binding-parens.js @@ -0,0 +1,21 @@ +// Copyright (C) 2017 Lucas Azzola. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Lucas Azzola +esid: pending +description: > + It is a SyntaxError to have a try/catch statement with an empty CatchParameter +features: [optional-catch-binding] +info: | + Catch[Yield, Await, Return]: + catch ( CatchParameter[?Yield, ?Await] ) Block[?Yield, ?Await, ?Return] +negative: + phase: early + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +try {} catch () {} + diff --git a/test/language/statements/try/optional-catch-binding-throws.js b/test/language/statements/try/optional-catch-binding-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..ee5b385e94d4ab18297b578ad036e2efe180ba39 --- /dev/null +++ b/test/language/statements/try/optional-catch-binding-throws.js @@ -0,0 +1,25 @@ +// Copyright (C) 2017 Lucas Azzola. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Lucas Azzola +esid: pending +description: errors can be thrown from catch clause without binding +features: [optional-catch-binding] +info: | + Runtime Semantics: CatchClauseEvaluation + + Catch : catch Block + (...) + Let B be the result of evaluating Block. + (...) + Return Completion(B). +---*/ + +assert.throws(Test262Error, function() { + try { + throw new Error(); + } catch { + throw new Test262Error(); + } +}); diff --git a/test/language/statements/try/optional-catch-binding.js b/test/language/statements/try/optional-catch-binding.js new file mode 100644 index 0000000000000000000000000000000000000000..107dc5799942367ae628a024eca7fc5982bd9957 --- /dev/null +++ b/test/language/statements/try/optional-catch-binding.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 Lucas Azzola. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Lucas Azzola +esid: pending +description: try/catch syntax with omission of the catch binding +features: [optional-catch-binding] +info: | + Optional Catch Binding + + Catch[Yield, Await, Return]: + (...) + catch Block[?Yield, ?Await, ?Return] +---*/ + +try {} catch {}