mirror of https://github.com/tc39/test262.git
Add optional-catch-binding tests (#1167)
This commit is contained in:
parent
eb93f96911
commit
75db6744eb
|
@ -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
|
||||
|
|
|
@ -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{}
|
|
@ -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 {}
|
|
@ -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;
|
||||
});
|
|
@ -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 () {}
|
||||
|
|
@ -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();
|
||||
}
|
||||
});
|
|
@ -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 {}
|
Loading…
Reference in New Issue