Corrects old tests.

This commit is contained in:
Tingan Ho 2015-05-13 09:53:34 +08:00
parent d13081685b
commit a97ea4b657
10 changed files with 431 additions and 115 deletions

View File

@ -1,59 +0,0 @@
tests/cases/conformance/expressions/functionCalls/callWithSpread.ts(52,21): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher.
==== tests/cases/conformance/expressions/functionCalls/callWithSpread.ts (1 errors) ====
interface X {
foo(x: number, y: number, ...z: string[]);
}
function foo(x: number, y: number, ...z: string[]) {
}
var a: string[];
var z: number[];
var obj: X;
var xa: X[];
foo(1, 2, "abc");
foo(1, 2, ...a);
foo(1, 2, ...a, "abc");
obj.foo(1, 2, "abc");
obj.foo(1, 2, ...a);
obj.foo(1, 2, ...a, "abc");
(obj.foo)(1, 2, "abc");
(obj.foo)(1, 2, ...a);
(obj.foo)(1, 2, ...a, "abc");
xa[1].foo(1, 2, "abc");
xa[1].foo(1, 2, ...a);
xa[1].foo(1, 2, ...a, "abc");
(<Function>xa[1].foo)(...[1, 2, "abc"]);
class C {
constructor(x: number, y: number, ...z: string[]) {
this.foo(x, y);
this.foo(x, y, ...z);
}
foo(x: number, y: number, ...z: string[]) {
}
}
class D extends C {
constructor() {
super(1, 2);
super(1, 2, ...a);
}
foo() {
super.foo(1, 2);
super.foo(1, 2, ...a);
}
}
// Only supported in when target is ES6
var c = new C(1, 2, ...a);
~~~~
!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher.

View File

@ -48,9 +48,6 @@ class D extends C {
super.foo(1, 2, ...a);
}
}
// Only supported in when target is ES6
var c = new C(1, 2, ...a);
//// [callWithSpread.js]
@ -112,6 +109,4 @@ var D = (function (_super) {
};
return D;
})(C);
// Only supported in when target is ES6
var c = new C(1, 2, ...a);
var _a, _b, _c;

View File

