2014-07-13 01:04:16 +02:00
|
|
|
//// [logicalNotOperatorWithStringType.ts]
|
|
|
|
// ! operator on string type
|
|
|
|
var STRING: string;
|
|
|
|
var STRING1: string[] = ["", "abc"];
|
|
|
|
|
|
|
|
function foo(): string { return "abc"; }
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public a: string;
|
|
|
|
static foo() { return ""; }
|
|
|
|
}
|
|
|
|
module M {
|
|
|
|
export var n: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
var objA = new A();
|
|
|
|
|
|
|
|
// string type var
|
|
|
|
var ResultIsBoolean1 = !STRING;
|
|
|
|
var ResultIsBoolean2 = !STRING1;
|
|
|
|
|
|
|
|
// string type literal
|
|
|
|
var ResultIsBoolean3 = !"";
|
|
|
|
var ResultIsBoolean4 = !{ x: "", y: "" };
|
|
|
|
var ResultIsBoolean5 = !{ x: "", y: (s: string) => { return s; } };
|
|
|
|
|
|
|
|
// string type expressions
|
|
|
|
var ResultIsBoolean6 = !objA.a;
|
|
|
|
var ResultIsBoolean7 = !M.n;
|
|
|
|
var ResultIsBoolean8 = !STRING1[0];
|
|
|
|
var ResultIsBoolean9 = !foo();
|
|
|
|
var ResultIsBoolean10 = !A.foo();
|
|
|
|
var ResultIsBoolean11 = !(STRING + STRING);
|
|
|
|
var ResultIsBoolean12 = !STRING.charAt(0);
|
|
|
|
|
|
|
|
// multiple ! operator
|
|
|
|
var ResultIsBoolean13 = !!STRING;
|
|
|
|
var ResultIsBoolean14 = !!!(STRING + STRING);
|
|
|
|
|
|
|
|
// miss assignment operators
|
|
|
|
!"";
|
|
|
|
!STRING;
|
|
|
|
!STRING1;
|
|
|
|
!foo();
|
|
|
|
!objA.a,M.n;
|
|
|
|
|
|
|
|
//// [logicalNotOperatorWithStringType.js]
|
2014-08-12 00:54:12 +02:00
|
|
|
// ! operator on string type
|
2014-07-13 01:04:16 +02:00
|
|
|
var STRING;
|
|
|
|
var STRING1 = ["", "abc"];
|
2015-02-07 05:03:24 +01:00
|
|
|
function foo() { return "abc"; }
|
2014-07-13 01:04:16 +02:00
|
|
|
var A = (function () {
|
|
|
|
function A() {
|
|
|
|
}
|
2015-02-07 05:03:24 +01:00
|
|
|
A.foo = function () { return ""; };
|
2014-07-13 01:04:16 +02:00
|
|
|
return A;
|
|
|
|
})();
|
|
|
|
var M;
|
|
|
|
(function (M) {
|
|
|
|
M.n;
|
|
|
|
})(M || (M = {}));
|
|
|
|
var objA = new A();
|
2014-08-12 00:54:12 +02:00
|
|
|
// string type var
|
2014-07-13 01:04:16 +02:00
|
|
|
var ResultIsBoolean1 = !STRING;
|
|
|
|
var ResultIsBoolean2 = !STRING1;
|
2014-08-12 00:54:12 +02:00
|
|
|
// string type literal
|
2014-07-13 01:04:16 +02:00
|
|
|
var ResultIsBoolean3 = !"";
|
|
|
|
var ResultIsBoolean4 = !{ x: "", y: "" };
|
2015-02-07 05:03:24 +01:00
|
|
|
var ResultIsBoolean5 = !{ x: "", y: function (s) { return s; } };
|
2014-08-12 00:54:12 +02:00
|
|
|
// string type expressions
|
2014-07-13 01:04:16 +02:00
|
|
|
var ResultIsBoolean6 = !objA.a;
|
|
|
|
var ResultIsBoolean7 = !M.n;
|
|
|
|
var ResultIsBoolean8 = !STRING1[0];
|
|
|
|
var ResultIsBoolean9 = !foo();
|
|
|
|
var ResultIsBoolean10 = !A.foo();
|
|
|
|
var ResultIsBoolean11 = !(STRING + STRING);
|
|
|
|
var ResultIsBoolean12 = !STRING.charAt(0);
|
2014-08-12 00:54:12 +02:00
|
|
|
// multiple ! operator
|
2014-07-13 01:04:16 +02:00
|
|
|
var ResultIsBoolean13 = !!STRING;
|
|
|
|
var ResultIsBoolean14 = !!!(STRING + STRING);
|
2014-08-16 00:49:09 +02:00
|
|
|
// miss assignment operators
|
2014-07-13 01:04:16 +02:00
|
|
|
!"";
|
|
|
|
!STRING;
|
|
|
|
!STRING1;
|
|
|
|
!foo();
|
|
|
|
!objA.a, M.n;
|