106 lines
1.8 KiB
Text
106 lines
1.8 KiB
Text
|
=== tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithBooleanType.ts ===
|
||
|
// - operator on boolean type
|
||
|
var BOOLEAN: boolean;
|
||
|
>BOOLEAN : boolean
|
||
|
|
||
|
function foo(): boolean { return true; }
|
||
|
>foo : () => boolean
|
||
|
|
||
|
class A {
|
||
|
>A : A
|
||
|
|
||
|
public a: boolean;
|
||
|
>a : boolean
|
||
|
|
||
|
static foo() { return false; }
|
||
|
>foo : () => boolean
|
||
|
}
|
||
|
module M {
|
||
|
>M : typeof M
|
||
|
|
||
|
export var n: boolean;
|
||
|
>n : boolean
|
||
|
}
|
||
|
|
||
|
var objA = new A();
|
||
|
>objA : A
|
||
|
>new A() : A
|
||
|
>A : typeof A
|
||
|
|
||
|
// boolean type var
|
||
|
var ResultIsNumber1 = -BOOLEAN;
|
||
|
>ResultIsNumber1 : number
|
||
|
>-BOOLEAN : number
|
||
|
>BOOLEAN : boolean
|
||
|
|
||
|
// boolean type literal
|
||
|
var ResultIsNumber2 = -true;
|
||
|
>ResultIsNumber2 : number
|
||
|
>-true : number
|
||
|
|
||
|
var ResultIsNumber3 = -{ x: true, y: false };
|
||
|
>ResultIsNumber3 : number
|
||
|
>-{ x: true, y: false } : number
|
||
|
>{ x: true, y: false } : { x: boolean; y: boolean; }
|
||
|
>x : boolean
|
||
|
>y : boolean
|
||
|
|
||
|
// boolean type expressions
|
||
|
var ResultIsNumber4 = -objA.a;
|
||
|
>ResultIsNumber4 : number
|
||
|
>-objA.a : number
|
||
|
>objA.a : boolean
|
||
|
>objA : A
|
||
|
>a : boolean
|
||
|
|
||
|
var ResultIsNumber5 = -M.n;
|
||
|
>ResultIsNumber5 : number
|
||
|
>-M.n : number
|
||
|
>M.n : boolean
|
||
|
>M : typeof M
|
||
|
>n : boolean
|
||
|
|
||
|
var ResultIsNumber6 = -foo();
|
||
|
>ResultIsNumber6 : number
|
||
|
>-foo() : number
|
||
|
>foo() : boolean
|
||
|
>foo : () => boolean
|
||
|
|
||
|
var ResultIsNumber7 = -A.foo();
|
||
|
>ResultIsNumber7 : number
|
||
|
>-A.foo() : number
|
||
|
>A.foo() : boolean
|
||
|
>A.foo : () => boolean
|
||
|
>A : typeof A
|
||
|
>foo : () => boolean
|
||
|
|
||
|
// miss assignment operators
|
||
|
-true;
|
||
|
>-true : number
|
||
|
|
||
|
-BOOLEAN;
|
||
|
>-BOOLEAN : number
|
||
|
>BOOLEAN : boolean
|
||
|
|
||
|
-foo();
|
||
|
>-foo() : number
|
||
|
>foo() : boolean
|
||
|
>foo : () => boolean
|
||
|
|
||
|
-true, false;
|
||
|
>-true, false : boolean
|
||
|
>-true : number
|
||
|
|
||
|
-objA.a;
|
||
|
>-objA.a : number
|
||
|
>objA.a : boolean
|
||
|
>objA : A
|
||
|
>a : boolean
|
||
|
|
||
|
-M.n;
|
||
|
>-M.n : number
|
||
|
>M.n : boolean
|
||
|
>M : typeof M
|
||
|
>n : boolean
|
||
|
|