@ -0,0 +1,159 @@
=== tests/cases/conformance/expressions/functionCalls/callWithSpread.ts ===
interface X {
>X : Symbol(X, Decl(callWithSpread.ts, 0, 0))
foo(x: number, y: number, ...z: string[]);
>foo : Symbol(foo, Decl(callWithSpread.ts, 0, 13))
>x : Symbol(x, Decl(callWithSpread.ts, 1, 8))
>y : Symbol(y, Decl(callWithSpread.ts, 1, 18))
>z : Symbol(z, Decl(callWithSpread.ts, 1, 29))
}
function foo(x: number, y: number, ...z: string[]) {
>foo : Symbol(foo, Decl(callWithSpread.ts, 2, 1))
>x : Symbol(x, Decl(callWithSpread.ts, 4, 13))
>y : Symbol(y, Decl(callWithSpread.ts, 4, 23))
>z : Symbol(z, Decl(callWithSpread.ts, 4, 34))
}
var a: string[];
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
var z: number[];
>z : Symbol(z, Decl(callWithSpread.ts, 8, 3))
var obj: X;
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>X : Symbol(X, Decl(callWithSpread.ts, 0, 0))
var xa: X[];
>xa : Symbol(xa, Decl(callWithSpread.ts, 10, 3))
>X : Symbol(X, Decl(callWithSpread.ts, 0, 0))
foo(1, 2, "abc");
>foo : Symbol(foo, Decl(callWithSpread.ts, 2, 1))
foo(1, 2, ...a);
>foo : Symbol(foo, Decl(callWithSpread.ts, 2, 1))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
foo(1, 2, ...a, "abc");
>foo : Symbol(foo, Decl(callWithSpread.ts, 2, 1))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
obj.foo(1, 2, "abc");
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
obj.foo(1, 2, ...a);
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
obj.foo(1, 2, ...a, "abc");
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
(obj.foo)(1, 2, "abc");
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
(obj.foo)(1, 2, ...a);
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
(obj.foo)(1, 2, ...a, "abc");
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
xa[1].foo(1, 2, "abc");
>xa[1].foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>xa : Symbol(xa, Decl(callWithSpread.ts, 10, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
xa[1].foo(1, 2, ...a);
>xa[1].foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>xa : Symbol(xa, Decl(callWithSpread.ts, 10, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
xa[1].foo(1, 2, ...a, "abc");
>xa[1].foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>xa : Symbol(xa, Decl(callWithSpread.ts, 10, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
(<Function>xa[1].foo)(...[1, 2, "abc"]);
>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11))
>xa[1].foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>xa : Symbol(xa, Decl(callWithSpread.ts, 10, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
class C {
>C : Symbol(C, Decl(callWithSpread.ts, 28, 40))
constructor(x: number, y: number, ...z: string[]) {
>x : Symbol(x, Decl(callWithSpread.ts, 31, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 31, 26))
>z : Symbol(z, Decl(callWithSpread.ts, 31, 37))
this.foo(x, y);
>this.foo : Symbol(foo, Decl(callWithSpread.ts, 34, 5))
>this : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>foo : Symbol(foo, Decl(callWithSpread.ts, 34, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 31, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 31, 26))
this.foo(x, y, ...z);
>this.foo : Symbol(foo, Decl(callWithSpread.ts, 34, 5))
>this : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>foo : Symbol(foo, Decl(callWithSpread.ts, 34, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 31, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 31, 26))
>z : Symbol(z, Decl(callWithSpread.ts, 31, 37))
}
foo(x: number, y: number, ...z: string[]) {
>foo : Symbol(foo, Decl(callWithSpread.ts, 34, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 35, 8))
>y : Symbol(y, Decl(callWithSpread.ts, 35, 18))
>z : Symbol(z, Decl(callWithSpread.ts, 35, 29))
}
}
class D extends C {
>D : Symbol(D, Decl(callWithSpread.ts, 37, 1))
>C : Symbol(C, Decl(callWithSpread.ts, 28, 40))
constructor() {
super(1, 2);
>super : Symbol(C, Decl(callWithSpread.ts, 28, 40))
super(1, 2, ...a);
>super : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
}
foo() {
>foo : Symbol(foo, Decl(callWithSpread.ts, 43, 5))
super.foo(1, 2);
>super.foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>super : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
super.foo(1, 2, ...a);
>super.foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>super : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
}
}

View File

@ -0,0 +1,247 @@
=== tests/cases/conformance/expressions/functionCalls/callWithSpread.ts ===
interface X {
>X : X
foo(x: number, y: number, ...z: string[]);
>foo : (x: number, y: number, ...z: string[]) => any
>x : number
>y : number
>z : string[]
}
function foo(x: number, y: number, ...z: string[]) {
>foo : (x: number, y: number, ...z: string[]) => void
>x : number
>y : number
>z : string[]
}
var a: string[];
>a : string[]
var z: number[];
>z : number[]
var obj: X;
>obj : X
>X : X
var xa: X[];
>xa : X[]
>X : X
foo(1, 2, "abc");
>foo(1, 2, "abc") : void
>foo : (x: number, y: number, ...z: string[]) => void
>1 : number
>2 : number
>"abc" : string
foo(1, 2, ...a);
>foo(1, 2, ...a) : void
>foo : (x: number, y: number, ...z: string[]) => void
>1 : number
>2 : number
>...a : string
>a : string[]
foo(1, 2, ...a, "abc");
>foo(1, 2, ...a, "abc") : void
>foo : (x: number, y: number, ...z: string[]) => void
>1 : number
>2 : number
>...a : string
>a : string[]
>"abc" : string
obj.foo(1, 2, "abc");
>obj.foo(1, 2, "abc") : any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>1 : number
>2 : number
>"abc" : string
obj.foo(1, 2, ...a);
>obj.foo(1, 2, ...a) : any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>1 : number
>2 : number
>...a : string
>a : string[]
obj.foo(1, 2, ...a, "abc");
>obj.foo(1, 2, ...a, "abc") : any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>1 : number
>2 : number
>...a : string
>a : string[]
>"abc" : string
(obj.foo)(1, 2, "abc");
>(obj.foo)(1, 2, "abc") : any
>(obj.foo) : (x: number, y: number, ...z: string[]) => any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>1 : number
>2 : number
>"abc" : string
(obj.foo)(1, 2, ...a);
>(obj.foo)(1, 2, ...a) : any
>(obj.foo) : (x: number, y: number, ...z: string[]) => any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>1 : number
>2 : number
>...a : string
>a : string[]
(obj.foo)(1, 2, ...a, "abc");
>(obj.foo)(1, 2, ...a, "abc") : any
>(obj.foo) : (x: number, y: number, ...z: string[]) => any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>1 : number
>2 : number
>...a : string
>a : string[]
>"abc" : string
xa[1].foo(1, 2, "abc");
>xa[1].foo(1, 2, "abc") : any
>xa[1].foo : (x: number, y: number, ...z: string[]) => any
>xa[1] : X
>xa : X[]
>1 : number
>foo : (x: number, y: number, ...z: string[]) => any
>1 : number
>2 : number
>"abc" : string
xa[1].foo(1, 2, ...a);
>xa[1].foo(1, 2, ...a) : any
>xa[1].foo : (x: number, y: number, ...z: string[]) => any
>xa[1] : X
>xa : X[]
>1 : number
>foo : (x: number, y: number, ...z: string[]) => any
>1 : number
>2 : number
>...a : string
>a : string[]
xa[1].foo(1, 2, ...a, "abc");
>xa[1].foo(1, 2, ...a, "abc") : any
>xa[1].foo : (x: number, y: number, ...z: string[]) => any
>xa[1] : X
>xa : X[]
>1 : number
>foo : (x: number, y: number, ...z: string[]) => any
>1 : number
>2 : number
>...a : string
>a : string[]
>"abc" : string
(<Function>xa[1].foo)(...[1, 2, "abc"]);
>(<Function>xa[1].foo)(...[1, 2, "abc"]) : any
>(<Function>xa[1].foo) : Function
><Function>xa[1].foo : Function
>Function : Function
>xa[1].foo : (x: number, y: number, ...z: string[]) => any
>xa[1] : X
>xa : X[]
>1 : number
>foo : (x: number, y: number, ...z: string[]) => any
>...[1, 2, "abc"] : string | number
>[1, 2, "abc"] : (string | number)[]
>1 : number
>2 : number
>"abc" : string
class C {
>C : C
constructor(x: number, y: number, ...z: string[]) {
>x : number
>y : number
>z : string[]
this.foo(x, y);
>this.foo(x, y) : void
>this.foo : (x: number, y: number, ...z: string[]) => void
>this : C
>foo : (x: number, y: number, ...z: string[]) => void
>x : number
>y : number
this.foo(x, y, ...z);
>this.foo(x, y, ...z) : void
>this.foo : (x: number, y: number, ...z: string[]) => void
>this : C
>foo : (x: number, y: number, ...z: string[]) => void
>x : number
>y : number
>...z : string
>z : string[]
}
foo(x: number, y: number, ...z: string[]) {
>foo : (x: number, y: number, ...z: string[]) => void
>x : number
>y : number
>z : string[]
}
}
class D extends C {
>D : D
>C : C
constructor() {
super(1, 2);
>super(1, 2) : void
>super : typeof C
>1 : number
>2 : number
super(1, 2, ...a);
>super(1, 2, ...a) : void
>super : typeof C
>1 : number
>2 : number
>...a : string
>a : string[]
}
foo() {
>foo : () => void
super.foo(1, 2);
>super.foo(1, 2) : void
>super.foo : (x: number, y: number, ...z: string[]) => void
>super : C
>foo : (x: number, y: number, ...z: string[]) => void
>1 : number
>2 : number
super.foo(1, 2, ...a);
>super.foo(1, 2, ...a) : void
>super.foo : (x: number, y: number, ...z: string[]) => void
>super : C
>foo : (x: number, y: number, ...z: string[]) => void
>1 : number
>2 : number
>...a : string
>a : string[]
}
}

View File

@ -49,9 +49,6 @@ class D extends C {
super.foo(1, 2, ...a);
}
}
// Only supported in when target is ES6
var c = new C(1, 2, ...a);
//// [callWithSpreadES6.js]
@ -92,5 +89,3 @@ class D extends C {
super.foo(1, 2, ...a);
}
}
// Only supported in when target is ES6
var c = new C(1, 2, ...a);

View File

@ -158,9 +158,3 @@ class D extends C {
}
}
// Only supported in when target is ES6
var c = new C(1, 2, ...a);
>c : Symbol(c, Decl(callWithSpreadES6.ts, 52, 3))
>C : Symbol(C, Decl(callWithSpreadES6.ts, 29, 40))
>a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3))

View File

@ -246,13 +246,3 @@ class D extends C {
}
}
// Only supported in when target is ES6
var c = new C(1, 2, ...a);
>c : C
>new C(1, 2, ...a) : C
>C : typeof C
>1 : number
>2 : number
>...a : string
>a : string[]

