Skip to content

Commit a27a68f

Browse files
committed
Add additional tests
1 parent 620b3f9 commit a27a68f

File tree

4 files changed

+158
-0
lines changed

4 files changed

+158
-0
lines changed

tests/baselines/reference/controlFlowArrays.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,22 @@ function f16() {
155155
(x.push("hello"), x).push(true);
156156
((x))[3] = { a: 1 };
157157
return x; // (string | number | boolean | { a: number })[]
158+
}
159+
160+
function f17() {
161+
let x = [];
162+
x.unshift(5);
163+
x.unshift("hello");
164+
x.unshift(true);
165+
return x; // (string | number | boolean)[]
166+
}
167+
168+
function f18() {
169+
let x = [];
170+
x.push(5);
171+
x.unshift("hello");
172+
x[2] = true;
173+
return x; // (string | number | boolean)[]
158174
}
159175

160176
//// [controlFlowArrays.js]
@@ -299,3 +315,17 @@ function f16() {
299315
((x))[3] = { a: 1 };
300316
return x; // (string | number | boolean | { a: number })[]
301317
}
318+
function f17() {
319+
var x = [];
320+
x.unshift(5);
321+
x.unshift("hello");
322+
x.unshift(true);
323+
return x; // (string | number | boolean)[]
324+
}
325+
function f18() {
326+
var x = [];
327+
x.push(5);
328+
x.unshift("hello");
329+
x[2] = true;
330+
return x; // (string | number | boolean)[]
331+
}

tests/baselines/reference/controlFlowArrays.symbols

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,51 @@ function f16() {
400400
return x; // (string | number | boolean | { a: number })[]
401401
>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7))
402402
}
403+
404+
function f17() {
405+
>f17 : Symbol(f17, Decl(controlFlowArrays.ts, 156, 1))
406+
407+
let x = [];
408+
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
409+
410+
x.unshift(5);
411+
>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
412+
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
413+
>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
414+
415+
x.unshift("hello");
416+
>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
417+
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
418+
>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
419+
420+
x.unshift(true);
421+
>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
422+
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
423+
>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
424+
425+
return x; // (string | number | boolean)[]
426+
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
427+
}
428+
429+
function f18() {
430+
>f18 : Symbol(f18, Decl(controlFlowArrays.ts, 164, 1))
431+
432+
let x = [];
433+
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
434+
435+
x.push(5);
436+
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
437+
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
438+
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
439+
440+
x.unshift("hello");
441+
>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
442+
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
443+
>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
444+
445+
x[2] = true;
446+
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
447+
448+
return x; // (string | number | boolean)[]
449+
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
450+
}

tests/baselines/reference/controlFlowArrays.types

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,3 +521,67 @@ function f16() {
521521
return x; // (string | number | boolean | { a: number })[]
522522
>x : (string | number | boolean | { a: number; })[]
523523
}
524+
525+
function f17() {
526+
>f17 : () => (string | number | boolean)[]
527+
528+
let x = [];
529+
>x : any[]
530+
>[] : never[]
531+
532+
x.unshift(5);
533+
>x.unshift(5) : number
534+
>x.unshift : (...items: any[]) => number
535+
>x : any[]
536+
>unshift : (...items: any[]) => number
537+
>5 : 5
538+
539+
x.unshift("hello");
540+
>x.unshift("hello") : number
541+
>x.unshift : (...items: any[]) => number
542+
>x : any[]
543+
>unshift : (...items: any[]) => number
544+
>"hello" : "hello"
545+
546+
x.unshift(true);
547+
>x.unshift(true) : number
548+
>x.unshift : (...items: any[]) => number
549+
>x : any[]
550+
>unshift : (...items: any[]) => number
551+
>true : true
552+
553+
return x; // (string | number | boolean)[]
554+
>x : (string | number | boolean)[]
555+
}
556+
557+
function f18() {
558+
>f18 : () => (string | number | boolean)[]
559+
560+
let x = [];
561+
>x : any[]
562+
>[] : never[]
563+
564+
x.push(5);
565+
>x.push(5) : number
566+
>x.push : (...items: any[]) => number
567+
>x : any[]
568+
>push : (...items: any[]) => number
569+
>5 : 5
570+
571+
x.unshift("hello");
572+
>x.unshift("hello") : number
573+
>x.unshift : (...items: any[]) => number
574+
>x : any[]
575+
>unshift : (...items: any[]) => number
576+
>"hello" : "hello"
577+
578+
x[2] = true;
579+
>x[2] = true : true
580+
>x[2] : any
581+
>x : any[]
582+
>2 : 2
583+
>true : true
584+
585+
return x; // (string | number | boolean)[]
586+
>x : (string | number | boolean)[]
587+
}

tests/cases/compiler/controlFlowArrays.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,20 @@ function f16() {
156156
(x.push("hello"), x).push(true);
157157
((x))[3] = { a: 1 };
158158
return x; // (string | number | boolean | { a: number })[]
159+
}
160+
161+
function f17() {
162+
let x = [];
163+
x.unshift(5);
164+
x.unshift("hello");
165+
x.unshift(true);
166+
return x; // (string | number | boolean)[]
167+
}
168+
169+
function f18() {
170+
let x = [];
171+
x.push(5);
172+
x.unshift("hello");
173+
x[2] = true;
174+
return x; // (string | number | boolean)[]
159175
}

0 commit comments

Comments
 (0)