mirror of https://github.com/tc39/test262.git
Add tests for for-in initializers (#735)
These were re-introduced in sloppy mode per https://github.com/tc39/ecma262/pull/614
This commit is contained in:
parent
55cf59c80d
commit
d6580e8b66
|
@ -0,0 +1,12 @@
|
|||
// 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-initializers-in-forin-statement-heads
|
||||
description: >
|
||||
for-in heads prohibit AssignmentExpressions
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
var a;
|
||||
throw NotEarlyError;
|
||||
for (a = 0 in {});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// 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-initializers-in-forin-statement-heads
|
||||
description: >
|
||||
for-in initializers with const are prohibited
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
throw NotEarlyError;
|
||||
for (const a = 0 in {});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// 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-initializers-in-forin-statement-heads
|
||||
description: >
|
||||
for-in initializers with let are prohibited
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
throw NotEarlyError;
|
||||
for (let a = 0 in {});
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// 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-initializers-in-forin-statement-heads
|
||||
description: >
|
||||
for-in initializers in nonstrict mode
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
(function() {
|
||||
var effects = 0;
|
||||
for (var a = ++effects in {});
|
||||
assert.sameValue(effects, 1);
|
||||
})();
|
||||
|
||||
|
||||
(function() {
|
||||
var stored;
|
||||
for (var a = 0 in stored = a, {});
|
||||
assert.sameValue(stored, 0);
|
||||
})();
|
||||
|
||||
|
||||
(function() {
|
||||
for (var a = 0 in {});
|
||||
assert.sameValue(a, 0);
|
||||
})();
|
||||
|
||||
|
||||
(function() {
|
||||
var effects = 0;
|
||||
var iterations = 0;
|
||||
var stored;
|
||||
for (var a = (++effects, -1) in stored = a, {a: 0, b: 1, c: 2}) {
|
||||
++iterations;
|
||||
}
|
||||
assert.sameValue(stored, -1, "Initialized value should be available to RHS");
|
||||
assert.sameValue(effects, 1, "Initializer should only be executed once");
|
||||
assert.sameValue(iterations, 3, "Loop body should be executed the appropriate number of times");
|
||||
})();
|
|
@ -0,0 +1,12 @@
|
|||
// 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-initializers-in-forin-statement-heads
|
||||
description: >
|
||||
for-in initializers in strict mode are prohibited
|
||||
negative: SyntaxError
|
||||
flags: [onlyStrict]
|
||||
---*/
|
||||
throw NotEarlyError;
|
||||
for (var a = 0 in {});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// 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-initializers-in-forin-statement-heads
|
||||
description: >
|
||||
for-in initializers with ArrayBindingPatterns are always prohibited
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
throw NotEarlyError;
|
||||
for (var [a] = 0 in {});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// 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-initializers-in-forin-statement-heads
|
||||
description: >
|
||||
for-in initializers with ObjectBindingPattern are always prohibited
|
||||
negative: SyntaxError
|
||||
---*/
|
||||
throw NotEarlyError;
|
||||
for (var {a} = 0 in {});
|
||||
|
Loading…
Reference in New Issue