Add tests for operators with symbol operand

This commit is contained in:
Jason Freeman 2015-01-30 14:57:51 -08:00
parent 25fcbe2f9e
commit b60fa1467f
32 changed files with 536 additions and 0 deletions

View file

@ -0,0 +1,11 @@
tests/cases/conformance/es6/Symbols/symbolType1.ts(1,1): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
tests/cases/conformance/es6/Symbols/symbolType1.ts(2,19): error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
==== tests/cases/conformance/es6/Symbols/symbolType1.ts (2 errors) ====
Symbol() instanceof Symbol;
~~~~~~~~
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
Symbol instanceof Symbol();
~~~~~~~~
!!! error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.

View file

@ -0,0 +1,7 @@
//// [symbolType1.ts]
Symbol() instanceof Symbol;
Symbol instanceof Symbol();
//// [symbolType1.js]
Symbol() instanceof Symbol;
Symbol instanceof Symbol();

View file

@ -0,0 +1,34 @@
tests/cases/conformance/es6/Symbols/symbolType10.ts(2,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType10.ts(2,5): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType10.ts(3,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType10.ts(3,5): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType10.ts(4,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType10.ts(4,5): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType10.ts(6,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType10.ts(7,5): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
==== tests/cases/conformance/es6/Symbols/symbolType10.ts (8 errors) ====
var s = Symbol.for("bitwise");
s & s;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
s | s;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
s ^ s;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
s & 0;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
0 | s;
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.

View file

@ -0,0 +1,16 @@
//// [symbolType10.ts]
var s = Symbol.for("bitwise");
s & s;
s | s;
s ^ s;
s & 0;
0 | s;
//// [symbolType10.js]
var s = Symbol.for("bitwise");
s & s;
s | s;
s ^ s;
s & 0;
0 | s;

View file

@ -0,0 +1,17 @@
//// [symbolType11.ts]
var s = Symbol.for("logical");
s && s;
s && [];
0 && s;
s || s;
s || 1;
({}) || s;
//// [symbolType11.js]
var s = Symbol.for("logical");
s && s;
s && [];
0 && s;
s || s;
s || 1;
({}) || s;

View file

@ -0,0 +1,55 @@
//// [symbolType12.ts]
var s = Symbol.for("assign");
var str = "";
s *= s;
s *= 0;
s /= s;
s /= 0;
s %= s;
s %= 0;
s += s;
s += 0;
s += "";
str += s;
s -= s;
s -= 0;
s <<= s;
s <<= 0;
s >>= s;
s >>= 0;
s >>>= s;
s >>>= 0;
s &= s;
s &= 0;
s ^= s;
s ^= 0;
s |= s;
s |= 0;
//// [symbolType12.js]
var s = Symbol.for("assign");
var str = "";
s *= s;
s *= 0;
s /= s;
s /= 0;
s %= s;
s %= 0;
s += s;
s += 0;
s += "";
str += s;
s -= s;
s -= 0;
s <<= s;
s <<= 0;
s >>= s;
s >>= 0;
s >>>= s;
s >>>= 0;
s &= s;
s &= 0;
s ^= s;
s ^= 0;
s |= s;
s |= 0;

View file

@ -0,0 +1,17 @@
//// [symbolType13.ts]
var s = Symbol();
var x: any;
for (s in {}) { }
for (x in s) { }
for (var y in s) { }
//// [symbolType13.js]
var s = Symbol();
var x;
for (s in {}) {
}
for (x in s) {
}
for (var y in s) {
}

View file

@ -0,0 +1,7 @@
//// [symbolType2.ts]
Symbol.isConcatSpreadable in {};
"" in Symbol.toPrimitive;
//// [symbolType2.js]
Symbol.isConcatSpreadable in {};
"" in Symbol.toPrimitive;

View file

@ -0,0 +1,23 @@
//// [symbolType3.ts]
var s = Symbol();
delete Symbol.iterator;
void Symbol.toPrimitive;
typeof Symbol.toStringTag;
++s;
--s;
+ Symbol();
- Symbol();
~ Symbol();
! Symbol();
//// [symbolType3.js]
var s = Symbol();
delete Symbol.iterator;
void Symbol.toPrimitive;
typeof Symbol.toStringTag;
++s;
--s;
+Symbol();
-Symbol();
~Symbol();
!Symbol();

View file

@ -0,0 +1,12 @@
tests/cases/conformance/es6/Symbols/symbolType4.ts(2,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType4.ts(3,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
==== tests/cases/conformance/es6/Symbols/symbolType4.ts (2 errors) ====
var s = Symbol.for("postfix");
s++;
~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
s--;
~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.

View file

@ -0,0 +1,9 @@
//// [symbolType4.ts]
var s = Symbol.for("postfix");
s++;
s--;
//// [symbolType4.js]
var s = Symbol.for("postfix");
s++;
s--;

View file

@ -0,0 +1,34 @@
tests/cases/conformance/es6/Symbols/symbolType5.ts(2,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType5.ts(2,5): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType5.ts(3,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType5.ts(3,5): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType5.ts(4,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType5.ts(4,5): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType5.ts(6,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType5.ts(7,5): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
==== tests/cases/conformance/es6/Symbols/symbolType5.ts (8 errors) ====
var s = Symbol.for("multiply");
s * s;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
s / s;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
s % s;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
s * 0;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
0 / s;
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.

View file

@ -0,0 +1,16 @@
//// [symbolType5.ts]
var s = Symbol.for("multiply");
s * s;
s / s;
s % s;
s * 0;
0 / s;
//// [symbolType5.js]
var s = Symbol.for("multiply");
s * s;
s / s;
s % s;
s * 0;
0 / s;

View file

@ -0,0 +1,21 @@
//// [symbolType6.ts]
var s = Symbol.for("add");
s + s;
s - s;
s + "";
s + 0;
"" + s;
0 + s;
s - 0;
0 - s;
//// [symbolType6.js]
var s = Symbol.for("add");
s + s;
s - s;
s + "";
s + 0;
"" + s;
0 + s;
s - 0;
0 - s;

View file

@ -0,0 +1,37 @@
tests/cases/conformance/es6/Symbols/symbolType7.ts(2,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType7.ts(2,6): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType7.ts(3,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType7.ts(4,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType7.ts(4,6): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType7.ts(5,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType7.ts(6,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType7.ts(6,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/Symbols/symbolType7.ts(7,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
==== tests/cases/conformance/es6/Symbols/symbolType7.ts (9 errors) ====
var s = Symbol.for("shift");
s << s;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
s << 0;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
s >> s;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
s >> 0;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
s >>> s;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
s >>> 0;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.

View file

@ -0,0 +1,17 @@
//// [symbolType7.ts]
var s = Symbol.for("shift");
s << s;
s << 0;
s >> s;
s >> 0;
s >>> s;
s >>> 0;
//// [symbolType7.js]
var s = Symbol.for("shift");
s << s;
s << 0;
s >> s;
s >> 0;
s >>> s;
s >>> 0;

View file

@ -0,0 +1,21 @@
//// [symbolType8.ts]
var s = Symbol.for("compare");
s < s;
s < 0;
s > s;
s > 0;
s <= s;
s <= 0;
s >= s;
s >= 0;
//// [symbolType8.js]
var s = Symbol.for("compare");
s < s;
s < 0;
s > s;
s > 0;
s <= s;
s <= 0;
s >= s;
s >= 0;

View file

@ -0,0 +1,21 @@
//// [symbolType9.ts]
var s = Symbol.for("equal");
s == s;
s == true;
s != s;
0 != s;
s === s;
s === 1;
s !== s;
false !== s;
//// [symbolType9.js]
var s = Symbol.for("equal");
s == s;
s == true;
s != s;
0 != s;
s === s;
s === 1;
s !== s;
false !== s;

View file

@ -0,0 +1,44 @@
=== tests/cases/conformance/es6/Symbols/symbolType9.ts ===
var s = Symbol.for("equal");
>s : Symbol
>Symbol.for("equal") : Symbol
>Symbol.for : (key: string) => Symbol
>Symbol : SymbolConstructor
>for : (key: string) => Symbol
s == s;
>s == s : boolean
>s : Symbol
>s : Symbol
s == true;
>s == true : boolean
>s : Symbol
s != s;
>s != s : boolean
>s : Symbol
>s : Symbol
0 != s;
>0 != s : boolean
>s : Symbol
s === s;
>s === s : boolean
>s : Symbol
>s : Symbol
s === 1;
>s === 1 : boolean
>s : Symbol
s !== s;
>s !== s : boolean
>s : Symbol
>s : Symbol
false !== s;
>false !== s : boolean
>s : Symbol

View file

@ -0,0 +1,3 @@
//@target: ES6
Symbol() instanceof Symbol;
Symbol instanceof Symbol();

View file

@ -0,0 +1,8 @@
//@target: ES6
var s = Symbol.for("bitwise");
s & s;
s | s;
s ^ s;
s & 0;
0 | s;

View file

@ -0,0 +1,8 @@
//@target: ES6
var s = Symbol.for("logical");
s && s;
s && [];
0 && s;
s || s;
s || 1;
({}) || s;

View file

@ -0,0 +1,27 @@
//@target: ES6
var s = Symbol.for("assign");
var str = "";
s *= s;
s *= 0;
s /= s;
s /= 0;
s %= s;
s %= 0;
s += s;
s += 0;
s += "";
str += s;
s -= s;
s -= 0;
s <<= s;
s <<= 0;
s >>= s;
s >>= 0;
s >>>= s;
s >>>= 0;
s &= s;
s &= 0;
s ^= s;
s ^= 0;
s |= s;
s |= 0;

View file

@ -0,0 +1,7 @@
//@target: ES6
var s = Symbol();
var x: any;
for (s in {}) { }
for (x in s) { }
for (var y in s) { }

View file

@ -0,0 +1,3 @@
//@target: ES6
Symbol.isConcatSpreadable in {};
"" in Symbol.toPrimitive;

View file

@ -0,0 +1,11 @@
//@target: ES6
var s = Symbol();
delete Symbol.iterator;
void Symbol.toPrimitive;
typeof Symbol.toStringTag;
++s;
--s;
+ Symbol();
- Symbol();
~ Symbol();
! Symbol();

View file

@ -0,0 +1,4 @@
//@target: ES6
var s = Symbol.for("postfix");
s++;
s--;

View file

@ -0,0 +1,8 @@
//@target: ES6
var s = Symbol.for("multiply");
s * s;
s / s;
s % s;
s * 0;
0 / s;

View file

@ -0,0 +1,10 @@
//@target: ES6
var s = Symbol.for("add");
s + s;
s - s;
s + "";
s + 0;
"" + s;
0 + s;
s - 0;
0 - s;

View file

@ -0,0 +1,8 @@
//@target: ES6
var s = Symbol.for("shift");
s << s;
s << 0;
s >> s;
s >> 0;
s >>> s;
s >>> 0;

View file

@ -0,0 +1,10 @@
//@target: ES6
var s = Symbol.for("compare");
s < s;
s < 0;
s > s;
s > 0;
s <= s;
s <= 0;
s >= s;
s >= 0;

View file

@ -0,0 +1,10 @@
//@target: ES6
var s = Symbol.for("equal");
s == s;
s == true;
s != s;
0 != s;
s === s;
s === 1;
s !== s;
false !== s;