TypeScript/tests/baselines/reference/plusOperatorWithStringType.types
2015-04-13 14:29:37 -07:00

156 lines
6.2 KiB
Plaintext

=== tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithStringType.ts ===
// + operator on string type
var STRING: string;
>STRING : string, Symbol(STRING, Decl(plusOperatorWithStringType.ts, 1, 3))
var STRING1: string[] = ["", "abc"];
>STRING1 : string[], Symbol(STRING1, Decl(plusOperatorWithStringType.ts, 2, 3))
>["", "abc"] : string[]
>"" : string
>"abc" : string
function foo(): string { return "abc"; }
>foo : () => string, Symbol(foo, Decl(plusOperatorWithStringType.ts, 2, 36))
>"abc" : string
class A {
>A : A, Symbol(A, Decl(plusOperatorWithStringType.ts, 4, 40))
public a: string;
>a : string, Symbol(a, Decl(plusOperatorWithStringType.ts, 6, 9))
static foo() { return ""; }
>foo : () => string, Symbol(A.foo, Decl(plusOperatorWithStringType.ts, 7, 21))
>"" : string
}
module M {
>M : typeof M, Symbol(M, Decl(plusOperatorWithStringType.ts, 9, 1))
export var n: string;
>n : string, Symbol(n, Decl(plusOperatorWithStringType.ts, 11, 14))
}
var objA = new A();
>objA : A, Symbol(objA, Decl(plusOperatorWithStringType.ts, 14, 3))
>new A() : A
>A : typeof A, Symbol(A, Decl(plusOperatorWithStringType.ts, 4, 40))
// string type var
var ResultIsNumber1 = +STRING;
>ResultIsNumber1 : number, Symbol(ResultIsNumber1, Decl(plusOperatorWithStringType.ts, 17, 3))
>+STRING : number
>STRING : string, Symbol(STRING, Decl(plusOperatorWithStringType.ts, 1, 3))
var ResultIsNumber2 = +STRING1;
>ResultIsNumber2 : number, Symbol(ResultIsNumber2, Decl(plusOperatorWithStringType.ts, 18, 3))
>+STRING1 : number
>STRING1 : string[], Symbol(STRING1, Decl(plusOperatorWithStringType.ts, 2, 3))
// string type literal
var ResultIsNumber3 = +"";
>ResultIsNumber3 : number, Symbol(ResultIsNumber3, Decl(plusOperatorWithStringType.ts, 21, 3))
>+"" : number
>"" : string
var ResultIsNumber4 = +{ x: "", y: "" };
>ResultIsNumber4 : number, Symbol(ResultIsNumber4, Decl(plusOperatorWithStringType.ts, 22, 3))
>+{ x: "", y: "" } : number
>{ x: "", y: "" } : { x: string; y: string; }
>x : string, Symbol(x, Decl(plusOperatorWithStringType.ts, 22, 24))
>"" : string
>y : string, Symbol(y, Decl(plusOperatorWithStringType.ts, 22, 31))
>"" : string
var ResultIsNumber5 = +{ x: "", y: (s: string) => { return s; } };
>ResultIsNumber5 : number, Symbol(ResultIsNumber5, Decl(plusOperatorWithStringType.ts, 23, 3))
>+{ x: "", y: (s: string) => { return s; } } : number
>{ x: "", y: (s: string) => { return s; } } : { x: string; y: (s: string) => string; }
>x : string, Symbol(x, Decl(plusOperatorWithStringType.ts, 23, 24))
>"" : string
>y : (s: string) => string, Symbol(y, Decl(plusOperatorWithStringType.ts, 23, 31))
>(s: string) => { return s; } : (s: string) => string
>s : string, Symbol(s, Decl(plusOperatorWithStringType.ts, 23, 36))
>s : string, Symbol(s, Decl(plusOperatorWithStringType.ts, 23, 36))
// string type expressions
var ResultIsNumber6 = +objA.a;
>ResultIsNumber6 : number, Symbol(ResultIsNumber6, Decl(plusOperatorWithStringType.ts, 26, 3))
>+objA.a : number
>objA.a : string, Symbol(A.a, Decl(plusOperatorWithStringType.ts, 6, 9))
>objA : A, Symbol(objA, Decl(plusOperatorWithStringType.ts, 14, 3))
>a : string, Symbol(A.a, Decl(plusOperatorWithStringType.ts, 6, 9))
var ResultIsNumber7 = +M.n;
>ResultIsNumber7 : number, Symbol(ResultIsNumber7, Decl(plusOperatorWithStringType.ts, 27, 3))
>+M.n : number
>M.n : string, Symbol(M.n, Decl(plusOperatorWithStringType.ts, 11, 14))
>M : typeof M, Symbol(M, Decl(plusOperatorWithStringType.ts, 9, 1))
>n : string, Symbol(M.n, Decl(plusOperatorWithStringType.ts, 11, 14))
var ResultIsNumber8 = +STRING1[0];
>ResultIsNumber8 : number, Symbol(ResultIsNumber8, Decl(plusOperatorWithStringType.ts, 28, 3))
>+STRING1[0] : number
>STRING1[0] : string
>STRING1 : string[], Symbol(STRING1, Decl(plusOperatorWithStringType.ts, 2, 3))
>0 : number
var ResultIsNumber9 = +foo();
>ResultIsNumber9 : number, Symbol(ResultIsNumber9, Decl(plusOperatorWithStringType.ts, 29, 3))
>+foo() : number
>foo() : string
>foo : () => string, Symbol(foo, Decl(plusOperatorWithStringType.ts, 2, 36))
var ResultIsNumber10 = +A.foo();
>ResultIsNumber10 : number, Symbol(ResultIsNumber10, Decl(plusOperatorWithStringType.ts, 30, 3))
>+A.foo() : number
>A.foo() : string
>A.foo : () => string, Symbol(A.foo, Decl(plusOperatorWithStringType.ts, 7, 21))
>A : typeof A, Symbol(A, Decl(plusOperatorWithStringType.ts, 4, 40))
>foo : () => string, Symbol(A.foo, Decl(plusOperatorWithStringType.ts, 7, 21))
var ResultIsNumber11 = +(STRING + STRING);
>ResultIsNumber11 : number, Symbol(ResultIsNumber11, Decl(plusOperatorWithStringType.ts, 31, 3))
>+(STRING + STRING) : number
>(STRING + STRING) : string
>STRING + STRING : string
>STRING : string, Symbol(STRING, Decl(plusOperatorWithStringType.ts, 1, 3))
>STRING : string, Symbol(STRING, Decl(plusOperatorWithStringType.ts, 1, 3))
var ResultIsNumber12 = +STRING.charAt(0);
>ResultIsNumber12 : number, Symbol(ResultIsNumber12, Decl(plusOperatorWithStringType.ts, 32, 3))
>+STRING.charAt(0) : number
>STRING.charAt(0) : string
>STRING.charAt : (pos: number) => string, Symbol(String.charAt, Decl(lib.d.ts, 279, 23))
>STRING : string, Symbol(STRING, Decl(plusOperatorWithStringType.ts, 1, 3))
>charAt : (pos: number) => string, Symbol(String.charAt, Decl(lib.d.ts, 279, 23))
>0 : number
// miss assignment operators
+"";
>+"" : number
>"" : string
+STRING;
>+STRING : number
>STRING : string, Symbol(STRING, Decl(plusOperatorWithStringType.ts, 1, 3))
+STRING1;
>+STRING1 : number
>STRING1 : string[], Symbol(STRING1, Decl(plusOperatorWithStringType.ts, 2, 3))
+foo();
>+foo() : number
>foo() : string
>foo : () => string, Symbol(foo, Decl(plusOperatorWithStringType.ts, 2, 36))
+objA.a,M.n;
>+objA.a,M.n : string
>+objA.a : number
>objA.a : string, Symbol(A.a, Decl(plusOperatorWithStringType.ts, 6, 9))
>objA : A, Symbol(objA, Decl(plusOperatorWithStringType.ts, 14, 3))
>a : string, Symbol(A.a, Decl(plusOperatorWithStringType.ts, 6, 9))
>M.n : string, Symbol(M.n, Decl(plusOperatorWithStringType.ts, 11, 14))
>M : typeof M, Symbol(M, Decl(plusOperatorWithStringType.ts, 9, 1))
>n : string, Symbol(M.n, Decl(plusOperatorWithStringType.ts, 11, 14))