Adding test

This commit is contained in:
Anders Hejlsberg 2015-06-26 09:48:36 -07:00
parent 18588104db
commit 90ffdf77c9
4 changed files with 116 additions and 0 deletions

View file

@ -0,0 +1,26 @@
//// [intersectionTypeOverloading.ts]
// Check that order is preserved in intersection types for purposes of
// overload resolution
type F = (s: string) => string;
type G = (x: any) => any;
var fg: F & G;
var gf: G & F;
var x = fg("abc");
var x: string;
var y = gf("abc");
var y: any;
//// [intersectionTypeOverloading.js]
// Check that order is preserved in intersection types for purposes of
// overload resolution
var fg;
var gf;
var x = fg("abc");
var x;
var y = gf("abc");
var y;

View file

@ -0,0 +1,36 @@
=== tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts ===
// Check that order is preserved in intersection types for purposes of
// overload resolution
type F = (s: string) => string;
>F : Symbol(F, Decl(intersectionTypeOverloading.ts, 0, 0))
>s : Symbol(s, Decl(intersectionTypeOverloading.ts, 3, 10))
type G = (x: any) => any;
>G : Symbol(G, Decl(intersectionTypeOverloading.ts, 3, 31))
>x : Symbol(x, Decl(intersectionTypeOverloading.ts, 4, 10))
var fg: F & G;
>fg : Symbol(fg, Decl(intersectionTypeOverloading.ts, 6, 3))
>F : Symbol(F, Decl(intersectionTypeOverloading.ts, 0, 0))
>G : Symbol(G, Decl(intersectionTypeOverloading.ts, 3, 31))
var gf: G & F;
>gf : Symbol(gf, Decl(intersectionTypeOverloading.ts, 7, 3))
>G : Symbol(G, Decl(intersectionTypeOverloading.ts, 3, 31))
>F : Symbol(F, Decl(intersectionTypeOverloading.ts, 0, 0))
var x = fg("abc");
>x : Symbol(x, Decl(intersectionTypeOverloading.ts, 9, 3), Decl(intersectionTypeOverloading.ts, 10, 3))
>fg : Symbol(fg, Decl(intersectionTypeOverloading.ts, 6, 3))
var x: string;
>x : Symbol(x, Decl(intersectionTypeOverloading.ts, 9, 3), Decl(intersectionTypeOverloading.ts, 10, 3))
var y = gf("abc");
>y : Symbol(y, Decl(intersectionTypeOverloading.ts, 12, 3), Decl(intersectionTypeOverloading.ts, 13, 3))
>gf : Symbol(gf, Decl(intersectionTypeOverloading.ts, 7, 3))
var y: any;
>y : Symbol(y, Decl(intersectionTypeOverloading.ts, 12, 3), Decl(intersectionTypeOverloading.ts, 13, 3))

View file

@ -0,0 +1,40 @@
=== tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts ===
// Check that order is preserved in intersection types for purposes of
// overload resolution
type F = (s: string) => string;
>F : (s: string) => string
>s : string
type G = (x: any) => any;
>G : (x: any) => any
>x : any
var fg: F & G;
>fg : ((s: string) => string) & ((x: any) => any)
>F : (s: string) => string
>G : (x: any) => any
var gf: G & F;
>gf : ((x: any) => any) & ((s: string) => string)
>G : (x: any) => any
>F : (s: string) => string
var x = fg("abc");
>x : string
>fg("abc") : string
>fg : ((s: string) => string) & ((x: any) => any)
>"abc" : string
var x: string;
>x : string
var y = gf("abc");
>y : any
>gf("abc") : any
>gf : ((x: any) => any) & ((s: string) => string)
>"abc" : string
var y: any;
>y : any

View file

@ -0,0 +1,14 @@
// Check that order is preserved in intersection types for purposes of
// overload resolution
type F = (s: string) => string;
type G = (x: any) => any;
var fg: F & G;
var gf: G & F;
var x = fg("abc");
var x: string;
var y = gf("abc");
var y: any;