113 lines
2 KiB
Text
113 lines
2 KiB
Text
|
=== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithBooleanType.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
|
||
|
|
||
|
// multiple ~ operators
|
||
|
var ResultIsNumber8 = ~~BOOLEAN;
|
||
|
>ResultIsNumber8 : number
|
||
|
>~~BOOLEAN : number
|
||
|
>~BOOLEAN : number
|
||
|
>BOOLEAN : 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
|
||
|
|