Skip to content

Commit

Permalink
even more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KiaraGrouwstra committed Aug 16, 2017
1 parent 6b1af9b commit c3f8904
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 16 deletions.
5 changes: 5 additions & 0 deletions tests/baselines/reference/dontWiden.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const d = { a: 1, b: 'c' };

interface SomeInterface { a: boolean }
declare function foo<T extends any[]>(arg: T): { hi: T };
declare function boo<T extends number[]>(arg: T): { hi: T };
declare function bar(arg: SomeInterface): void
declare function baz(arg: [number, 2, 3 | number]): void
declare function bag(arg: number[]): void
Expand All @@ -19,6 +20,8 @@ bar({a: true});
baz([1, 2, 3]);
bag([1, 2, 3]);
bag(e);
boo([1, 2, 3]);
boo(e);


//// [dontWiden.js]
Expand All @@ -34,3 +37,5 @@ bar({ a: true });
baz([1, 2, 3]);
bag([1, 2, 3]);
bag(e);
boo([1, 2, 3]);
boo(e);
47 changes: 31 additions & 16 deletions tests/baselines/reference/dontWiden.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -19,46 +19,61 @@ declare function foo<T extends any[]>(arg: T): { hi: T };
>hi : Symbol(hi, Decl(dontWiden.ts, 4, 48))
>T : Symbol(T, Decl(dontWiden.ts, 4, 21))

declare function boo<T extends number[]>(arg: T): { hi: T };
>boo : Symbol(boo, Decl(dontWiden.ts, 4, 57))
>T : Symbol(T, Decl(dontWiden.ts, 5, 21))
>arg : Symbol(arg, Decl(dontWiden.ts, 5, 41))
>T : Symbol(T, Decl(dontWiden.ts, 5, 21))
>hi : Symbol(hi, Decl(dontWiden.ts, 5, 51))
>T : Symbol(T, Decl(dontWiden.ts, 5, 21))

declare function bar(arg: SomeInterface): void
>bar : Symbol(bar, Decl(dontWiden.ts, 4, 57))
>arg : Symbol(arg, Decl(dontWiden.ts, 5, 21))
>bar : Symbol(bar, Decl(dontWiden.ts, 5, 60))
>arg : Symbol(arg, Decl(dontWiden.ts, 6, 21))
>SomeInterface : Symbol(SomeInterface, Decl(dontWiden.ts, 1, 27))

declare function baz(arg: [number, 2, 3 | number]): void
>baz : Symbol(baz, Decl(dontWiden.ts, 5, 46))
>arg : Symbol(arg, Decl(dontWiden.ts, 6, 21))
>baz : Symbol(baz, Decl(dontWiden.ts, 6, 46))
>arg : Symbol(arg, Decl(dontWiden.ts, 7, 21))

declare function bag(arg: number[]): void
>bag : Symbol(bag, Decl(dontWiden.ts, 6, 56))
>arg : Symbol(arg, Decl(dontWiden.ts, 7, 21))
>bag : Symbol(bag, Decl(dontWiden.ts, 7, 56))
>arg : Symbol(arg, Decl(dontWiden.ts, 8, 21))

// As variable assignees
const a: number[] = [1, 2, 3];
>a : Symbol(a, Decl(dontWiden.ts, 10, 5))
>a : Symbol(a, Decl(dontWiden.ts, 11, 5))

const b: SomeInterface = {a: true};
>b : Symbol(b, Decl(dontWiden.ts, 11, 5))
>b : Symbol(b, Decl(dontWiden.ts, 12, 5))
>SomeInterface : Symbol(SomeInterface, Decl(dontWiden.ts, 1, 27))
>a : Symbol(a, Decl(dontWiden.ts, 11, 26))
>a : Symbol(a, Decl(dontWiden.ts, 12, 26))

const e = [1, 2, 3];
>e : Symbol(e, Decl(dontWiden.ts, 12, 5))
>e : Symbol(e, Decl(dontWiden.ts, 13, 5))

// Same, but as arguments
foo([1, 2, 3]);
>foo : Symbol(foo, Decl(dontWiden.ts, 3, 38))

bar({a: true});
>bar : Symbol(bar, Decl(dontWiden.ts, 4, 57))
>a : Symbol(a, Decl(dontWiden.ts, 16, 5))
>bar : Symbol(bar, Decl(dontWiden.ts, 5, 60))
>a : Symbol(a, Decl(dontWiden.ts, 17, 5))

baz([1, 2, 3]);
>baz : Symbol(baz, Decl(dontWiden.ts, 5, 46))
>baz : Symbol(baz, Decl(dontWiden.ts, 6, 46))

bag([1, 2, 3]);
>bag : Symbol(bag, Decl(dontWiden.ts, 6, 56))
>bag : Symbol(bag, Decl(dontWiden.ts, 7, 56))

bag(e);
>bag : Symbol(bag, Decl(dontWiden.ts, 6, 56))
>e : Symbol(e, Decl(dontWiden.ts, 12, 5))
>bag : Symbol(bag, Decl(dontWiden.ts, 7, 56))
>e : Symbol(e, Decl(dontWiden.ts, 13, 5))

boo([1, 2, 3]);
>boo : Symbol(boo, Decl(dontWiden.ts, 4, 57))

boo(e);
>boo : Symbol(boo, Decl(dontWiden.ts, 4, 57))
>e : Symbol(e, Decl(dontWiden.ts, 13, 5))

21 changes: 21 additions & 0 deletions tests/baselines/reference/dontWiden.types
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ declare function foo<T extends any[]>(arg: T): { hi: T };
>hi : T
>T : T

declare function boo<T extends number[]>(arg: T): { hi: T };
>boo : <T extends number[]>(arg: T) => { hi: T; }
>T : T
>arg : T
>T : T
>hi : T
>T : T

declare function bar(arg: SomeInterface): void
>bar : (arg: SomeInterface) => void
>arg : SomeInterface
Expand Down Expand Up @@ -97,3 +105,16 @@ bag(e);
>bag : (arg: number[]) => void
>e : [1, 2, 3]

boo([1, 2, 3]);
>boo([1, 2, 3]) : { hi: [1, 2, 3]; }
>boo : <T extends number[]>(arg: T) => { hi: T; }
>[1, 2, 3] : [1, 2, 3]
>1 : 1
>2 : 2
>3 : 3

boo(e);
>boo(e) : { hi: [1, 2, 3]; }
>boo : <T extends number[]>(arg: T) => { hi: T; }
>e : [1, 2, 3]

3 changes: 3 additions & 0 deletions tests/cases/compiler/dontWiden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const d = { a: 1, b: 'c' };

interface SomeInterface { a: boolean }
declare function foo<T extends any[]>(arg: T): { hi: T };
declare function boo<T extends number[]>(arg: T): { hi: T };
declare function bar(arg: SomeInterface): void
declare function baz(arg: [number, 2, 3 | number]): void
declare function bag(arg: number[]): void
Expand All @@ -20,3 +21,5 @@ bar({a: true});
baz([1, 2, 3]);
bag([1, 2, 3]);
bag(e);
boo([1, 2, 3]);
boo(e);

0 comments on commit c3f8904

Please sign in to comment.