Skip to content
Snippets Groups Projects
Commit 75db6744 authored by Lucas Azzola's avatar Lucas Azzola Committed by Leo Balter
Browse files

Add optional-catch-binding tests (#1167)

parent eb93f969
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,10 @@ Symbol.asyncIterator ...@@ -21,6 +21,10 @@ Symbol.asyncIterator
object-rest object-rest
object-spread object-spread
# Optional Catch Binding
# https://github.com/tc39/proposal-optional-catch-binding
optional-catch-binding
# RegExp s (dotAll) flag # RegExp s (dotAll) flag
# https://github.com/tc39/proposal-regexp-dotall-flag # https://github.com/tc39/proposal-regexp-dotall-flag
regexp-dotall regexp-dotall
......
// 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 {}
// 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;
});
// Copyright 2009 the Sputnik authors. All rights reserved. // Copyright (C) 2017 Lucas Azzola. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
info: > author: Lucas Azzola
TryStatement: "try Block Catch" or "try Block Finally" or "try Block esid: pending
Catch Finally"
es5id: 12.14_A16_T4
description: > description: >
Catch: "catch (Identifier ) Block". Checking if execution of It is a SyntaxError to have a try/catch statement with an empty CatchParameter
"catch" that takes no arguments fails features: [optional-catch-binding]
info: |
Catch[Yield, Await, Return]:
catch ( CatchParameter[?Yield, ?Await] ) Block[?Yield, ?Await, ?Return]
negative: negative:
phase: early phase: early
type: SyntaxError type: SyntaxError
...@@ -16,6 +17,5 @@ negative: ...@@ -16,6 +17,5 @@ negative:
throw "Test262: This statement should not be evaluated."; throw "Test262: This statement should not be evaluated.";
// CHECK#1 try {} catch () {}
try{}
catch{}
// 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();
}
});
// 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 {}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment