Adding test

This commit is contained in:
Anders Hejlsberg
2016-05-11 09:42:55 -07:00
parent 5edf72666d
commit 9f30d9ff6e
4 changed files with 204 additions and 0 deletions
@@ -103,6 +103,23 @@ function f5(x: string | number) {
}
x; // string | number
}
function f6() {
let x: string | undefined | null;
x!.slice();
x = "";
x!.slice();
x = undefined;
x!.slice();
x = null;
x!.slice();
x = <undefined | null>undefined;
x!.slice();
x = <string | undefined>"";
x!.slice();
x = <string | null>"";
x!.slice();
}
//// [typeGuardsAsAssertions.js]
@@ -194,3 +211,19 @@ function f5(x) {
}
x; // string | number
}
function f6() {
var x;
x.slice();
x = "";
x.slice();
x = undefined;
x.slice();
x = null;
x.slice();
x = undefined;
x.slice();
x = "";
x.slice();
x = "";
x.slice();
}
@@ -251,3 +251,65 @@ function f5(x: string | number) {
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 95, 12))
}
function f6() {
>f6 : Symbol(f6, Decl(typeGuardsAsAssertions.ts, 103, 1))
let x: string | undefined | null;
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 106, 7))
x!.slice();
>x!.slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 106, 7))
>slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
x = "";
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 106, 7))
x!.slice();
>x!.slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 106, 7))
>slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
x = undefined;
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 106, 7))
>undefined : Symbol(undefined)
x!.slice();
>x!.slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 106, 7))
>slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
x = null;
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 106, 7))
x!.slice();
>x!.slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 106, 7))
>slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
x = <undefined | null>undefined;
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 106, 7))
>undefined : Symbol(undefined)
x!.slice();
>x!.slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 106, 7))
>slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
x = <string | undefined>"";
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 106, 7))
x!.slice();
>x!.slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 106, 7))
>slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
x = <string | null>"";
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 106, 7))
x!.slice();
>x!.slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(typeGuardsAsAssertions.ts, 106, 7))
>slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
}
@@ -291,3 +291,95 @@ function f5(x: string | number) {
>x : number | string
}
function f6() {
>f6 : () => void
let x: string | undefined | null;
>x : string | null | undefined
>null : null
x!.slice();
>x!.slice() : string
>x!.slice : (start?: number | undefined, end?: number | undefined) => string
>x! : string
>x : string | null | undefined
>slice : (start?: number | undefined, end?: number | undefined) => string
x = "";
>x = "" : string
>x : string | null | undefined
>"" : string
x!.slice();
>x!.slice() : string
>x!.slice : (start?: number | undefined, end?: number | undefined) => string
>x! : string
>x : string
>slice : (start?: number | undefined, end?: number | undefined) => string
x = undefined;
>x = undefined : undefined
>x : string | null | undefined
>undefined : undefined
x!.slice();
>x!.slice() : string
>x!.slice : (start?: number | undefined, end?: number | undefined) => string
>x! : string
>x : string | null | undefined
>slice : (start?: number | undefined, end?: number | undefined) => string
x = null;
>x = null : null
>x : string | null | undefined
>null : null
x!.slice();
>x!.slice() : string
>x!.slice : (start?: number | undefined, end?: number | undefined) => string
>x! : string
>x : string | null | undefined
>slice : (start?: number | undefined, end?: number | undefined) => string
x = <undefined | null>undefined;
>x = <undefined | null>undefined : null | undefined
>x : string | null | undefined
><undefined | null>undefined : null | undefined
>null : null
>undefined : undefined
x!.slice();
>x!.slice() : string
>x!.slice : (start?: number | undefined, end?: number | undefined) => string
>x! : string
>x : string | null | undefined
>slice : (start?: number | undefined, end?: number | undefined) => string
x = <string | undefined>"";
>x = <string | undefined>"" : string | undefined
>x : string | null | undefined
><string | undefined>"" : string | undefined
>"" : string
x!.slice();
>x!.slice() : string
>x!.slice : (start?: number | undefined, end?: number | undefined) => string
>x! : string
>x : string | undefined
>slice : (start?: number | undefined, end?: number | undefined) => string
x = <string | null>"";
>x = <string | null>"" : string | null
>x : string | null | undefined
><string | null>"" : string | null
>null : null
>"" : string
x!.slice();
>x!.slice() : string
>x!.slice : (start?: number | undefined, end?: number | undefined) => string
>x! : string
>x : string | null
>slice : (start?: number | undefined, end?: number | undefined) => string
}
@@ -103,3 +103,20 @@ function f5(x: string | number) {
}
x; // string | number
}
function f6() {
let x: string | undefined | null;
x!.slice();
x = "";
x!.slice();
x = undefined;
x!.slice();
x = null;
x!.slice();
x = <undefined | null>undefined;
x!.slice();
x = <string | undefined>"";
x!.slice();
x = <string | null>"";
x!.slice();
}