113 lines
2 KiB
Plaintext
113 lines
2 KiB
Plaintext
|
=== tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithBooleanType.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 ResultIsBoolean1 = !BOOLEAN;
|
||
|
>ResultIsBoolean1 : boolean
|
||
|
>!BOOLEAN : boolean
|
||
|
>BOOLEAN : boolean
|
||
|
|
||
|
// boolean type literal
|
||
|
var ResultIsBoolean2 = !true;
|
||
|
>ResultIsBoolean2 : boolean
|
||
|
>!true : boolean
|
||
|
|
||
|
var ResultIsBoolean3 = !{ x: true, y: false };
|
||
|
>ResultIsBoolean3 : boolean
|
||
|
>!{ x: true, y: false } : boolean
|
||
|
>{ x: true, y: false } : { x: boolean; y: boolean; }
|
||
|
>x : boolean
|
||
|
>y : boolean
|
||
|
|
||
|
// boolean type expressions
|
||
|
var ResultIsBoolean4 = !objA.a;
|
||
|
>ResultIsBoolean4 : boolean
|
||
|
>!objA.a : boolean
|
||
|
>objA.a : boolean
|
||
|
>objA : A
|
||
|
>a : boolean
|
||
|
|
||
|
var ResultIsBoolean5 = !M.n;
|
||
|
>ResultIsBoolean5 : boolean
|
||
|
>!M.n : boolean
|
||
|
>M.n : boolean
|
||
|
>M : typeof M
|
||
|
>n : boolean
|
||
|
|
||
|
var ResultIsBoolean6 = !foo();
|
||
|
>ResultIsBoolean6 : boolean
|
||
|
>!foo() : boolean
|
||
|
>foo() : boolean
|
||
|
>foo : () => boolean
|
||
|
|
||
|
var ResultIsBoolean7 = !A.foo();
|
||
|
>ResultIsBoolean7 : boolean
|
||
|
>!A.foo() : boolean
|
||
|
>A.foo() : boolean
|
||
|
>A.foo : () => boolean
|
||
|
>A : typeof A
|
||
|
>foo : () => boolean
|
||
|
|
||
|
// multiple ! operators
|
||
|
var ResultIsBoolean = !!BOOLEAN;
|
||
|
>ResultIsBoolean : boolean
|
||
|
>!!BOOLEAN : boolean
|
||
|
>!BOOLEAN : boolean
|
||
|
>BOOLEAN : boolean
|
||
|
|
||
|
// miss assignment operators
|
||
|
!true;
|
||
|
>!true : boolean
|
||
|
|
||
|
!BOOLEAN;
|
||
|
>!BOOLEAN : boolean
|
||
|
>BOOLEAN : boolean
|
||
|
|
||
|
!foo();
|
||
|
>!foo() : boolean
|
||
|
>foo() : boolean
|
||
|
>foo : () => boolean
|
||
|
|
||
|
!true, false;
|
||
|
>!true, false : boolean
|
||
|
>!true : boolean
|
||
|
|
||
|
!objA.a;
|
||
|
>!objA.a : boolean
|
||
|
>objA.a : boolean
|
||
|
>objA : A
|
||
|
>a : boolean
|
||
|
|
||
|
!M.n;
|
||
|
>!M.n : boolean
|
||
|
>M.n : boolean
|
||
|
>M : typeof M
|
||
|
>n : boolean
|
||
|
|