184 lines
4.4 KiB
Text
184 lines
4.4 KiB
Text
=== tests/cases/conformance/statements/switchStatements/switchStatements.ts ===
|
|
module M {
|
|
>M : typeof M, Symbol(M,Decl(switchStatements.ts,0,0))
|
|
|
|
export function fn(x: number) {
|
|
>fn : (x: number) => string, Symbol(fn,Decl(switchStatements.ts,0,10))
|
|
>x : number, Symbol(x,Decl(switchStatements.ts,1,23))
|
|
|
|
return '';
|
|
>'' : string
|
|
}
|
|
}
|
|
|
|
var x: any;
|
|
>x : any, Symbol(x,Decl(switchStatements.ts,6,3))
|
|
|
|
switch (x) {
|
|
>x : any, Symbol(x,Decl(switchStatements.ts,6,3))
|
|
|
|
case '':
|
|
>'' : string
|
|
|
|
case 12:
|
|
>12 : number
|
|
|
|
case true:
|
|
>true : boolean
|
|
|
|
case null:
|
|
>null : null
|
|
|
|
case undefined:
|
|
>undefined : undefined, Symbol(undefined)
|
|
|
|
case new Date(12):
|
|
>new Date(12) : Date
|
|
>Date : DateConstructor, Symbol(Date,Decl(lib.d.ts,633,23),Decl(lib.d.ts,815,11))
|
|
>12 : number
|
|
|
|
case new Object():
|
|
>new Object() : Object
|
|
>Object : ObjectConstructor, Symbol(Object,Decl(lib.d.ts,92,1),Decl(lib.d.ts,223,11))
|
|
|
|
case /[a-z]/:
|
|
>/[a-z]/ : RegExp
|
|
|
|
case[]:
|
|
>[] : undefined[]
|
|
|
|
case {}:
|
|
>{} : {}
|
|
|
|
case { id: 12 }:
|
|
>{ id: 12 } : { id: number; }
|
|
>id : number, Symbol(id,Decl(switchStatements.ts,18,10))
|
|
>12 : number
|
|
|
|
case['a']:
|
|
>['a'] : string[]
|
|
>'a' : string
|
|
|
|
case typeof x:
|
|
>typeof x : string
|
|
>x : any, Symbol(x,Decl(switchStatements.ts,6,3))
|
|
|
|
case typeof M:
|
|
>typeof M : string
|
|
>M : typeof M, Symbol(M,Decl(switchStatements.ts,0,0))
|
|
|
|
case M.fn(1):
|
|
>M.fn(1) : string
|
|
>M.fn : (x: number) => string, Symbol(M.fn,Decl(switchStatements.ts,0,10))
|
|
>M : typeof M, Symbol(M,Decl(switchStatements.ts,0,0))
|
|
>fn : (x: number) => string, Symbol(M.fn,Decl(switchStatements.ts,0,10))
|
|
>1 : number
|
|
|
|
case <T>(x: number) => '':
|
|
><T>(x: number) => '' : <T>(x: number) => string
|
|
>T : T, Symbol(T,Decl(switchStatements.ts,23,10))
|
|
>x : number, Symbol(x,Decl(switchStatements.ts,23,13))
|
|
>'' : string
|
|
|
|
case (<T>(x: number) => '')(2):
|
|
>(<T>(x: number) => '')(2) : string
|
|
>(<T>(x: number) => '') : <T>(x: number) => string
|
|
><T>(x: number) => '' : <T>(x: number) => string
|
|
>T : T, Symbol(T,Decl(switchStatements.ts,24,11))
|
|
>x : number, Symbol(x,Decl(switchStatements.ts,24,14))
|
|
>'' : string
|
|
>2 : number
|
|
|
|
default:
|
|
}
|
|
|
|
// basic assignable check, rest covered in tests for 'assignement compatibility'
|
|
class C { id: number; }
|
|
>C : C, Symbol(C,Decl(switchStatements.ts,26,1))
|
|
>id : number, Symbol(id,Decl(switchStatements.ts,29,9))
|
|
|
|
class D extends C { name: string }
|
|
>D : D, Symbol(D,Decl(switchStatements.ts,29,23))
|
|
>C : C, Symbol(C,Decl(switchStatements.ts,26,1))
|
|
>name : string, Symbol(name,Decl(switchStatements.ts,30,19))
|
|
|
|
switch (new C()) {
|
|
>new C() : C
|
|
>C : typeof C, Symbol(C,Decl(switchStatements.ts,26,1))
|
|
|
|
case new D():
|
|
>new D() : D
|
|
>D : typeof D, Symbol(D,Decl(switchStatements.ts,29,23))
|
|
|
|
case { id: 12, name: '' }:
|
|
>{ id: 12, name: '' } : { id: number; name: string; }
|
|
>id : number, Symbol(id,Decl(switchStatements.ts,34,10))
|
|
>12 : number
|
|
>name : string, Symbol(name,Decl(switchStatements.ts,34,18))
|
|
>'' : string
|
|
|
|
case new C():
|
|
>new C() : C
|
|
>C : typeof C, Symbol(C,Decl(switchStatements.ts,26,1))
|
|
}
|
|
|
|
switch ('') { }
|
|
>'' : string
|
|
|
|
switch (12) { }
|
|
>12 : number
|
|
|
|
switch (true) { }
|
|
>true : boolean
|
|
|
|
switch (null) { }
|
|
>null : null
|
|
|
|
switch (undefined) { }
|
|
>undefined : undefined, Symbol(undefined)
|
|
|
|
switch (new Date(12)) { }
|
|
>new Date(12) : Date
|
|
>Date : DateConstructor, Symbol(Date,Decl(lib.d.ts,633,23),Decl(lib.d.ts,815,11))
|
|
>12 : number
|
|
|
|
switch (new Object()) { }
|
|
>new Object() : Object
|
|
>Object : ObjectConstructor, Symbol(Object,Decl(lib.d.ts,92,1),Decl(lib.d.ts,223,11))
|
|
|
|
switch (/[a-z]/) { }
|
|
>/[a-z]/ : RegExp
|
|
|
|
switch ([]) { }
|
|
>[] : undefined[]
|
|
|
|
switch ({}) { }
|
|
>{} : {}
|
|
|
|
switch ({ id: 12 }) { }
|
|
>{ id: 12 } : { id: number; }
|
|
>id : number, Symbol(id,Decl(switchStatements.ts,48,9))
|
|
>12 : number
|
|
|
|
switch (['a']) { }
|
|
>['a'] : string[]
|
|
>'a' : string
|
|
|
|
switch (<T>(x: number) => '') { }
|
|
><T>(x: number) => '' : <T>(x: number) => string
|
|
>T : T, Symbol(T,Decl(switchStatements.ts,50,9))
|
|
>x : number, Symbol(x,Decl(switchStatements.ts,50,12))
|
|
>'' : string
|
|
|
|
switch ((<T>(x: T) => '')(1)) { }
|
|
>(<T>(x: T) => '')(1) : string
|
|
>(<T>(x: T) => '') : <T>(x: T) => string
|
|
><T>(x: T) => '' : <T>(x: T) => string
|
|
>T : T, Symbol(T,Decl(switchStatements.ts,51,10))
|
|
>x : T, Symbol(x,Decl(switchStatements.ts,51,13))
|
|
>T : T, Symbol(T,Decl(switchStatements.ts,51,10))
|
|
>'' : string
|
|
>1 : number
|
|
|
|
|
|
|