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:
Rick Waldron 2015-03-30 12:34:10 -04:00
parent 506f9fe803
commit 44c65fd02a
93 changed files with 302 additions and 3 deletions
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
continue
for-in
for-of
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

View File

@ -5,7 +5,6 @@ es6id: 13.1
description: >
Mixed values in iteration
---*/
"use strict";
function fn(x) {
let a = [];
for (let p in x) {

View File

@ -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; } })

View File

@ -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++) {}

View File

@ -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++ }

View File

@ -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++ }

View File

@ -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`");

View File

@ -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`");

View File

@ -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`");

View File

@ -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`");

View File

@ -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`");

View File

@ -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`");

View File

@ -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`");

View File

@ -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 }) {}

View File

@ -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'`");

View File

@ -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 }) {}

View File

@ -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'`");

View File

@ -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]) {}

View File

@ -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`");

View File

@ -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]) {}

View File

@ -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`");

View File

@ -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`");

View File

@ -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`");

View File

@ -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; } })