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
test/language
block-scope/syntax/for-in
statements
const
block-local-closure-get-before-initialization.jsblock-local-use-before-initialization-in-declaration-statement.jsblock-local-use-before-initialization-in-prior-statement.jsfunction-local-closure-get-before-initialization.jsfunction-local-use-before-initialization-in-declaration-statement.jsfunction-local-use-before-initialization-in-prior-statement.jsglobal-closure-get-before-initialization.jsglobal-use-before-initialization-in-declaration-statement.jsglobal-use-before-initialization-in-prior-statement.jsredeclaration-error-from-within-strict-mode-function-const.js
syntax
block-scope-syntax-const-declarations-mixed-with-without-initialiser.jsblock-scope-syntax-const-declarations-mixed-without-with-initialiser.jsblock-scope-syntax-const-declarations-without-initialiser.jsconst-invalid-assignment-next-expression-for.jsconst-invalid-assignment-statement-body-for-in.jsconst-invalid-assignment-statement-body-for-of.jsconst-outer-inner-let-bindings.jsconst.jswith-initializer-case-expression-statement-list.jswith-initializer-default-statement-list.jswith-initializer-do-statement-while-expression.jswith-initializer-for-statement.jswith-initializer-if-expression-statement-else-statement.jswith-initializer-if-expression-statement.jswith-initializer-label-statement.jswith-initializer-while-expression-statement.jswithout-initializer-case-expression-statement-list.jswithout-initializer-default-statement-list.jswithout-initializer-do-statement-while-expression.jswithout-initializer-for-statement.jswithout-initializer-if-expression-statement-else-statement.jswithout-initializer-if-expression-statement.jswithout-initializer-label-statement.jswithout-initializer-while-expression-statement.js
continue
labeled-continue.jsnested-let-bound-for-loops-inner-continue.jsnested-let-bound-for-loops-labeled-continue.jsnested-let-bound-for-loops-outer-continue.jsno-label-continue.jsshadowing-loop-variable-in-same-scope-as-continue.jssimple-and-labeled.js
for-in
const-bound-names-fordecl-tdz-for-in.jsconst-fresh-binding-per-iteration-for-in.jslet-bound-names-fordecl-tdz-for-in.jslet-fresh-binding-per-iteration-for-in.js
for-of
const-bound-names-fordecl-tdz-for-of.jsconst-fresh-binding-per-iteration-for-of.jslet-bound-names-fordecl-tdz-for-of.jslet-fresh-binding-per-iteration-for-of.js
for
let
block-local-closure-get-before-initialization.jsblock-local-closure-set-before-initialization.jsblock-local-use-before-initialization-in-declaration-statement.jsblock-local-use-before-initialization-in-prior-statement.jsfunction-local-closure-get-before-initialization.jsfunction-local-closure-set-before-initialization.jsfunction-local-use-before-initialization-in-declaration-statement.jsfunction-local-use-before-initialization-in-prior-statement.jsglobal-closure-get-before-initialization.jsglobal-closure-set-before-initialization.jsglobal-use-before-initialization-in-declaration-statement.jsglobal-use-before-initialization-in-prior-statement.jsredeclaration-error-from-within-strict-mode-function.js
syntax
attempt-to-redeclare-let-binding-with-function-declaration.jsattempt-to-redeclare-let-binding-with-var.jsidentifier-let-allowed-as-lefthandside-expression-non-strict.jsidentifier-let-allowed-as-lefthandside-expression-strict.jsidentifier-let-disallowed-as-boundname.jslet-closure-inside-condition.jslet-closure-inside-initialization.jslet-closure-inside-next-expression.jslet-iteration-variable-is-freshly-allocated-for-each-iteration-multi-let-binding.jslet-iteration-variable-is-freshly-allocated-for-each-iteration-single-let-binding.jslet-outer-inner-let-bindings.jslet.jswith-initialisers-in-statement-positions-case-expression-statement-list.jswith-initialisers-in-statement-positions-default-statement-list.jswith-initialisers-in-statement-positions-do-statement-while-expression.jswith-initialisers-in-statement-positions-for-statement.jswith-initialisers-in-statement-positions-if-expression-statement-else-statement.jswith-initialisers-in-statement-positions-if-expression-statement.jswith-initialisers-in-statement-positions-label-statement.jswith-initialisers-in-statement-positions-while-expression-statement.jswithout-initialisers-in-statement-positions-case-expression-statement-list.jswithout-initialisers-in-statement-positions-default-statement-list.jswithout-initialisers-in-statement-positions-do-statement-while-expression.jswithout-initialisers-in-statement-positions-for-statement.jswithout-initialisers-in-statement-positions-if-expression-statement-else-statement.jswithout-initialisers-in-statement-positions-if-expression-statement.jswithout-initialisers-in-statement-positions-label-statement.jswithout-initialisers-in-statement-positions-while-expression-statement.js
|
@ -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