mirror of https://github.com/tc39/test262.git
Add tests for interpretation of `let` token
This commit is contained in:
parent
7a8e644696
commit
ce2e421464
|
@ -0,0 +1,31 @@
|
||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-iteration-statements
|
||||||
|
es6id: 13.7
|
||||||
|
description: >
|
||||||
|
The token sequence `let [`is interpreted as the beginning of a destructuring
|
||||||
|
binding pattern
|
||||||
|
info: |
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
IterationStatement[Yield, Return]:
|
||||||
|
|
||||||
|
for ( [lookahead ∉ { let [ } ] LeftHandSideExpression[?Yield] in
|
||||||
|
Expression[+In, ?Yield] ) Statement[?Yield, ?Return]
|
||||||
|
|
||||||
|
for ( ForDeclaration[?Yield] in Expression[+In, ?Yield] )
|
||||||
|
Statement[?Yield, ?Return]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var obj = Object.create(null);
|
||||||
|
var value;
|
||||||
|
|
||||||
|
obj.key = 1;
|
||||||
|
|
||||||
|
for ( let[x] in obj ) {
|
||||||
|
value = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(typeof x, 'undefined', 'binding is block-scoped');
|
||||||
|
assert.sameValue(value, 'k');
|
|
@ -0,0 +1,38 @@
|
||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-iteration-statements
|
||||||
|
es6id: 13.7
|
||||||
|
description: >
|
||||||
|
The `let` token is interpreted as an Identifier when it is not followed by a
|
||||||
|
`[` token
|
||||||
|
info: |
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
IterationStatement[Yield, Return]:
|
||||||
|
|
||||||
|
for ( [lookahead ∉ { let [ } ] LeftHandSideExpression[?Yield] in
|
||||||
|
Expression[+In, ?Yield] ) Statement[?Yield, ?Return]
|
||||||
|
|
||||||
|
for ( ForDeclaration[?Yield] in Expression[+In, ?Yield] )
|
||||||
|
Statement[?Yield, ?Return]
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var obj = Object.create(null);
|
||||||
|
var let, value;
|
||||||
|
|
||||||
|
obj.key = 1;
|
||||||
|
|
||||||
|
for ( let in obj ) ;
|
||||||
|
|
||||||
|
assert.sameValue(let, 'key', 'IdentifierReference');
|
||||||
|
|
||||||
|
Object.defineProperty(Array.prototype, '1', {
|
||||||
|
set: function(param) {
|
||||||
|
value = param;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for ( [let][1] in obj ) ;
|
||||||
|
|
||||||
|
assert.sameValue(value, 'key', 'MemberExpression');
|
|
@ -0,0 +1,28 @@
|
||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-for-in-and-for-of-statements
|
||||||
|
es6id: 13.7.5
|
||||||
|
description: >
|
||||||
|
The token sequence `let [`is interpreted as the beginning of a destructuring
|
||||||
|
binding pattern
|
||||||
|
info: |
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
IterationStatement[Yield, Return]:
|
||||||
|
|
||||||
|
for ( [lookahead ≠ let]LeftHandSideExpression[?Yield] of
|
||||||
|
AssignmentExpression[+In, ?Yield] ) Statement[?Yield, ?Return]
|
||||||
|
|
||||||
|
for ( ForDeclaration[?Yield] of AssignmentExpression[+In, ?Yield] )
|
||||||
|
Statement[?Yield, ?Return]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var value;
|
||||||
|
|
||||||
|
for ( let[x] of [[34]] ) {
|
||||||
|
value = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(typeof x, 'undefined', 'binding is block-scoped');
|
||||||
|
assert.sameValue(value, 34);
|
|
@ -0,0 +1,21 @@
|
||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-for-in-and-for-of-statements
|
||||||
|
es6id: 13.7.5
|
||||||
|
description: >
|
||||||
|
The `let` token is disallowed when not followed by a `[` token
|
||||||
|
info: |
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
IterationStatement[Yield, Return]:
|
||||||
|
|
||||||
|
for ( [lookahead ≠ let]LeftHandSideExpression[?Yield] of
|
||||||
|
AssignmentExpression[+In, ?Yield] ) Statement[?Yield, ?Return]
|
||||||
|
|
||||||
|
for ( ForDeclaration[?Yield] of AssignmentExpression[+In, ?Yield] )
|
||||||
|
Statement[?Yield, ?Return]
|
||||||
|
negative: SyntaxError
|
||||||
|
---*/
|
||||||
|
|
||||||
|
for ( let of [] ) ;
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-iteration-statements
|
||||||
|
es6id: 13.7
|
||||||
|
description: >
|
||||||
|
The token sequence `let [`is interpreted as the beginning of a destructuring
|
||||||
|
binding pattern
|
||||||
|
info: |
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
IterationStatement[Yield, Return]:
|
||||||
|
|
||||||
|
for ( [lookahead ∉ { let [ } ] Expression[~In, ?Yield]opt ;
|
||||||
|
Expression[+In, ?Yield]opt ; Expression[+In, ?Yield]opt )
|
||||||
|
Statement[?Yield, ?Return]
|
||||||
|
|
||||||
|
for ( LexicalDeclaration[~In, ?Yield] Expression[+In, ?Yield]opt ;
|
||||||
|
Expression[+In, ?Yield]opt) Statement[?Yield, ?Return]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var value;
|
||||||
|
|
||||||
|
for ( let[x] = [23]; ; ) {
|
||||||
|
value = x;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(typeof x, 'undefined', 'binding is block-scoped');
|
||||||
|
assert.sameValue(value, 23);
|
|
@ -0,0 +1,41 @@
|
||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-iteration-statements
|
||||||
|
es6id: 13.7
|
||||||
|
description: >
|
||||||
|
The `let` token is interpreted as an Identifier when it is not followed by a
|
||||||
|
`[` token
|
||||||
|
info: |
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
IterationStatement[Yield, Return]:
|
||||||
|
|
||||||
|
for ( [lookahead ∉ { let [ } ] Expression[~In, ?Yield]opt ;
|
||||||
|
Expression[+In, ?Yield]opt ; Expression[+In, ?Yield]opt )
|
||||||
|
Statement[?Yield, ?Return]
|
||||||
|
|
||||||
|
for ( LexicalDeclaration[~In, ?Yield] Expression[+In, ?Yield]opt ;
|
||||||
|
Expression[+In, ?Yield]opt) Statement[?Yield, ?Return]
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var let;
|
||||||
|
|
||||||
|
let = 1;
|
||||||
|
for ( let; ; )
|
||||||
|
break;
|
||||||
|
|
||||||
|
assert.sameValue(let, 1, 'IdentifierReference');
|
||||||
|
|
||||||
|
let = 2;
|
||||||
|
for ( let = 3; ; )
|
||||||
|
break;
|
||||||
|
|
||||||
|
assert.sameValue(let, 3, 'AssignmentExpression');
|
||||||
|
|
||||||
|
let = 4;
|
||||||
|
for ( [let][0]; ; )
|
||||||
|
break;
|
||||||
|
|
||||||
|
assert.sameValue(let, 4, 'MemberExpression');
|
Loading…
Reference in New Issue