Skip to content

Commit b60fa14

Browse files
committed
Add tests for operators with symbol operand
1 parent 25fcbe2 commit b60fa14

32 files changed

+536
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
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.
2+
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.
3+
4+
5+
==== tests/cases/conformance/es6/Symbols/symbolType1.ts (2 errors) ====
6+
Symbol() instanceof Symbol;
7+
~~~~~~~~
8+
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
9+
Symbol instanceof Symbol();
10+
~~~~~~~~
11+
!!! 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.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//// [symbolType1.ts]
2+
Symbol() instanceof Symbol;
3+
Symbol instanceof Symbol();
4+
5+
//// [symbolType1.js]
6+
Symbol() instanceof Symbol;
7+
Symbol instanceof Symbol();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
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.
2+
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.
3+
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.
4+
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.
5+
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.
6+
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.
7+
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.
8+
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.
9+
10+
11+
==== tests/cases/conformance/es6/Symbols/symbolType10.ts (8 errors) ====
12+
var s = Symbol.for("bitwise");
13+
s & s;
14+
~
15+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
16+
~
17+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
18+
s | s;
19+
~
20+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
21+
~
22+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
23+
s ^ s;
24+
~
25+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
26+
~
27+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
28+
29+
s & 0;
30+
~
31+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
32+
0 | s;
33+
~
34+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [symbolType10.ts]
2+
var s = Symbol.for("bitwise");
3+
s & s;
4+
s | s;
5+
s ^ s;
6+
7+
s & 0;
8+
0 | s;
9+
10+
//// [symbolType10.js]
11+
var s = Symbol.for("bitwise");
12+
s & s;
13+
s | s;
14+
s ^ s;
15+
s & 0;
16+
0 | s;
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//// [symbolType11.ts]
2+
var s = Symbol.for("logical");
3+
s && s;
4+
s && [];
5+
0 && s;
6+
s || s;
7+
s || 1;
8+
({}) || s;
9+
10+
//// [symbolType11.js]
11+
var s = Symbol.for("logical");
12+
s && s;
13+
s && [];
14+
0 && s;
15+
s || s;
16+
s || 1;
17+
({}) || s;
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//// [symbolType12.ts]
2+
var s = Symbol.for("assign");
3+
var str = "";
4+
s *= s;
5+
s *= 0;
6+
s /= s;
7+
s /= 0;
8+
s %= s;
9+
s %= 0;
10+
s += s;
11+
s += 0;
12+
s += "";
13+
str += s;
14+
s -= s;
15+
s -= 0;
16+
s <<= s;
17+
s <<= 0;
18+
s >>= s;
19+
s >>= 0;
20+
s >>>= s;
21+
s >>>= 0;
22+
s &= s;
23+
s &= 0;
24+
s ^= s;
25+
s ^= 0;
26+
s |= s;
27+
s |= 0;
28+
29+
//// [symbolType12.js]
30+
var s = Symbol.for("assign");
31+
var str = "";
32+
s *= s;
33+
s *= 0;
34+
s /= s;
35+
s /= 0;
36+
s %= s;
37+
s %= 0;
38+
s += s;
39+
s += 0;
40+
s += "";
41+
str += s;
42+
s -= s;
43+
s -= 0;
44+
s <<= s;
45+
s <<= 0;
46+
s >>= s;
47+
s >>= 0;
48+
s >>>= s;
49+
s >>>= 0;
50+
s &= s;
51+
s &= 0;
52+
s ^= s;
53+
s ^= 0;
54+
s |= s;
55+
s |= 0;
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//// [symbolType13.ts]
2+
var s = Symbol();
3+
var x: any;
4+
5+
for (s in {}) { }
6+
for (x in s) { }
7+
for (var y in s) { }
8+
9+
//// [symbolType13.js]
10+
var s = Symbol();
11+
var x;
12+
for (s in {}) {
13+
}
14+
for (x in s) {
15+
}
16+
for (var y in s) {
17+
}
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//// [symbolType2.ts]
2+
Symbol.isConcatSpreadable in {};
3+
"" in Symbol.toPrimitive;
4+
5+
//// [symbolType2.js]
6+
Symbol.isConcatSpreadable in {};
7+
"" in Symbol.toPrimitive;
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//// [symbolType3.ts]
2+
var s = Symbol();
3+
delete Symbol.iterator;
4+
void Symbol.toPrimitive;
5+
typeof Symbol.toStringTag;
6+
++s;
7+
--s;
8+
+ Symbol();
9+
- Symbol();
10+
~ Symbol();
11+
! Symbol();
12+
13+
//// [symbolType3.js]
14+
var s = Symbol();
15+
delete Symbol.iterator;
16+
void Symbol.toPrimitive;
17+
typeof Symbol.toStringTag;
18+
++s;
19+
--s;
20+
+Symbol();
21+
-Symbol();
22+
~Symbol();
23+
!Symbol();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
tests/cases/conformance/es6/Symbols/symbolType4.ts(2,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
2+
tests/cases/conformance/es6/Symbols/symbolType4.ts(3,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
3+
4+
5+
==== tests/cases/conformance/es6/Symbols/symbolType4.ts (2 errors) ====
6+
var s = Symbol.for("postfix");
7+
s++;
8+
~
9+
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
10+
s--;
11+
~
12+
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [symbolType4.ts]
2+
var s = Symbol.for("postfix");
3+
s++;
4+
s--;
5+
6+
//// [symbolType4.js]
7+
var s = Symbol.for("postfix");
8+
s++;
9+
s--;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
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.
2+
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.
3+
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.
4+
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.
5+
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.
6+
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.
7+
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.
8+
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.
9+
10+
11+
==== tests/cases/conformance/es6/Symbols/symbolType5.ts (8 errors) ====
12+
var s = Symbol.for("multiply");
13+
s * s;
14+
~
15+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
16+
~
17+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
18+
s / s;
19+
~
20+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
21+
~
22+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
23+
s % s;
24+
~
25+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
26+
~
27+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
28+
29+
s * 0;
30+
~
31+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
32+
0 / s;
33+
~
34+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [symbolType5.ts]
2+
var s = Symbol.for("multiply");
3+
s * s;
4+
s / s;
5+
s % s;
6+
7+
s * 0;
8+
0 / s;
9+
10+
//// [symbolType5.js]
11+
var s = Symbol.for("multiply");
12+
s * s;
13+
s / s;
14+
s % s;
15+
s * 0;
16+
0 / s;
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//// [symbolType6.ts]
2+
var s = Symbol.for("add");
3+
s + s;
4+
s - s;
5+
s + "";
6+
s + 0;
7+
"" + s;
8+
0 + s;
9+
s - 0;
10+
0 - s;
11+
12+
//// [symbolType6.js]
13+
var s = Symbol.for("add");
14+
s + s;
15+
s - s;
16+
s + "";
17+
s + 0;
18+
"" + s;
19+
0 + s;
20+
s - 0;
21+
0 - s;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
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.
2+
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.
3+
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.
4+
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.
5+
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.
6+
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.
7+
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.
8+
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.
9+
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.
10+
11+
12+
==== tests/cases/conformance/es6/Symbols/symbolType7.ts (9 errors) ====
13+
var s = Symbol.for("shift");
14+
s << s;
15+
~
16+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
17+
~
18+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
19+
s << 0;
20+
~
21+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
22+
s >> s;
23+
~
24+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
25+
~
26+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
27+
s >> 0;
28+
~
29+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
30+
s >>> s;
31+
~
32+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
33+
~
34+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
35+
s >>> 0;
36+
~
37+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//// [symbolType7.ts]
2+
var s = Symbol.for("shift");
3+
s << s;
4+
s << 0;
5+
s >> s;
6+
s >> 0;
7+
s >>> s;
8+
s >>> 0;
9+
10+
//// [symbolType7.js]
11+
var s = Symbol.for("shift");
12+
s << s;
13+
s << 0;
14+
s >> s;
15+
s >> 0;
16+
s >>> s;
17+
s >>> 0;
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//// [symbolType8.ts]
2+
var s = Symbol.for("compare");
3+
s < s;
4+
s < 0;
5+
s > s;
6+
s > 0;
7+
s <= s;
8+
s <= 0;
9+
s >= s;
10+
s >= 0;
11+
12+
//// [symbolType8.js]
13+
var s = Symbol.for("compare");
14+
s < s;
15+
s < 0;
16+
s > s;
17+
s > 0;
18+
s <= s;
19+
s <= 0;
20+
s >= s;
21+
s >= 0;
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//// [symbolType9.ts]
2+
var s = Symbol.for("equal");
3+
s == s;
4+
s == true;
5+
s != s;
6+
0 != s;
7+
s === s;
8+
s === 1;
9+
s !== s;
10+
false !== s;
11+
12+
//// [symbolType9.js]
13+
var s = Symbol.for("equal");
14+
s == s;
15+
s == true;
16+
s != s;
17+
0 != s;
18+
s === s;
19+
s === 1;
20+
s !== s;
21+
false !== s;

0 commit comments

Comments
 (0)