2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithEnumType.ts ===
|
|
|
|
// + operator on enum type
|
|
|
|
|
|
|
|
enum ENUM { };
|
|
|
|
>ENUM : ENUM
|
|
|
|
|
2014-10-07 07:27:22 +02:00
|
|
|
enum ENUM1 { A, B, "" };
|
2014-08-15 23:33:16 +02:00
|
|
|
>ENUM1 : ENUM1
|
2014-10-07 07:27:22 +02:00
|
|
|
>A : ENUM1
|
|
|
|
>B : ENUM1
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// enum type var
|
|
|
|
var ResultIsNumber1 = +ENUM;
|
|
|
|
>ResultIsNumber1 : number
|
|
|
|
>+ENUM : number
|
|
|
|
>ENUM : typeof ENUM
|
|
|
|
|
|
|
|
var ResultIsNumber2 = +ENUM1;
|
|
|
|
>ResultIsNumber2 : number
|
|
|
|
>+ENUM1 : number
|
|
|
|
>ENUM1 : typeof ENUM1
|
|
|
|
|
|
|
|
// enum type expressions
|
2014-10-08 20:11:36 +02:00
|
|
|
var ResultIsNumber3 = +ENUM1["A"];
|
2014-08-15 23:33:16 +02:00
|
|
|
>ResultIsNumber3 : number
|
2014-10-08 20:11:36 +02:00
|
|
|
>+ENUM1["A"] : number
|
|
|
|
>ENUM1["A"] : ENUM1
|
2014-08-15 23:33:16 +02:00
|
|
|
>ENUM1 : typeof ENUM1
|
|
|
|
|
2014-10-08 20:11:36 +02:00
|
|
|
var ResultIsNumber4 = +(ENUM[0] + ENUM1["B"]);
|
2014-08-15 23:33:16 +02:00
|
|
|
>ResultIsNumber4 : number
|
2014-10-08 20:11:36 +02:00
|
|
|
>+(ENUM[0] + ENUM1["B"]) : number
|
|
|
|
>(ENUM[0] + ENUM1["B"]) : string
|
|
|
|
>ENUM[0] + ENUM1["B"] : string
|
2014-08-15 23:33:16 +02:00
|
|
|
>ENUM[0] : string
|
|
|
|
>ENUM : typeof ENUM
|
2014-10-08 20:11:36 +02:00
|
|
|
>ENUM1["B"] : ENUM1
|
2014-08-15 23:33:16 +02:00
|
|
|
>ENUM1 : typeof ENUM1
|
|
|
|
|
|
|
|
// miss assignment operators
|
|
|
|
+ENUM;
|
|
|
|
>+ENUM : number
|
|
|
|
>ENUM : typeof ENUM
|
|
|
|
|
|
|
|
+ENUM1;
|
|
|
|
>+ENUM1 : number
|
|
|
|
>ENUM1 : typeof ENUM1
|
|
|
|
|
2014-10-08 20:11:36 +02:00
|
|
|
+ENUM1.B;
|
|
|
|
>+ENUM1.B : number
|
|
|
|
>ENUM1.B : ENUM1
|
2014-08-15 23:33:16 +02:00
|
|
|
>ENUM1 : typeof ENUM1
|
2014-10-08 20:11:36 +02:00
|
|
|
>B : ENUM1
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
+ENUM, ENUM1;
|
|
|
|
>+ENUM, ENUM1 : typeof ENUM1
|
|
|
|
>+ENUM : number
|
|
|
|
>ENUM : typeof ENUM
|
|
|
|
>ENUM1 : typeof ENUM1
|
|
|
|
|