mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 14:04:51 +02:00
Add omitted destructuring binding forms
Add test templates for destructuring binding as it occurs in previously-overlooked productions (various IterationStatements and the TryStatement).
This commit is contained in:
parent
8c6b1320de
commit
be195c38ca
47
src/dstr-binding/default/for-const.template
Normal file
47
src/dstr-binding/default/for-const.template
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
path: language/statements/for/dstr-const-
|
||||
name: for statement
|
||||
esid: sec-for-statement-runtime-semantics-labelledevaluation
|
||||
es6id: 13.7.4.7
|
||||
features: [destructuring-binding]
|
||||
info: |
|
||||
IterationStatement :
|
||||
for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
|
||||
|
||||
[...]
|
||||
7. Let forDcl be the result of evaluating LexicalDeclaration.
|
||||
[...]
|
||||
|
||||
LexicalDeclaration : LetOrConst BindingList ;
|
||||
|
||||
1. Let next be the result of evaluating BindingList.
|
||||
2. ReturnIfAbrupt(next).
|
||||
3. Return NormalCompletion(empty).
|
||||
|
||||
BindingList : BindingList , LexicalBinding
|
||||
|
||||
1. Let next be the result of evaluating BindingList.
|
||||
2. ReturnIfAbrupt(next).
|
||||
3. Return the result of evaluating LexicalBinding.
|
||||
|
||||
LexicalBinding : BindingPattern Initializer
|
||||
|
||||
1. Let rhs be the result of evaluating Initializer.
|
||||
2. Let value be GetValue(rhs).
|
||||
3. ReturnIfAbrupt(value).
|
||||
4. Let env be the running execution context’s LexicalEnvironment.
|
||||
5. Return the result of performing BindingInitialization for BindingPattern
|
||||
using value and env as the arguments.
|
||||
---*/
|
||||
|
||||
var iterCount = 0;
|
||||
|
||||
for (const /*{ elems }*/ = /*{ vals }*/; iterCount < 1; ) {
|
||||
/*{ body }*/
|
||||
|
||||
iterCount += 1;
|
||||
}
|
||||
|
||||
assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
|
47
src/dstr-binding/default/for-let.template
Normal file
47
src/dstr-binding/default/for-let.template
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
path: language/statements/for/dstr-let-
|
||||
name: for statement
|
||||
esid: sec-for-statement-runtime-semantics-labelledevaluation
|
||||
es6id: 13.7.4.7
|
||||
features: [destructuring-binding]
|
||||
info: |
|
||||
IterationStatement :
|
||||
for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
|
||||
|
||||
[...]
|
||||
7. Let forDcl be the result of evaluating LexicalDeclaration.
|
||||
[...]
|
||||
|
||||
LexicalDeclaration : LetOrConst BindingList ;
|
||||
|
||||
1. Let next be the result of evaluating BindingList.
|
||||
2. ReturnIfAbrupt(next).
|
||||
3. Return NormalCompletion(empty).
|
||||
|
||||
BindingList : BindingList , LexicalBinding
|
||||
|
||||
1. Let next be the result of evaluating BindingList.
|
||||
2. ReturnIfAbrupt(next).
|
||||
3. Return the result of evaluating LexicalBinding.
|
||||
|
||||
LexicalBinding : BindingPattern Initializer
|
||||
|
||||
1. Let rhs be the result of evaluating Initializer.
|
||||
2. Let value be GetValue(rhs).
|
||||
3. ReturnIfAbrupt(value).
|
||||
4. Let env be the running execution context’s LexicalEnvironment.
|
||||
5. Return the result of performing BindingInitialization for BindingPattern
|
||||
using value and env as the arguments.
|
||||
---*/
|
||||
|
||||
var iterCount = 0;
|
||||
|
||||
for (let /*{ elems }*/ = /*{ vals }*/; iterCount < 1; ) {
|
||||
/*{ body }*/
|
||||
|
||||
iterCount += 1;
|
||||
}
|
||||
|
||||
assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
|
47
src/dstr-binding/default/for-of-const.template
Normal file
47
src/dstr-binding/default/for-of-const.template
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
path: language/statements/for-of/dstr-const-
|
||||
name: for-of statement
|
||||
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
|
||||
es6id: 13.7.5.11
|
||||
features: [destructuring-binding]
|
||||
info: |
|
||||
IterationStatement :
|
||||
for ( ForDeclaration of AssignmentExpression ) Statement
|
||||
|
||||
[...]
|
||||
3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
|
||||
lexicalBinding, labelSet).
|
||||
|
||||
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
|
||||
|
||||
[...]
|
||||
3. Let destructuring be IsDestructuring of lhs.
|
||||
[...]
|
||||
5. Repeat
|
||||
[...]
|
||||
h. If destructuring is false, then
|
||||
[...]
|
||||
i. Else
|
||||
i. If lhsKind is assignment, then
|
||||
[...]
|
||||
ii. Else if lhsKind is varBinding, then
|
||||
[...]
|
||||
iii. Else,
|
||||
1. Assert: lhsKind is lexicalBinding.
|
||||
2. Assert: lhs is a ForDeclaration.
|
||||
3. Let status be the result of performing BindingInitialization
|
||||
for lhs passing nextValue and iterationEnv as arguments.
|
||||
[...]
|
||||
---*/
|
||||
|
||||
var iterCount = 0;
|
||||
|
||||
for (const /*{ elems }*/ of [/*{ vals }*/]) {
|
||||
/*{ body }*/
|
||||
|
||||
iterCount += 1;
|
||||
}
|
||||
|
||||
assert.sameValue(iterCount, 1, 'iteration occurred as expected');
|
47
src/dstr-binding/default/for-of-let.template
Normal file
47
src/dstr-binding/default/for-of-let.template
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
path: language/statements/for-of/dstr-let-
|
||||
name: for-of statement
|
||||
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
|
||||
es6id: 13.7.5.11
|
||||
features: [destructuring-binding]
|
||||
info: |
|
||||
IterationStatement :
|
||||
for ( ForDeclaration of AssignmentExpression ) Statement
|
||||
|
||||
[...]
|
||||
3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
|
||||
lexicalBinding, labelSet).
|
||||
|
||||
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
|
||||
|
||||
[...]
|
||||
3. Let destructuring be IsDestructuring of lhs.
|
||||
[...]
|
||||
5. Repeat
|
||||
[...]
|
||||
h. If destructuring is false, then
|
||||
[...]
|
||||
i. Else
|
||||
i. If lhsKind is assignment, then
|
||||
[...]
|
||||
ii. Else if lhsKind is varBinding, then
|
||||
[...]
|
||||
iii. Else,
|
||||
1. Assert: lhsKind is lexicalBinding.
|
||||
2. Assert: lhs is a ForDeclaration.
|
||||
3. Let status be the result of performing BindingInitialization
|
||||
for lhs passing nextValue and iterationEnv as arguments.
|
||||
[...]
|
||||
---*/
|
||||
|
||||
var iterCount = 0;
|
||||
|
||||
for (let /*{ elems }*/ of [/*{ vals }*/]) {
|
||||
/*{ body }*/
|
||||
|
||||
iterCount += 1;
|
||||
}
|
||||
|
||||
assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
|
44
src/dstr-binding/default/for-of-var.template
Normal file
44
src/dstr-binding/default/for-of-var.template
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
path: language/statements/for-of/dstr-var-
|
||||
name: for-of statement
|
||||
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
|
||||
es6id: 13.7.5.11
|
||||
features: [destructuring-binding]
|
||||
info: |
|
||||
IterationStatement :
|
||||
for ( var ForBinding of AssignmentExpression ) Statement
|
||||
|
||||
[...]
|
||||
3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
|
||||
varBinding, labelSet).
|
||||
|
||||
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
|
||||
|
||||
[...]
|
||||
3. Let destructuring be IsDestructuring of lhs.
|
||||
[...]
|
||||
5. Repeat
|
||||
[...]
|
||||
h. If destructuring is false, then
|
||||
[...]
|
||||
i. Else
|
||||
i. If lhsKind is assignment, then
|
||||
[...]
|
||||
ii. Else if lhsKind is varBinding, then
|
||||
1. Assert: lhs is a ForBinding.
|
||||
2. Let status be the result of performing BindingInitialization
|
||||
for lhs passing nextValue and undefined as the arguments.
|
||||
[...]
|
||||
---*/
|
||||
|
||||
var iterCount = 0;
|
||||
|
||||
for (var /*{ elems }*/ of [/*{ vals }*/]) {
|
||||
/*{ body }*/
|
||||
|
||||
iterCount += 1;
|
||||
}
|
||||
|
||||
assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
|
40
src/dstr-binding/default/for-var.template
Normal file
40
src/dstr-binding/default/for-var.template
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
path: language/statements/for/dstr-var-
|
||||
name: for statement
|
||||
esid: sec-for-statement-runtime-semantics-labelledevaluation
|
||||
es6id: 13.7.4.7
|
||||
features: [destructuring-binding]
|
||||
info: |
|
||||
IterationStatement :
|
||||
for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
|
||||
|
||||
1. Let varDcl be the result of evaluating VariableDeclarationList.
|
||||
[...]
|
||||
|
||||
13.3.2.4 Runtime Semantics: Evaluation
|
||||
|
||||
VariableDeclarationList : VariableDeclarationList , VariableDeclaration
|
||||
|
||||
1. Let next be the result of evaluating VariableDeclarationList.
|
||||
2. ReturnIfAbrupt(next).
|
||||
3. Return the result of evaluating VariableDeclaration.
|
||||
|
||||
VariableDeclaration : BindingPattern Initializer
|
||||
|
||||
1. Let rhs be the result of evaluating Initializer.
|
||||
2. Let rval be GetValue(rhs).
|
||||
3. ReturnIfAbrupt(rval).
|
||||
4. Return the result of performing BindingInitialization for BindingPattern
|
||||
passing rval and undefined as arguments.
|
||||
---*/
|
||||
|
||||
var iterCount = 0;
|
||||
|
||||
for (var /*{ elems }*/ = /*{ vals }*/; iterCount < 1; ) {
|
||||
/*{ body }*/
|
||||
iterCount += 1;
|
||||
}
|
||||
|
||||
assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
|
27
src/dstr-binding/default/try.template
Normal file
27
src/dstr-binding/default/try.template
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
path: language/statements/try/dstr-
|
||||
name: try statement
|
||||
esid: sec-runtime-semantics-catchclauseevaluation
|
||||
es6id: 13.15.7
|
||||
features: [destructuring-binding]
|
||||
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 /*{ vals }*/;
|
||||
} catch (/*{ elems }*/) {
|
||||
/*{ body }*/
|
||||
ranCatch = true;
|
||||
}
|
||||
|
||||
assert(ranCatch, 'executed `catch` block');
|
Loading…
x
Reference in New Issue
Block a user