Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jablko committed Oct 5, 2019
1 parent 57f9f72 commit 5d2ccd3
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/baselines/reference/promiseType.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ const pc6 = p.then(() => Promise.reject("1"), () => {});
const pc7 = p.then(() => Promise.reject("1"), () => {throw 1});
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));

// #27711

const p2: Promise<number> = new Promise<Promise<number>>(() => {});

declare function f(resolve: (value: Promise<number> | string) => void);
new Promise(f);


//// [promiseType.js]
Expand Down Expand Up @@ -440,3 +447,6 @@ const pc6 = p.then(() => Promise.reject("1"), () => { });
const pc7 = p.then(() => Promise.reject("1"), () => { throw 1; });
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
// #27711
const p2 = new Promise(() => { });
new Promise(f);
18 changes: 18 additions & 0 deletions tests/baselines/reference/promiseType.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -1089,3 +1089,21 @@ const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --))

// #27711

const p2: Promise<number> = new Promise<Promise<number>>(() => {});
>p2 : Symbol(p2, Decl(promiseType.ts, 221, 5))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))

declare function f(resolve: (value: Promise<number> | string) => void);
>f : Symbol(f, Decl(promiseType.ts, 221, 67))
>resolve : Symbol(resolve, Decl(promiseType.ts, 223, 19))
>value : Symbol(value, Decl(promiseType.ts, 223, 29))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))

new Promise(f);
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>f : Symbol(f, Decl(promiseType.ts, 221, 67))

18 changes: 18 additions & 0 deletions tests/baselines/reference/promiseType.types
Original file line number Diff line number Diff line change
Expand Up @@ -1583,3 +1583,21 @@ const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
>reject : <T = never>(reason?: any) => Promise<T>
>1 : 1

// #27711

const p2: Promise<number> = new Promise<Promise<number>>(() => {});
>p2 : Promise<number>
>new Promise<Promise<number>>(() => {}) : Promise<number>
>Promise : PromiseConstructor
>() => {} : () => void

declare function f(resolve: (value: Promise<number> | string) => void);
>f : (resolve: (value: string | Promise<number>) => void) => any
>resolve : (value: string | Promise<number>) => void
>value : string | Promise<number>

new Promise(f);
>new Promise(f) : Promise<string | number>
>Promise : PromiseConstructor
>f : (resolve: (value: string | Promise<number>) => void) => any

7 changes: 7 additions & 0 deletions tests/cases/compiler/promiseType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,10 @@ const pc6 = p.then(() => Promise.reject("1"), () => {});
const pc7 = p.then(() => Promise.reject("1"), () => {throw 1});
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));

// #27711

const p2: Promise<number> = new Promise<Promise<number>>(() => {});

declare function f(resolve: (value: Promise<number> | string) => void);
new Promise(f);

0 comments on commit 5d2ccd3

Please sign in to comment.