Type inference test for comparison with BigInt
@@ -1442,6 +1442,17 @@ public final class TypeInferenceTest {
verify("assignBigIntOnBothSides", NO_TYPE);
}
+ @Test
+ public void testBigIntComparison() {
+ assuming("b", BIGINT_TYPE);
+ assuming("n", NUMBER_TYPE);
+
+ inFunction("bigintOnly = b > b; bigintAndOther = b > n");
+
+ verify("bigintOnly", BOOLEAN_TYPE);
+ verify("bigintAndOther", BOOLEAN_TYPE);
+ }
+
@Test
public void testAssertBoolean_narrowsAllTypeToBoolean() {
JSType startType = createNullableType(ALL_TYPE);
@@ -2470,6 +2481,18 @@ public final class TypeInferenceTest {
verify("x", NUMBER_TYPE);
}
+ @Test
+ public void testComparisonWithBigInt() {
+ inFunction("var x = 'foo'; var y = (x = 3n) < 4;");
+ verify("x", BIGINT_TYPE);
+ inFunction("var x = 'foo'; var y = (x = 3n) > 4;");
+ verify("x", BIGINT_TYPE);
+ inFunction("var x = 'foo'; var y = (x = 3n) <= 4;");
+ verify("x", BIGINT_TYPE);
+ inFunction("var x = 'foo'; var y = (x = 3n) >= 4;");
+ verify("x", BIGINT_TYPE);
+ }
+
@Test
public void testThrownExpression() {
inFunction("var x = 'foo'; "
