Skip to content

Commit bf3bf34

Browse files
Add more test coverage for binary expressions (#2515)
1 parent 098d8b4 commit bf3bf34

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

Diff for: tests/compiler/binary-error.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"asc_flags": [
3+
],
4+
"stderr": [
5+
"TS2365: Operator '<' cannot be applied to types 'binary-error/A | null' and 'i8'.",
6+
"TS2365: Operator '>' cannot be applied to types 'binary-error/A | null' and 'i8'.",
7+
"TS2365: Operator '<=' cannot be applied to types 'binary-error/A | null' and 'i8'.",
8+
"TS2365: Operator '>=' cannot be applied to types 'binary-error/A | null' and 'i8'.",
9+
"TS2365: Operator '==' cannot be applied to types 'binary-error/A | null' and 'i8'.",
10+
"TS2365: Operator '!=' cannot be applied to types 'binary-error/A | null' and 'i8'.",
11+
"TS2365: Operator '+' cannot be applied to types 'i8' and '() => void'.",
12+
"TS2365: Operator '-' cannot be applied to types 'i8' and '() => void'.",
13+
"TS2365: Operator '*' cannot be applied to types 'i8' and '() => void'.",
14+
"TS2365: Operator '**' cannot be applied to types 'i8' and '() => void'.",
15+
"TS2365: Operator '/' cannot be applied to types 'i8' and '() => void'.",
16+
"TS2365: Operator '%' cannot be applied to types 'i8' and '() => void'.",
17+
"TS2469: The '>>' operator cannot be applied to type '() => void'.",
18+
"TS2469: The '<<' operator cannot be applied to type '() => void'.",
19+
"TS2469: The '>>>' operator cannot be applied to type '() => void'.",
20+
"TS2469: The '&' operator cannot be applied to type '() => void'.",
21+
"TS2469: The '|' operator cannot be applied to type '() => void'.",
22+
"TS2469: The '^' operator cannot be applied to type '() => void'."
23+
]
24+
}

Diff for: tests/compiler/binary-error.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class A { }
2+
let b: A | null;
3+
let c: i8 = 1;
4+
b < c; // TS2365: Operator '<' cannot be applied to types 'binary-error/A | null' and 'i8'.
5+
b > c; // TS2365: Operator '>' cannot be applied to types 'binary-error/A | null' and 'i8'.
6+
b <= c; // TS2365: Operator '<=' cannot be applied to types 'binary-error/A | null' and 'i8'.
7+
b >= c; // TS2365: Operator '>=' cannot be applied to types 'binary-error/A | null' and 'i8'.
8+
b == c; // TS2365: Operator '==' cannot be applied to types 'binary-error/A | null' and 'i8'.
9+
b != c; // TS2365: Operator '!=' cannot be applied to types 'binary-error/A | null' and 'i8'.
10+
let d: () => void = (): void => { };
11+
c + d; // TS2365: Operator '+' cannot be applied to types 'i8' and '() => void'.
12+
c - d; // TS2365: Operator '-' cannot be applied to types 'i8' and '() => void'.
13+
c * d; // TS2365: Operator '*' cannot be applied to types 'i8' and '() => void'.
14+
c ** d; // TS2365: Operator '**' cannot be applied to types 'i8' and '() => void'.
15+
c / d; // TS2365: Operator '/' cannot be applied to types 'i8' and '() => void'.
16+
c % d; // TS2365: Operator '%' cannot be applied to types 'i8' and '() => void'.
17+
d >> 1; // TS2469: The '>>' operator cannot be applied to type '() => void'.
18+
d << 1; // TS2469: The '<<' operator cannot be applied to type '() => void'.
19+
d >>> 1; // TS2469: The '>>>' operator cannot be applied to type '() => void'.
20+
d & 1; // TS2469: The '&' operator cannot be applied to type '() => void'.
21+
d | 1; // TS2469: The '|' operator cannot be applied to type '() => void'.
22+
d ^ 1; // TS2469: The '^' operator cannot be applied to type '() => void'.

0 commit comments

Comments
 (0)