Parser tests for generators and yield expressions.

This commit is contained in:
Cyrus Najmabadi
2014-11-24 22:40:54 -08:00
parent 7e1a62a8c2
commit 78cd1b5f7e
69 changed files with 165 additions and 1 deletions

View File

@@ -0,0 +1 @@
var v = { [e] };

View File

@@ -0,0 +1,3 @@
class C {
[e] = 1
}

View File

@@ -0,0 +1,3 @@
class C {
[e]();
}

View File

@@ -0,0 +1,3 @@
class C {
[e]() { }
}

View File

@@ -0,0 +1 @@
var v: { [e]: number };

View File

@@ -0,0 +1 @@
var v: { [e](): number };

View File

@@ -0,0 +1 @@
var v: { [e: number]: string; [e]: number };

View File

@@ -0,0 +1,3 @@
enum E {
[e] = 1
}

View File

@@ -0,0 +1 @@
var v = { set [e](v) { } }

View File

@@ -0,0 +1 @@
var v: { [e]?(): number };

View File

@@ -0,0 +1 @@
var v: { [e]? };

View File

@@ -0,0 +1 @@
var v = { [e]: 1 };

View File

@@ -0,0 +1 @@
var v = { [e]() { } };

View File

@@ -0,0 +1 @@
var v = { get [e]() { } };

View File

@@ -0,0 +1 @@
var v = { public get [e]() { } };

View File

@@ -0,0 +1 @@
var v = { [e]: 1, [e + e]: 2 };

View File

@@ -0,0 +1,3 @@
class C {
[e]
}

View File

@@ -0,0 +1,3 @@
class C {
public [e]
}

View File

@@ -0,0 +1,3 @@
class C {
[e]: Type
}

View File

@@ -0,0 +1,3 @@
class C {
*foo() { }
}

View File

@@ -0,0 +1,3 @@
class C {
public * foo() { }
}

View File

@@ -0,0 +1,3 @@
class C {
*[foo]() { }
}

View File

@@ -0,0 +1,3 @@
class C {
*() { }
}

View File

@@ -0,0 +1,3 @@
class C {
*
}

View File

@@ -0,0 +1,3 @@
class C {
*foo
}

View File

@@ -0,0 +1,3 @@
class C {
*foo<T>() { }
}

View File

@@ -0,0 +1,7 @@
class C {
foo() {
// Make sure we don't think of *bar as the start of a generator method.
if (a) # * bar;
return bar;
}
}

View File

@@ -0,0 +1,2 @@
function * foo() {
}

View File

@@ -0,0 +1,2 @@
function * foo(a = yield => yield) {
}

View File

@@ -0,0 +1,2 @@
function * yield() {
}

View File

@@ -0,0 +1 @@
var v = function * yield() { }

View File

@@ -0,0 +1,4 @@
function * foo() {
// Legal to use 'yield' in a type context.
var v: yield;
}

View File

@@ -0,0 +1,2 @@
function f(yield) {
}

View File

@@ -0,0 +1,2 @@
function f(yield = yield) {
}

View File

@@ -0,0 +1,2 @@
function yield() {
}

View File

@@ -0,0 +1,2 @@
function*foo(yield) {
}

View File

@@ -0,0 +1,2 @@
function*foo(a = yield) {
}

View File

@@ -0,0 +1,5 @@
function*bar() {
// 'yield' here is an identifier, and not a yield expression.
function*foo(a = yield) {
}
}

View File

@@ -0,0 +1 @@
var v = { [yield]: foo }

View File

@@ -0,0 +1,3 @@
function * foo() {
var v = { [yield]: foo }
}

View File

@@ -0,0 +1 @@
var v = function * () { }

View File

@@ -0,0 +1 @@
var v = function * foo() { }

View File

@@ -0,0 +1 @@
var v = { *foo() { } }

View File

@@ -0,0 +1 @@
var v = { *() { } }

View File

@@ -0,0 +1 @@
var v = { *{ } }

View File

@@ -0,0 +1 @@
var v = { *[foo()]() { } }

View File

@@ -0,0 +1 @@
var v = { *<T>() { } }

View File

@@ -0,0 +1 @@
var v = `foo ${ a

View File

@@ -1,4 +1,4 @@
function* gen {
function* gen() {
// Once this is supported, the inner expression does not need to be parenthesized.
var x = yield `abc${ x }def`;
}

View File

@@ -0,0 +1 @@
yield;

View File

@@ -0,0 +1,4 @@
var v = { * foo() {
yield(foo);
}
}

View File

@@ -0,0 +1,5 @@
class C {
*foo() {
yield(foo);
}
}

View File

@@ -0,0 +1,5 @@
class C {
constructor() {
yield foo
}
}

View File

@@ -0,0 +1 @@
function* foo() { yield }

View File

@@ -0,0 +1,5 @@
class C {
foo() {
yield foo
}
}

View File

@@ -0,0 +1,3 @@
var v = () => {
yield foo
}

View File

@@ -0,0 +1,5 @@
function* foo() {
function bar() {
yield foo;
}
}

View File

@@ -0,0 +1 @@
var v = { get foo() { yield foo; } }

View File

@@ -0,0 +1,2 @@
"use strict";
yield(foo);

View File

@@ -0,0 +1,7 @@
function*foo() {
function bar() {
function* quux() {
yield(foo);
}
}
}

View File

@@ -0,0 +1 @@
yield foo;

View File

@@ -0,0 +1,4 @@
function* foo() {
yield
yield
}

View File

@@ -0,0 +1,4 @@
function* foo() {
yield;
yield;
}

View File

@@ -0,0 +1,3 @@
function* foo() {
yield*
}

View File

@@ -0,0 +1,3 @@
function* foo() {
yield*foo
}

View File

@@ -0,0 +1,3 @@
function* foo() {
yield foo
}

View File

@@ -0,0 +1,4 @@
yield(foo);
function* foo() {
yield(foo);
}

View File

@@ -0,0 +1,3 @@
var v = function*() {
yield(foo);
}