Skip to content

Commit 82c26cd

Browse files
committed
Adding selected tests from #6196
1 parent 868d5e6 commit 82c26cd

11 files changed

+192
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var a = "foo" === "bar" as string;
2+
var b = "foo" !== ("bar" as string);
3+
var c = "foo" == (<any>"bar");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type EnhancedString = string & { enhancements: any };
2+
3+
var a = "foo" === "bar" as "baz";
4+
var b = "foo" !== ("bar" as "foo");
5+
var c = "foo" == (<number>"bar");
6+
var d = "foo" === ("bar" as EnhancedString);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
let x: "foo";
2+
let y: "foo" | "bar";
3+
4+
let b: boolean;
5+
b = x === y;
6+
b = "foo" === y
7+
b = y === "foo";
8+
b = "foo" === "bar";
9+
b = "bar" === x;
10+
b = x === "bar";
11+
b = y === "bar";
12+
b = "bar" === y;
13+
14+
b = x !== y;
15+
b = "foo" !== y
16+
b = y !== "foo";
17+
b = "foo" !== "bar";
18+
b = "bar" !== x;
19+
b = x !== "bar";
20+
b = y !== "bar";
21+
b = "bar" !== y;
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
let x: "foo";
2+
let y: "foo" | "bar";
3+
4+
let b: boolean;
5+
b = x == y;
6+
b = "foo" == y
7+
b = y == "foo";
8+
b = "foo" == "bar";
9+
b = "bar" == x;
10+
b = x == "bar";
11+
b = y == "bar";
12+
b = "bar" == y;
13+
14+
b = x != y;
15+
b = "foo" != y
16+
b = y != "foo";
17+
b = "foo" != "bar";
18+
b = "bar" != x;
19+
b = x != "bar";
20+
b = y != "bar";
21+
b = "bar" != y;
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
interface Runnable {
2+
isRunning: boolean;
3+
}
4+
5+
interface Refrigerator extends Runnable {
6+
makesFoodGoBrrr: boolean;
7+
}
8+
9+
let x: string;
10+
let y: "foo" | Refrigerator;
11+
12+
let b: boolean;
13+
b = x === y;
14+
b = "foo" === y
15+
b = y === "foo";
16+
b = "foo" === "bar";
17+
b = "bar" === x;
18+
b = x === "bar";
19+
b = y === "bar";
20+
b = "bar" === y;
21+
22+
b = x !== y;
23+
b = "foo" !== y
24+
b = y !== "foo";
25+
b = "foo" !== "bar";
26+
b = "bar" !== x;
27+
b = x !== "bar";
28+
b = y !== "bar";
29+
b = "bar" !== y;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
interface Runnable {
2+
isRunning: boolean;
3+
}
4+
5+
interface Refrigerator extends Runnable {
6+
makesFoodGoBrrr: boolean;
7+
}
8+
9+
let x: string;
10+
let y: "foo" | Refrigerator;
11+
12+
let b: boolean;
13+
b = x == y;
14+
b = "foo" == y
15+
b = y == "foo";
16+
b = "foo" == "bar";
17+
b = "bar" == x;
18+
b = x == "bar";
19+
b = y == "bar";
20+
b = "bar" == y;
21+
22+
b = x != y;
23+
b = "foo" != y
24+
b = y != "foo";
25+
b = "foo" != "bar";
26+
b = "bar" != x;
27+
b = x != "bar";
28+
b = y != "bar";
29+
b = "bar" != y;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
let x: "foo";
2+
let y: "foo" | "bar";
3+
4+
switch (x) {
5+
case "foo":
6+
break;
7+
case "bar":
8+
break;
9+
case y:
10+
y;
11+
break;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
let x: "foo";
2+
let y: "foo" | "bar";
3+
4+
let b: boolean;
5+
b = x == y;
6+
b = "foo" == y
7+
b = y == "foo";
8+
b = "foo" == "bar";
9+
10+
b = x != y;
11+
b = "foo" != y
12+
b = y != "foo";
13+
b = "foo" != "bar";
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
let x: "foo";
2+
let y: "foo" | "bar";
3+
let z: "bar";
4+
5+
declare function randBool(): boolean;
6+
7+
switch (x) {
8+
case randBool() ? "foo" : "baz":
9+
break;
10+
case (randBool() ? ("bar") : "baz" ? "bar" : "baz"):
11+
break;
12+
case (("bar")):
13+
break;
14+
case (x, y, ("baz")):
15+
x;
16+
y;
17+
break;
18+
case (("foo" || ("bar"))):
19+
break;
20+
case (("bar" || ("baz"))):
21+
break;
22+
case z || "baz":
23+
case "baz" || z:
24+
z;
25+
break;
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
let x: "foo";
2+
let y: "foo" | "bar";
3+
4+
declare function randBool(): boolean;
5+
6+
switch (y) {
7+
case "foo", x:
8+
break;
9+
case x, "foo":
10+
break;
11+
case x, "baz":
12+
break;
13+
case "baz", x:
14+
break;
15+
case "baz" && "bar":
16+
break;
17+
case "baz" && ("foo" || "bar"):
18+
break;
19+
case "bar" && ("baz" || "bar"):
20+
break;
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
let fooOrBar: "foo" | "bar";
2+
3+
let a = "foo" as "bar";
4+
let b = "bar" as "foo";
5+
let c = fooOrBar as "foo";
6+
let d = fooOrBar as "bar";
7+
let e = fooOrBar as "baz";
8+
let f = "baz" as typeof fooOrBar;

0 commit comments

Comments
 (0)