Skip to content

Commit 8def2ea

Browse files
committed
Accept baselines
1 parent d85a212 commit 8def2ea

File tree

3 files changed

+134
-24
lines changed

3 files changed

+134
-24
lines changed

tests/baselines/reference/parameterInference.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,26 @@ function subs(s) {
1717
// => (s: string) => number & (s: number) => string
1818

1919
// CASE 3
20-
function f(x: number){
20+
function f3(x: number){
2121
return x;
2222
}
2323

24-
function g(x){ return f(x); };
25-
// => function g(x: number): number
26-
24+
function g3(x){ return f3(x); };
25+
// => function g3(x: number): number
26+
27+
// CASE 4
28+
declare function f4(g: Function)
29+
function g4(x) {
30+
f4(() => {
31+
Math.sqrt(x)
32+
})
33+
}
34+
35+
// CASE 5
36+
function f5(a) {
37+
if (Math.random() > 0.5) Math.round(a)
38+
else (a)
39+
}
2740

2841
//// [parameterInference.js]
2942
// CASE 1
@@ -37,9 +50,20 @@ function subs(s) {
3750
// NOTE: Still broken, needs to deal with overloads. Should have been inferred as:
3851
// => (s: string) => number & (s: number) => string
3952
// CASE 3
40-
function f(x) {
53+
function f3(x) {
4154
return x;
4255
}
43-
function g(x) { return f(x); }
56+
function g3(x) { return f3(x); }
4457
;
45-
// => function g(x: number): number
58+
function g4(x) {
59+
f4(function () {
60+
Math.sqrt(x);
61+
});
62+
}
63+
// CASE 5
64+
function f5(a) {
65+
if (Math.random() > 0.5)
66+
Math.round(a);
67+
else
68+
(a);
69+
}

tests/baselines/reference/parameterInference.symbols

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,58 @@ function subs(s) {
3434
// => (s: string) => number & (s: number) => string
3535

3636
// CASE 3
37-
function f(x: number){
38-
>f : Symbol(f, Decl(parameterInference.ts, 12, 1))
39-
>x : Symbol(x, Decl(parameterInference.ts, 18, 11))
37+
function f3(x: number){
38+
>f3 : Symbol(f3, Decl(parameterInference.ts, 12, 1))
39+
>x : Symbol(x, Decl(parameterInference.ts, 18, 12))
4040

4141
return x;
42-
>x : Symbol(x, Decl(parameterInference.ts, 18, 11))
42+
>x : Symbol(x, Decl(parameterInference.ts, 18, 12))
4343
}
4444

45-
function g(x){ return f(x); };
46-
>g : Symbol(g, Decl(parameterInference.ts, 20, 1))
47-
>x : Symbol(x, Decl(parameterInference.ts, 22, 11))
48-
>f : Symbol(f, Decl(parameterInference.ts, 12, 1))
49-
>x : Symbol(x, Decl(parameterInference.ts, 22, 11))
45+
function g3(x){ return f3(x); };
46+
>g3 : Symbol(g3, Decl(parameterInference.ts, 20, 1))
47+
>x : Symbol(x, Decl(parameterInference.ts, 22, 12))
48+
>f3 : Symbol(f3, Decl(parameterInference.ts, 12, 1))
49+
>x : Symbol(x, Decl(parameterInference.ts, 22, 12))
5050

51-
// => function g(x: number): number
51+
// => function g3(x: number): number
5252

53+
// CASE 4
54+
declare function f4(g: Function)
55+
>f4 : Symbol(f4, Decl(parameterInference.ts, 22, 32))
56+
>g : Symbol(g, Decl(parameterInference.ts, 26, 20))
57+
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
58+
59+
function g4(x) {
60+
>g4 : Symbol(g4, Decl(parameterInference.ts, 26, 32))
61+
>x : Symbol(x, Decl(parameterInference.ts, 27, 12))
62+
63+
f4(() => {
64+
>f4 : Symbol(f4, Decl(parameterInference.ts, 22, 32))
65+
66+
Math.sqrt(x)
67+
>Math.sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, --, --))
68+
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
69+
>sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, --, --))
70+
>x : Symbol(x, Decl(parameterInference.ts, 27, 12))
71+
72+
})
73+
}
74+
75+
// CASE 5
76+
function f5(a) {
77+
>f5 : Symbol(f5, Decl(parameterInference.ts, 31, 1))
78+
>a : Symbol(a, Decl(parameterInference.ts, 34, 12))
79+
80+
if (Math.random() > 0.5) Math.round(a)
81+
>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --))
82+
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
83+
>random : Symbol(Math.random, Decl(lib.d.ts, --, --))
84+
>Math.round : Symbol(Math.round, Decl(lib.d.ts, --, --))
85+
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
86+
>round : Symbol(Math.round, Decl(lib.d.ts, --, --))
87+
>a : Symbol(a, Decl(parameterInference.ts, 34, 12))
88+
89+
else (a)
90+
>a : Symbol(a, Decl(parameterInference.ts, 34, 12))
91+
}

tests/baselines/reference/parameterInference.types

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,67 @@ function subs(s) {
3636
// => (s: string) => number & (s: number) => string
3737

3838
// CASE 3
39-
function f(x: number){
40-
>f : (x: number) => number
39+
function f3(x: number){
40+
>f3 : (x: number) => number
4141
>x : number
4242

4343
return x;
4444
>x : number
4545
}
4646

47-
function g(x){ return f(x); };
48-
>g : (x: number) => number
47+
function g3(x){ return f3(x); };
48+
>g3 : (x: number) => number
4949
>x : number
50-
>f(x) : number
51-
>f : (x: number) => number
50+
>f3(x) : number
51+
>f3 : (x: number) => number
5252
>x : number
5353

54-
// => function g(x: number): number
54+
// => function g3(x: number): number
5555

56+
// CASE 4
57+
declare function f4(g: Function)
58+
>f4 : (g: Function) => any
59+
>g : Function
60+
>Function : Function
61+
62+
function g4(x) {
63+
>g4 : (x: number) => void
64+
>x : number
65+
66+
f4(() => {
67+
>f4(() => { Math.sqrt(x) }) : any
68+
>f4 : (g: Function) => any
69+
>() => { Math.sqrt(x) } : () => void
70+
71+
Math.sqrt(x)
72+
>Math.sqrt(x) : number
73+
>Math.sqrt : (x: number) => number
74+
>Math : Math
75+
>sqrt : (x: number) => number
76+
>x : number
77+
78+
})
79+
}
80+
81+
// CASE 5
82+
function f5(a) {
83+
>f5 : (a: number) => void
84+
>a : number
85+
86+
if (Math.random() > 0.5) Math.round(a)
87+
>Math.random() > 0.5 : boolean
88+
>Math.random() : number
89+
>Math.random : () => number
90+
>Math : Math
91+
>random : () => number
92+
>0.5 : 0.5
93+
>Math.round(a) : number
94+
>Math.round : (x: number) => number
95+
>Math : Math
96+
>round : (x: number) => number
97+
>a : number
98+
99+
else (a)
100+
>(a) : number
101+
>a : number
102+
}

0 commit comments

Comments
 (0)