Adding regression test

This commit is contained in:
Anders Hejlsberg
2016-04-25 11:24:39 -07:00
parent b88269bace
commit ff108c0142
4 changed files with 142 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
//// [controlFlowIteration.ts]
let cond: boolean;
function ff() {
let x: string | undefined;
while (true) {
if (cond) {
x = "";
}
else {
if (x) {
x.length;
}
if (x) {
x.length;
}
}
}
}
//// [controlFlowIteration.js]
var cond;
function ff() {
var x;
while (true) {
if (cond) {
x = "";
}
else {
if (x) {
x.length;
}
if (x) {
x.length;
}
}
}
}

View File

@@ -0,0 +1,39 @@
=== tests/cases/conformance/controlFlow/controlFlowIteration.ts ===
let cond: boolean;
>cond : Symbol(cond, Decl(controlFlowIteration.ts, 1, 3))
function ff() {
>ff : Symbol(ff, Decl(controlFlowIteration.ts, 1, 18))
let x: string | undefined;
>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7))
while (true) {
if (cond) {
>cond : Symbol(cond, Decl(controlFlowIteration.ts, 1, 3))
x = "";
>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7))
}
else {
if (x) {
>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7))
x.length;
>x.length : Symbol(String.length, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7))
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
}
if (x) {
>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7))
x.length;
>x.length : Symbol(String.length, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7))
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
}
}
}
}

View File

@@ -0,0 +1,43 @@
=== tests/cases/conformance/controlFlow/controlFlowIteration.ts ===
let cond: boolean;
>cond : boolean
function ff() {
>ff : () => void
let x: string | undefined;
>x : string | undefined
while (true) {
>true : boolean
if (cond) {
>cond : boolean
x = "";
>x = "" : string
>x : string | undefined
>"" : string
}
else {
if (x) {
>x : string | undefined
x.length;
>x.length : number
>x : string
>length : number
}
if (x) {
>x : string | undefined
x.length;
>x.length : number
>x : string
>length : number
}
}
}
}

View File

@@ -0,0 +1,20 @@
// @strictNullChecks: true
let cond: boolean;
function ff() {
let x: string | undefined;
while (true) {
if (cond) {
x = "";
}
else {
if (x) {
x.length;
}
if (x) {
x.length;
}
}
}
}