From 798048963cdfaadbc8defeebdd76749b9b7554a2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 19 Sep 2016 17:06:53 -0700 Subject: [PATCH] Accept new baselines --- .../controlFlowWithIncompleteTypes.js | 53 ++++++++++++++ .../controlFlowWithIncompleteTypes.symbols | 55 ++++++++++++++ .../controlFlowWithIncompleteTypes.types | 71 +++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 tests/baselines/reference/controlFlowWithIncompleteTypes.js create mode 100644 tests/baselines/reference/controlFlowWithIncompleteTypes.symbols create mode 100644 tests/baselines/reference/controlFlowWithIncompleteTypes.types diff --git a/tests/baselines/reference/controlFlowWithIncompleteTypes.js b/tests/baselines/reference/controlFlowWithIncompleteTypes.js new file mode 100644 index 00000000000..83940df6753 --- /dev/null +++ b/tests/baselines/reference/controlFlowWithIncompleteTypes.js @@ -0,0 +1,53 @@ +//// [controlFlowWithIncompleteTypes.ts] +// Repro from #11000 + +declare var cond: boolean; + +function foo1() { + let x: string | number | boolean = 0; + while (cond) { + if (typeof x === "string") { + x = x.slice(); + } + else { + x = "abc"; + } + } +} + +function foo2() { + let x: string | number | boolean = 0; + while (cond) { + if (typeof x === "number") { + x = "abc"; + } + else { + x = x.slice(); + } + } +} + +//// [controlFlowWithIncompleteTypes.js] +// Repro from #11000 +function foo1() { + var x = 0; + while (cond) { + if (typeof x === "string") { + x = x.slice(); + } + else { + x = "abc"; + } + } +} +function foo2() { + var x = 0; + while (cond) { + if (typeof x === "number") { + x = "abc"; + } + else { + x = x.slice(); + } + } +} diff --git a/tests/baselines/reference/controlFlowWithIncompleteTypes.symbols b/tests/baselines/reference/controlFlowWithIncompleteTypes.symbols new file mode 100644 index 00000000000..2ad709140cb --- /dev/null +++ b/tests/baselines/reference/controlFlowWithIncompleteTypes.symbols @@ -0,0 +1,55 @@ +=== tests/cases/compiler/controlFlowWithIncompleteTypes.ts === +// Repro from #11000 + +declare var cond: boolean; +>cond : Symbol(cond, Decl(controlFlowWithIncompleteTypes.ts, 2, 11)) + +function foo1() { +>foo1 : Symbol(foo1, Decl(controlFlowWithIncompleteTypes.ts, 2, 26)) + + let x: string | number | boolean = 0; +>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 5, 7)) + + while (cond) { +>cond : Symbol(cond, Decl(controlFlowWithIncompleteTypes.ts, 2, 11)) + + if (typeof x === "string") { +>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 5, 7)) + + x = x.slice(); +>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 5, 7)) +>x.slice : Symbol(String.slice, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 5, 7)) +>slice : Symbol(String.slice, Decl(lib.d.ts, --, --)) + } + else { + x = "abc"; +>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 5, 7)) + } + } +} + +function foo2() { +>foo2 : Symbol(foo2, Decl(controlFlowWithIncompleteTypes.ts, 14, 1)) + + let x: string | number | boolean = 0; +>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 17, 7)) + + while (cond) { +>cond : Symbol(cond, Decl(controlFlowWithIncompleteTypes.ts, 2, 11)) + + if (typeof x === "number") { +>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 17, 7)) + + x = "abc"; +>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 17, 7)) + } + else { + x = x.slice(); +>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 17, 7)) +>x.slice : Symbol(String.slice, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 17, 7)) +>slice : Symbol(String.slice, Decl(lib.d.ts, --, --)) + } + } +} diff --git a/tests/baselines/reference/controlFlowWithIncompleteTypes.types b/tests/baselines/reference/controlFlowWithIncompleteTypes.types new file mode 100644 index 00000000000..784f22a3966 --- /dev/null +++ b/tests/baselines/reference/controlFlowWithIncompleteTypes.types @@ -0,0 +1,71 @@ +=== tests/cases/compiler/controlFlowWithIncompleteTypes.ts === +// Repro from #11000 + +declare var cond: boolean; +>cond : boolean + +function foo1() { +>foo1 : () => void + + let x: string | number | boolean = 0; +>x : string | number | boolean +>0 : 0 + + while (cond) { +>cond : boolean + + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : string +>x : string | number +>"string" : "string" + + x = x.slice(); +>x = x.slice() : string +>x : string | number | boolean +>x.slice() : string +>x.slice : (start?: number, end?: number) => string +>x : string +>slice : (start?: number, end?: number) => string + } + else { + x = "abc"; +>x = "abc" : "abc" +>x : string | number | boolean +>"abc" : "abc" + } + } +} + +function foo2() { +>foo2 : () => void + + let x: string | number | boolean = 0; +>x : string | number | boolean +>0 : 0 + + while (cond) { +>cond : boolean + + if (typeof x === "number") { +>typeof x === "number" : boolean +>typeof x : string +>x : string | number +>"number" : "number" + + x = "abc"; +>x = "abc" : "abc" +>x : string | number | boolean +>"abc" : "abc" + } + else { + x = x.slice(); +>x = x.slice() : string +>x : string | number | boolean +>x.slice() : string +>x.slice : (start?: number, end?: number) => string +>x : string +>slice : (start?: number, end?: number) => string + } + } +}