Skip to content

Commit

Permalink
Accept baselines
Browse files Browse the repository at this point in the history
  • Loading branch information
masaeedu committed Aug 10, 2017
1 parent d85a212 commit 8def2ea
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 24 deletions.
38 changes: 31 additions & 7 deletions tests/baselines/reference/parameterInference.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,26 @@ function subs(s) {
// => (s: string) => number & (s: number) => string

// CASE 3
function f(x: number){
function f3(x: number){
return x;
}

function g(x){ return f(x); };
// => function g(x: number): number

function g3(x){ return f3(x); };
// => function g3(x: number): number

// CASE 4
declare function f4(g: Function)
function g4(x) {
f4(() => {
Math.sqrt(x)
})
}

// CASE 5
function f5(a) {
if (Math.random() > 0.5) Math.round(a)
else (a)
}

//// [parameterInference.js]
// CASE 1
Expand All @@ -37,9 +50,20 @@ function subs(s) {
// NOTE: Still broken, needs to deal with overloads. Should have been inferred as:
// => (s: string) => number & (s: number) => string
// CASE 3
function f(x) {
function f3(x) {
return x;
}
function g(x) { return f(x); }
function g3(x) { return f3(x); }
;
// => function g(x: number): number
function g4(x) {
f4(function () {
Math.sqrt(x);
});
}
// CASE 5
function f5(a) {
if (Math.random() > 0.5)
Math.round(a);
else
(a);
}
59 changes: 49 additions & 10 deletions tests/baselines/reference/parameterInference.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,58 @@ function subs(s) {
// => (s: string) => number & (s: number) => string

// CASE 3
function f(x: number){
>f : Symbol(f, Decl(parameterInference.ts, 12, 1))
>x : Symbol(x, Decl(parameterInference.ts, 18, 11))
function f3(x: number){
>f3 : Symbol(f3, Decl(parameterInference.ts, 12, 1))
>x : Symbol(x, Decl(parameterInference.ts, 18, 12))

return x;
>x : Symbol(x, Decl(parameterInference.ts, 18, 11))
>x : Symbol(x, Decl(parameterInference.ts, 18, 12))
}

function g(x){ return f(x); };
>g : Symbol(g, Decl(parameterInference.ts, 20, 1))
>x : Symbol(x, Decl(parameterInference.ts, 22, 11))
>f : Symbol(f, Decl(parameterInference.ts, 12, 1))
>x : Symbol(x, Decl(parameterInference.ts, 22, 11))
function g3(x){ return f3(x); };
>g3 : Symbol(g3, Decl(parameterInference.ts, 20, 1))
>x : Symbol(x, Decl(parameterInference.ts, 22, 12))
>f3 : Symbol(f3, Decl(parameterInference.ts, 12, 1))
>x : Symbol(x, Decl(parameterInference.ts, 22, 12))

// => function g(x: number): number
// => function g3(x: number): number

// CASE 4
declare function f4(g: Function)
>f4 : Symbol(f4, Decl(parameterInference.ts, 22, 32))
>g : Symbol(g, Decl(parameterInference.ts, 26, 20))
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))

function g4(x) {
>g4 : Symbol(g4, Decl(parameterInference.ts, 26, 32))
>x : Symbol(x, Decl(parameterInference.ts, 27, 12))

f4(() => {
>f4 : Symbol(f4, Decl(parameterInference.ts, 22, 32))

Math.sqrt(x)
>Math.sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(parameterInference.ts, 27, 12))

})
}

// CASE 5
function f5(a) {
>f5 : Symbol(f5, Decl(parameterInference.ts, 31, 1))
>a : Symbol(a, Decl(parameterInference.ts, 34, 12))

if (Math.random() > 0.5) Math.round(a)
>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>random : Symbol(Math.random, Decl(lib.d.ts, --, --))
>Math.round : Symbol(Math.round, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>round : Symbol(Math.round, Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(parameterInference.ts, 34, 12))

else (a)
>a : Symbol(a, Decl(parameterInference.ts, 34, 12))
}
61 changes: 54 additions & 7 deletions tests/baselines/reference/parameterInference.types
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,67 @@ function subs(s) {
// => (s: string) => number & (s: number) => string

// CASE 3
function f(x: number){
>f : (x: number) => number
function f3(x: number){
>f3 : (x: number) => number
>x : number

return x;
>x : number
}

function g(x){ return f(x); };
>g : (x: number) => number
function g3(x){ return f3(x); };
>g3 : (x: number) => number
>x : number
>f(x) : number
>f : (x: number) => number
>f3(x) : number
>f3 : (x: number) => number
>x : number

// => function g(x: number): number
// => function g3(x: number): number

// CASE 4
declare function f4(g: Function)
>f4 : (g: Function) => any
>g : Function
>Function : Function

function g4(x) {
>g4 : (x: number) => void
>x : number

f4(() => {
>f4(() => { Math.sqrt(x) }) : any
>f4 : (g: Function) => any
>() => { Math.sqrt(x) } : () => void

Math.sqrt(x)
>Math.sqrt(x) : number
>Math.sqrt : (x: number) => number
>Math : Math
>sqrt : (x: number) => number
>x : number

})
}

// CASE 5
function f5(a) {
>f5 : (a: number) => void
>a : number

if (Math.random() > 0.5) Math.round(a)
>Math.random() > 0.5 : boolean
>Math.random() : number
>Math.random : () => number
>Math : Math
>random : () => number
>0.5 : 0.5
>Math.round(a) : number
>Math.round : (x: number) => number
>Math : Math
>round : (x: number) => number
>a : number

else (a)
>(a) : number
>a : number
}

0 comments on commit 8def2ea

Please sign in to comment.