mirror of https://github.com/tc39/test262.git
Import tests from Google V8 (Block Scope Additions)
These tests are derived from the following files within the Google V8 project: test/mjsunit/es6/regress/regress-2506.js test/mjsunit/es6/regress/regress-3426.js test/mjsunit/es6/regress/regress-3683.js
This commit is contained in:
parent
506f9fe803
commit
44c65fd02a
|
@ -5,7 +5,6 @@ es6id: 13.1
|
|||
description: >
|
||||
Mixed values in iteration
|
||||
---*/
|
||||
"use strict";
|
||||
function fn(x) {
|
||||
let a = [];
|
||||
for (let p in x) {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.1
|
||||
description: >
|
||||
Redeclaration error within strict mode function inside non-strict code.
|
||||
negative: SyntaxError
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
(function() { 'use strict'; { const f = 1; var f; } })
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (C) 2015 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.1
|
||||
es6id: 13.6.3.7_S5.a.i
|
||||
description: >
|
||||
const: invalid assignment in next expression
|
||||
negative: TypeError
|
||||
---*/
|
||||
|
||||
for (const i = 0; i < 1; i++) { }
|
||||
for (const i = 0; i < 1; i++) {}
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (C) 2011 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.6.4.10_S1.a.i
|
||||
description: >
|
||||
const: invalid assignment in Statement body
|
||||
negative: TypeError
|
||||
---*/
|
||||
|
||||
for (const x in [1, 2, 3]) { x++ }
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (C) 2011 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.6.4.10_S1.a.i
|
||||
description: >
|
||||
const: invalid assignment in Statement body
|
||||
negative: TypeError
|
||||
---*/
|
||||
|
||||
for (const x of [1, 2, 3]) { x++ }
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.12
|
||||
description: >
|
||||
labeled continue
|
||||
---*/
|
||||
var count = 0;
|
||||
label: for (let x = 0; x < 10;) {
|
||||
while (true) {
|
||||
x++;
|
||||
count++;
|
||||
continue label;
|
||||
}
|
||||
}
|
||||
assert.sameValue(count, 10, "The value of `count` is `10`");
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.12
|
||||
description: >
|
||||
nested let bound for loops inner continue
|
||||
---*/
|
||||
var count = 0;
|
||||
for (let x = 0; x < 10;) {
|
||||
x++;
|
||||
for (let y = 0; y < 2;) {
|
||||
y++;
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
assert.sameValue(count, 20, "The value of `count` is `20`");
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.12
|
||||
description: >
|
||||
nested let bound for loops labeled continue
|
||||
---*/
|
||||
var count = 0;
|
||||
outer: for (let x = 0; x < 10;) {
|
||||
x++;
|
||||
for (let y = 0; y < 2;) {
|
||||
y++;
|
||||
count++;
|
||||
if (y == 2) continue outer;
|
||||
}
|
||||
}
|
||||
assert.sameValue(count, 20, "The value of `count` is `20`");
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.12
|
||||
description: >
|
||||
nested let bound for loops outer continue
|
||||
---*/
|
||||
var count = 0;
|
||||
for (let x = 0; x < 10;) {
|
||||
x++;
|
||||
for (let y = 0; y < 2;) {
|
||||
y++;
|
||||
count++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
assert.sameValue(count, 20, "The value of `count` is `20`");
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.12
|
||||
description: >
|
||||
no label continue
|
||||
---*/
|
||||
var count = 0;
|
||||
for (let x = 0; x < 10;) {
|
||||
x++;
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
assert.sameValue(count, 10, "The value of `count` is `10`");
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.12
|
||||
description: >
|
||||
shadowing loop variable in same scope as continue
|
||||
---*/
|
||||
var count = 0;
|
||||
for (let x = 0; x < 10;) {
|
||||
x++;
|
||||
count++;
|
||||
{
|
||||
let x = "hello";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
assert.sameValue(count, 10, "The value of `count` is `10`");
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.12
|
||||
description: >
|
||||
basic labeled for loop with continue
|
||||
---*/
|
||||
var count = 0;
|
||||
label: for (let x = 0; x < 10;) {
|
||||
x++;
|
||||
count++;
|
||||
continue label;
|
||||
}
|
||||
assert.sameValue(count, 10, "The value of `count` is `10`");
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.6.4.12_S2
|
||||
description: >
|
||||
ForIn/Of: Bound names of ForDeclaration are in TDZ (for-of)
|
||||
negative: ReferenceError
|
||||
---*/
|
||||
|
||||
let x = 1;
|
||||
for (const x in { x }) {}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2011 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.6.4.13
|
||||
description: >
|
||||
const ForDeclaration: creates a fresh binding per iteration
|
||||
---*/
|
||||
|
||||
let s = '';
|
||||
for (const x of [1, 2, 3]) {
|
||||
s += x;
|
||||
}
|
||||
assert.sameValue(s, '123', "The value of `s` is `'123'`");
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.6.4.12_S2
|
||||
description: >
|
||||
ForIn/Of: Bound names of ForDeclaration are in TDZ (for-of)
|
||||
negative: ReferenceError
|
||||
---*/
|
||||
|
||||
let x = 1;
|
||||
for (let x in { x }) {}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2011 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.6.4.13
|
||||
description: >
|
||||
let ForDeclaration: creates a fresh binding per iteration
|
||||
---*/
|
||||
|
||||
let s = '';
|
||||
for (let x of [1, 2, 3]) {
|
||||
s += x;
|
||||
}
|
||||
assert.sameValue(s, '123', "The value of `s` is `'123'`");
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2011 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.6.4.12_S2
|
||||
description: >
|
||||
ForIn/Of: Bound names of ForDeclaration are in TDZ (for-of)
|
||||
negative: ReferenceError
|
||||
---*/
|
||||
|
||||
let x = 1;
|
||||
for (const x of [x]) {}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2011 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.6.4.13
|
||||
description: >
|
||||
const ForDeclaration: creates a fresh binding per iteration
|
||||
---*/
|
||||
|
||||
let s = 0;
|
||||
let f = [undefined, undefined, undefined];
|
||||
|
||||
for (const x of [1, 2, 3]) {
|
||||
s += x;
|
||||
f[x-1] = function() { return x; }
|
||||
}
|
||||
assert.sameValue(s, 6, "The value of `s` is `6`");
|
||||
assert.sameValue(f[0](), 1, "`f[0]()` returns `1`");
|
||||
assert.sameValue(f[1](), 2, "`f[1]()` returns `2`");
|
||||
assert.sameValue(f[2](), 3, "`f[2]()` returns `3`");
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2011 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.6.4.12_S2
|
||||
description: >
|
||||
ForIn/Of: Bound names of ForDeclaration are in TDZ (for-of)
|
||||
negative: ReferenceError
|
||||
---*/
|
||||
|
||||
let x = 1;
|
||||
for (let x of [x]) {}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2011 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.6.4.13
|
||||
description: >
|
||||
let ForDeclaration: creates a fresh binding per iteration
|
||||
---*/
|
||||
|
||||
let s = 0;
|
||||
let f = [undefined, undefined, undefined];
|
||||
|
||||
for (let x of [1, 2, 3]) {
|
||||
s += x;
|
||||
f[x-1] = function() { return x; }
|
||||
}
|
||||
assert.sameValue(s, 6, "The value of `s` is `6`");
|
||||
assert.sameValue(f[0](), 1, "`f[0]()` returns `1`");
|
||||
assert.sameValue(f[1](), 2, "`f[1]()` returns `2`");
|
||||
assert.sameValue(f[2](), 3, "`f[2]()` returns `3`");
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (C) 2011 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.6.4.13
|
||||
description: >
|
||||
const ForDeclaration: creates a fresh binding per iteration
|
||||
---*/
|
||||
|
||||
let z = 1;
|
||||
let s = 0;
|
||||
for (const x = 1; z < 2; z++) {
|
||||
s += x + z;
|
||||
}
|
||||
assert.sameValue(s, 2, "The value of `s` is `2`");
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (C) 2011 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.6.4.13
|
||||
description: >
|
||||
let ForDeclaration: creates a fresh binding per iteration
|
||||
---*/
|
||||
|
||||
let z = 1;
|
||||
let s = 0;
|
||||
for (let x = 1; z < 2; z++) {
|
||||
s += x + z;
|
||||
}
|
||||
assert.sameValue(s, 2, "The value of `s` is `2`");
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 13.1
|
||||
description: >
|
||||
Redeclaration error within strict mode function inside non-strict code.
|
||||
negative: SyntaxError
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
(function() { 'use strict'; { let f; var f; } })
|
||||
|
Loading…
Reference in New Issue