Add additional tests

This commit is contained in:
Anders Hejlsberg 2016-10-13 09:44:50 -07:00
parent 620b3f91e1
commit a27a68f8eb
4 changed files with 158 additions and 0 deletions

View file

@ -155,6 +155,22 @@ function f16() {
(x.push("hello"), x).push(true);
((x))[3] = { a: 1 };
return x; // (string | number | boolean | { a: number })[]
}
function f17() {
let x = [];
x.unshift(5);
x.unshift("hello");
x.unshift(true);
return x; // (string | number | boolean)[]
}
function f18() {
let x = [];
x.push(5);
x.unshift("hello");
x[2] = true;
return x; // (string | number | boolean)[]
}
//// [controlFlowArrays.js]
@ -299,3 +315,17 @@ function f16() {
((x))[3] = { a: 1 };
return x; // (string | number | boolean | { a: number })[]
}
function f17() {
var x = [];
x.unshift(5);
x.unshift("hello");
x.unshift(true);
return x; // (string | number | boolean)[]
}
function f18() {
var x = [];
x.push(5);
x.unshift("hello");
x[2] = true;
return x; // (string | number | boolean)[]
}

View file

@ -400,3 +400,51 @@ function f16() {
return x; // (string | number | boolean | { a: number })[]
>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7))
}
function f17() {
>f17 : Symbol(f17, Decl(controlFlowArrays.ts, 156, 1))
let x = [];
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
x.unshift(5);
>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
x.unshift("hello");
>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
x.unshift(true);
>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
return x; // (string | number | boolean)[]
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
}
function f18() {
>f18 : Symbol(f18, Decl(controlFlowArrays.ts, 164, 1))
let x = [];
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
x.push(5);
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
x.unshift("hello");
>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
x[2] = true;
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
return x; // (string | number | boolean)[]
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
}

View file

@ -521,3 +521,67 @@ function f16() {
return x; // (string | number | boolean | { a: number })[]
>x : (string | number | boolean | { a: number; })[]
}
function f17() {
>f17 : () => (string | number | boolean)[]
let x = [];
>x : any[]
>[] : never[]
x.unshift(5);
>x.unshift(5) : number
>x.unshift : (...items: any[]) => number
>x : any[]
>unshift : (...items: any[]) => number
>5 : 5
x.unshift("hello");
>x.unshift("hello") : number
>x.unshift : (...items: any[]) => number
>x : any[]
>unshift : (...items: any[]) => number
>"hello" : "hello"
x.unshift(true);
>x.unshift(true) : number
>x.unshift : (...items: any[]) => number
>x : any[]
>unshift : (...items: any[]) => number
>true : true
return x; // (string | number | boolean)[]
>x : (string | number | boolean)[]
}
function f18() {
>f18 : () => (string | number | boolean)[]
let x = [];
>x : any[]
>[] : never[]
x.push(5);
>x.push(5) : number
>x.push : (...items: any[]) => number
>x : any[]
>push : (...items: any[]) => number
>5 : 5
x.unshift("hello");
>x.unshift("hello") : number
>x.unshift : (...items: any[]) => number
>x : any[]
>unshift : (...items: any[]) => number
>"hello" : "hello"
x[2] = true;
>x[2] = true : true
>x[2] : any
>x : any[]
>2 : 2
>true : true
return x; // (string | number | boolean)[]
>x : (string | number | boolean)[]
}

View file

@ -156,4 +156,20 @@ function f16() {
(x.push("hello"), x).push(true);
((x))[3] = { a: 1 };
return x; // (string | number | boolean | { a: number })[]
}
function f17() {
let x = [];
x.unshift(5);
x.unshift("hello");
x.unshift(true);
return x; // (string | number | boolean)[]
}
function f18() {
let x = [];
x.push(5);
x.unshift("hello");
x[2] = true;
return x; // (string | number | boolean)[]
}