Type checking test for >=, <, <= guard expressions
@@ -678,6 +678,60 @@ fn infer_error_test() {
}
);
+ assert_error!(
+ "case [3.33], 1 { x, y if x >= y -> 1 }",
+ Error::CouldNotUnify {
+ location: SrcSpan { start: 25, end: 26 },
+ expected: int(),
+ given: list(float())
+ }
+ );
+
+ assert_error!(
+ "case 1, 2.22, \"three\" { x, _, y if x >= y -> 1 }",
+ Error::CouldNotUnify {
+ location: SrcSpan { start: 40, end: 41 },
+ expected: int(),
+ given: string()
+ }
+ );
+
+ assert_error!(
+ "case [3.33], 1 { x, y if x < y -> 1 }",
+ Error::CouldNotUnify {
+ location: SrcSpan { start: 25, end: 26 },
+ expected: int(),
+ given: list(float())
+ }
+ );
+
+ assert_error!(
+ "case 1, 2.22, \"three\" { x, _, y if x < y -> 1 }",
+ Error::CouldNotUnify {
+ location: SrcSpan { start: 39, end: 40 },
+ expected: int(),
+ given: string()
+ }
+ );
+
+ assert_error!(
+ "case [3.33], 1 { x, y if x <= y -> 1 }",
+ Error::CouldNotUnify {
+ location: SrcSpan { start: 25, end: 26 },
+ expected: int(),
+ given: list(float())
+ }
+ );
+
+ assert_error!(
+ "case 1, 2.22, \"three\" { x, _, y if x <= y -> 1 }",
+ Error::CouldNotUnify {
+ location: SrcSpan { start: 40, end: 41 },
+ expected: int(),
+ given: string()
+ }
+ );
+
assert_error!(
"case [3], 1.1 { x, y if x >. y -> 1 }",
Error::CouldNotUnify {
@@ -695,6 +749,7 @@ fn infer_error_test() {
given: string()
}
);
+
assert_error!(
"case [3], 1.1 { x, y if x >=. y -> 1 }",
Error::CouldNotUnify {
