From 0b9b4e62de37dbccb53544704791ea92a3af0cd7 Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Fri, 30 Aug 2019 09:38:13 -0700 Subject: [PATCH] Add tests --- tests/baselines/reference/promiseType.js | 4 ++++ tests/baselines/reference/promiseType.symbols | 10 ++++++++++ tests/baselines/reference/promiseType.types | 10 ++++++++++ tests/cases/compiler/promiseType.ts | 3 +++ 4 files changed, 27 insertions(+) diff --git a/tests/baselines/reference/promiseType.js b/tests/baselines/reference/promiseType.js index 84d9d713b4810..065497c99cd56 100644 --- a/tests/baselines/reference/promiseType.js +++ b/tests/baselines/reference/promiseType.js @@ -217,6 +217,9 @@ 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)); + +declare const x2: Promise | string; +Promise.resolve(x2); //// [promiseType.js] @@ -440,3 +443,4 @@ 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)); +Promise.resolve(x2); diff --git a/tests/baselines/reference/promiseType.symbols b/tests/baselines/reference/promiseType.symbols index cec81cd7d8266..74e6d1cd0a9aa 100644 --- a/tests/baselines/reference/promiseType.symbols +++ b/tests/baselines/reference/promiseType.symbols @@ -1089,3 +1089,13 @@ 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, --, --)) +declare const x2: Promise | string; +>x2 : Symbol(x2, Decl(promiseType.ts, 219, 13)) +>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.resolve(x2); +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.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, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>x2 : Symbol(x2, Decl(promiseType.ts, 219, 13)) + diff --git a/tests/baselines/reference/promiseType.types b/tests/baselines/reference/promiseType.types index 347885d24a193..c37dc6d178596 100644 --- a/tests/baselines/reference/promiseType.types +++ b/tests/baselines/reference/promiseType.types @@ -1583,3 +1583,13 @@ const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); >reject : (reason?: any) => Promise >1 : 1 +declare const x2: Promise | string; +>x2 : string | Promise + +Promise.resolve(x2); +>Promise.resolve(x2) : Promise +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T): Promise ? U : T>; (): Promise; } +>x2 : string | Promise + diff --git a/tests/cases/compiler/promiseType.ts b/tests/cases/compiler/promiseType.ts index ba4a7f6041396..d94ad78a64d82 100644 --- a/tests/cases/compiler/promiseType.ts +++ b/tests/cases/compiler/promiseType.ts @@ -217,3 +217,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)); + +declare const x2: Promise | string; +Promise.resolve(x2);