View File

@ -116,49 +116,50 @@ var h;
var i;
// Basic expression
new f(1, 2, "string");
new (Function.bind.apply(f, [void 0].concat([1, 2].concat(a))));
new (Function.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"]))));
new (f.bind.apply(f, [void 0].concat([1, 2].concat(a))));
new (f.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"]))));
// Call expression
new f(1, 2, "string")();
new (Function.bind.apply(f, [void 0].concat([1, 2].concat(a))))();
new (Function.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"]))))();
new (f.bind.apply(f, [void 0].concat([1, 2].concat(a))))()();
new (f.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"]))))()();
// Property access expression
new b.f(1, 2, "string");
new (Function.bind.apply(b.f, [void 0].concat([1, 2].concat(a))));
new (Function.bind.apply(b.f, [void 0].concat([1, 2].concat(a, ["string"]))));
new ((_a = b.f).bind.apply(_a, [void 0].concat([1, 2].concat(a))));
new ((_b = b.f).bind.apply(_b, [void 0].concat([1, 2].concat(a, ["string"]))));
// Parenthesised expression
new (b.f)(1, 2, "string");
new (Function.bind.apply((b.f), [void 0].concat([1, 2].concat(a))));
new (Function.bind.apply((b.f), [void 0].concat([1, 2].concat(a, ["string"]))));
new ((_c = (b.f)).bind.apply(_c, [void 0].concat([1, 2].concat(a))));
new ((_d = (b.f)).bind.apply(_d, [void 0].concat([1, 2].concat(a, ["string"]))));
// Element access expression
new d[1].f(1, 2, "string");
new (Function.bind.apply(d[1].f, [void 0].concat([1, 2].concat(a))));
new (Function.bind.apply(d[1].f, [void 0].concat([1, 2].concat(a, ["string"]))));
new ((_e = d[1].f).bind.apply(_e, [void 0].concat([1, 2].concat(a))));
new ((_f = d[1].f).bind.apply(_f, [void 0].concat([1, 2].concat(a, ["string"]))));
// Element access expression with a punctuated key
new e["a-b"].f(1, 2, "string");
new (Function.bind.apply(e["a-b"].f, [void 0].concat([1, 2].concat(a))));
new (Function.bind.apply(e["a-b"].f, [void 0].concat([1, 2].concat(a, ["string"]))));
new ((_g = e["a-b"].f).bind.apply(_g, [void 0].concat([1, 2].concat(a))));
new ((_h = e["a-b"].f).bind.apply(_h, [void 0].concat([1, 2].concat(a, ["string"]))));
// Basic expression
new B(1, 2, "string");
new (Function.bind.apply(B, [void 0].concat([1, 2].concat(a))));
new (Function.bind.apply(B, [void 0].concat([1, 2].concat(a, ["string"]))));
new (B.bind.apply(B, [void 0].concat([1, 2].concat(a))));
new (B.bind.apply(B, [void 0].concat([1, 2].concat(a, ["string"]))));
// Property access expression
new c["a-b"](1, 2, "string");
new (Function.bind.apply(c["a-b"], [void 0].concat([1, 2].concat(a))));
new (Function.bind.apply(c["a-b"], [void 0].concat([1, 2].concat(a, ["string"]))));
new ((_j = c["a-b"]).bind.apply(_j, [void 0].concat([1, 2].concat(a))));
new ((_k = c["a-b"]).bind.apply(_k, [void 0].concat([1, 2].concat(a, ["string"]))));
// Parenthesised expression
new (c["a-b"])(1, 2, "string");
new (Function.bind.apply((c["a-b"]), [void 0].concat([1, 2].concat(a))));
new (Function.bind.apply((c["a-b"]), [void 0].concat([1, 2].concat(a, ["string"]))));
new ((_l = (c["a-b"])).bind.apply(_l, [void 0].concat([1, 2].concat(a))));
new ((_m = (c["a-b"])).bind.apply(_m, [void 0].concat([1, 2].concat(a, ["string"]))));
// Element access expression
new g[1]["a-b"](1, 2, "string");
new (Function.bind.apply(g[1]["a-b"], [void 0].concat([1, 2].concat(a))));
new (Function.bind.apply(g[1]["a-b"], [void 0].concat([1, 2].concat(a, ["string"]))));
new ((_o = g[1]["a-b"]).bind.apply(_o, [void 0].concat([1, 2].concat(a))));
new ((_p = g[1]["a-b"]).bind.apply(_p, [void 0].concat([1, 2].concat(a, ["string"]))));
// Element access expression with a punctuated key
new h["a-b"]["a-b"](1, 2, "string");
new (Function.bind.apply(h["a-b"]["a-b"], [void 0].concat([1, 2].concat(a))));
new (Function.bind.apply(h["a-b"]["a-b"], [void 0].concat([1, 2].concat(a, ["string"]))));
new ((_q = h["a-b"]["a-b"]).bind.apply(_q, [void 0].concat([1, 2].concat(a))));
new ((_r = h["a-b"]["a-b"]).bind.apply(_r, [void 0].concat([1, 2].concat(a, ["string"]))));
// Element access expression with a number
new i["a-b"][1](1, 2, "string");
new (Function.bind.apply(i["a-b"][1], [void 0].concat([1, 2].concat(a))));
new (Function.bind.apply(i["a-b"][1], [void 0].concat([1, 2].concat(a, ["string"]))));
new ((_s = i["a-b"][1]).bind.apply(_s, [void 0].concat([1, 2].concat(a))));
new ((_t = i["a-b"][1]).bind.apply(_t, [void 0].concat([1, 2].concat(a, ["string"]))));
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;

View File

@ -47,6 +47,3 @@ class D extends C {
super.foo(1, 2, ...a);
}
}
// Only supported in when target is ES6
var c = new C(1, 2, ...a);

View File

@ -49,6 +49,3 @@ class D extends C {
super.foo(1, 2, ...a);
}
}
// Only supported in when target is ES6
var c = new C(1, 2, ...a);