Skip to content
Snippets Groups Projects
Commit 93d994df authored by Mike Pennisi's avatar Mike Pennisi
Browse files

Import tests from Google V8 (generator syntax)

These tests are derived from the following files within the Google V8
project:

    test/mjsunit/es6/generators-parsing.js
parent 2df6c4f2
Branches
No related tags found
No related merge requests found
Showing
with 264 additions and 0 deletions
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` is a reserved identifier in strict mode code and may not be used
as an identifier.
es6id: 12.1.1
negative: SyntaxError
flags: [onlyStrict]
---*/
var yield = 13;
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` may be used as a literal property name in an object literal.
es6id: 12.1.1
---*/
({ yield: 1 });
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` is not a reserved identifier in non-strict mode code and may be
used as a label.
es6id: 12.1.1
flags: [noStrict]
---*/
yield: 1;
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` is a reserved identifier in strict mode code and may not be used
as a label.
es6id: 12.1.1
negative: SyntaxError
flags: [onlyStrict]
---*/
yield: 1;
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Generators declared with GeneratorDeclaration syntax do not require a
`yield` expression.
es6id: 14.4
---*/
function *foo(a) {}
var g = foo(3);
assert.sameValue(g.next().value, undefined);
assert.sameValue(g.next().done, true);
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`return` is a valid statement within generator function bodies.
es6id: 14.4
---*/
function* g() { return; }
function* g() { return 1; }
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` is a reserved keyword within generator function bodies and may
not be used as a binding identifier.
es6id: 12.1.1
negative: SyntaxError
---*/
function* g() {
yield = 1;
}
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` is a valid expression within generator function bodies.
es6id: 14.4
---*/
function* g() { (yield 1) }
function* g() { [yield 1] }
function* g() { {yield 1} }
function* g() { yield 1, yield 1; }
function* g() { (yield 1) ? yield 1 : yield 1 }
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` is a valid expression within generator function bodies.
es6id: 14.4
---*/
function* g() { (yield) }
function* g() { [yield] }
function* g() { {yield} }
function* g() { yield, yield; }
function* g() { (yield) ? yield : yield }
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` may be used as the binding identifier of a function expression
within generator bodies.
es6id: 14.1
flags: [noStrict]
---*/
function* g() {
(function yield() {})
}
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` is a valid BindingIdentifier for GeneratorDeclarations outside of
strict mode.
es6id: 12.1.1
flags: [noStrict]
---*/
function* yield() { (yield 3) + (yield 4); }
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` is not a reserved keyword within normal function bodies declared
within generator function bodies.
es6id: 12.1.1
flags: [noStrict]
---*/
function* g() {
function h() {
yield = 1;
}
}
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` is a reserved keyword within generator function bodies and may
not be used as a label.
es6id: 12.1.1
negative: SyntaxError
---*/
function* g() {
yield: 1;
}
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` may be used as a literal property name in an object literal
within generator function bodies.
es6id: 12.1.1
---*/
function* g() {
({ get yield() { return 1 } });
}
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` expressions are not LogicalOrExpressions.
es6id: 12.1.1
negative: SyntaxError
---*/
function* g() {
yield ? yield : yield
}
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` is a reserved keyword within generator function bodies and may
not be used as the binding identifier of a parameter.
es6id: 12.1.1
negative: SyntaxError
---*/
function* g(yield) {}
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` may be used as a literal property name in an object literal
within generator function bodies.
es6id: 12.1.1
---*/
function* g() {
({ yield: 1 });
}
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` is a valid statement within generator function bodies.
es6id: 14.4
---*/
function* g() { yield; }
function* g() { yield 1; }
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` expressions may be used as the right-hand-side of other `yield`
expressions.
es6id: 14.4
---*/
function* g() {
yield yield 1;
}
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Newlines terminate `yield` expressions.
es6id: 14.4
---*/
function* g() {
yield
1
}
assert.sameValue(g().next().value, undefined);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment