175 lines
3.3 KiB
Text
175 lines
3.3 KiB
Text
=== tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithNumberType.ts ===
|
|
// ! operator on number type
|
|
var NUMBER: number;
|
|
>NUMBER : number
|
|
|
|
var NUMBER1: number[] = [1, 2];
|
|
>NUMBER1 : number[]
|
|
>[1, 2] : number[]
|
|
>1 : number
|
|
>2 : number
|
|
|
|
function foo(): number { return 1; }
|
|
>foo : () => number
|
|
>1 : number
|
|
|
|
class A {
|
|
>A : A
|
|
|
|
public a: number;
|
|
>a : number
|
|
|
|
static foo() { return 1; }
|
|
>foo : () => number
|
|
>1 : number
|
|
}
|
|
module M {
|
|
>M : typeof M
|
|
|
|
export var n: number;
|
|
>n : number
|
|
}
|
|
|
|
var objA = new A();
|
|
>objA : A
|
|
>new A() : A
|
|
>A : typeof A
|
|
|
|
// number type var
|
|
var ResultIsBoolean1 = !NUMBER;
|
|
>ResultIsBoolean1 : boolean
|
|
>!NUMBER : boolean
|
|
>NUMBER : number
|
|
|
|
var ResultIsBoolean2 = !NUMBER1;
|
|
>ResultIsBoolean2 : boolean
|
|
>!NUMBER1 : boolean
|
|
>NUMBER1 : number[]
|
|
|
|
// number type literal
|
|
var ResultIsBoolean3 = !1;
|
|
>ResultIsBoolean3 : boolean
|
|
>!1 : boolean
|
|
>1 : number
|
|
|
|
var ResultIsBoolean4 = !{ x: 1, y: 2};
|
|
>ResultIsBoolean4 : boolean
|
|
>!{ x: 1, y: 2} : boolean
|
|
>{ x: 1, y: 2} : { x: number; y: number; }
|
|
>x : number
|
|
>1 : number
|
|
>y : number
|
|
>2 : number
|
|
|
|
var ResultIsBoolean5 = !{ x: 1, y: (n: number) => { return n; } };
|
|
>ResultIsBoolean5 : boolean
|
|
>!{ x: 1, y: (n: number) => { return n; } } : boolean
|
|
>{ x: 1, y: (n: number) => { return n; } } : { x: number; y: (n: number) => number; }
|
|
>x : number
|
|
>1 : number
|
|
>y : (n: number) => number
|
|
>(n: number) => { return n; } : (n: number) => number
|
|
>n : number
|
|
>n : number
|
|
|
|
// number type expressions
|
|
var ResultIsBoolean6 = !objA.a;
|
|
>ResultIsBoolean6 : boolean
|
|
>!objA.a : boolean
|
|
>objA.a : number
|
|
>objA : A
|
|
>a : number
|
|
|
|
var ResultIsBoolean7 = !M.n;
|
|
>ResultIsBoolean7 : boolean
|
|
>!M.n : boolean
|
|
>M.n : number
|
|
>M : typeof M
|
|
>n : number
|
|
|
|
var ResultIsBoolean8 = !NUMBER1[0];
|
|
>ResultIsBoolean8 : boolean
|
|
>!NUMBER1[0] : boolean
|
|
>NUMBER1[0] : number
|
|
>NUMBER1 : number[]
|
|
>0 : number
|
|
|
|
var ResultIsBoolean9 = !foo();
|
|
>ResultIsBoolean9 : boolean
|
|
>!foo() : boolean
|
|
>foo() : number
|
|
>foo : () => number
|
|
|
|
var ResultIsBoolean10 = !A.foo();
|
|
>ResultIsBoolean10 : boolean
|
|
>!A.foo() : boolean
|
|
>A.foo() : number
|
|
>A.foo : () => number
|
|
>A : typeof A
|
|
>foo : () => number
|
|
|
|
var ResultIsBoolean11 = !(NUMBER + NUMBER);
|
|
>ResultIsBoolean11 : boolean
|
|
>!(NUMBER + NUMBER) : boolean
|
|
>(NUMBER + NUMBER) : number
|
|
>NUMBER + NUMBER : number
|
|
>NUMBER : number
|
|
>NUMBER : number
|
|
|
|
// multiple ! operator
|
|
var ResultIsBoolean12 = !!NUMBER;
|
|
>ResultIsBoolean12 : boolean
|
|
>!!NUMBER : boolean
|
|
>!NUMBER : boolean
|
|
>NUMBER : number
|
|
|
|
var ResultIsBoolean13 = !!!(NUMBER + NUMBER);
|
|
>ResultIsBoolean13 : boolean
|
|
>!!!(NUMBER + NUMBER) : boolean
|
|
>!!(NUMBER + NUMBER) : boolean
|
|
>!(NUMBER + NUMBER) : boolean
|
|
>(NUMBER + NUMBER) : number
|
|
>NUMBER + NUMBER : number
|
|
>NUMBER : number
|
|
>NUMBER : number
|
|
|
|
// miss assignment operators
|
|
!1;
|
|
>!1 : boolean
|
|
>1 : number
|
|
|
|
!NUMBER;
|
|
>!NUMBER : boolean
|
|
>NUMBER : number
|
|
|
|
!NUMBER1;
|
|
>!NUMBER1 : boolean
|
|
>NUMBER1 : number[]
|
|
|
|
!foo();
|
|
>!foo() : boolean
|
|
>foo() : number
|
|
>foo : () => number
|
|
|
|
!objA.a;
|
|
>!objA.a : boolean
|
|
>objA.a : number
|
|
>objA : A
|
|
>a : number
|
|
|
|
!M.n;
|
|
>!M.n : boolean
|
|
>M.n : number
|
|
>M : typeof M
|
|
>n : number
|
|
|
|
!objA.a, M.n;
|
|
>!objA.a, M.n : number
|
|
>!objA.a : boolean
|
|
>objA.a : number
|
|
>objA : A
|
|
>a : number
|
|
>M.n : number
|
|
>M : typeof M
|
|
>n : number
|
|
|