Skip to content

Commit

Permalink
Add more complex integer case expression test
Browse files Browse the repository at this point in the history
Ref. #907
  • Loading branch information
senier committed Jul 12, 2022
1 parent a4fc8ca commit 31e06b1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/unit/expression_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@

EXPR = Equal(Variable("UNDEFINED_1"), Variable("UNDEFINED_2"))
TINY_INT = RangeInteger("P::Tiny", Number(1), Number(3), Number(8), location=Location((1, 2)))
INT = RangeInteger("P::Int", Number(1), Number(100), Number(8), location=Location((3, 2)))


def assert_type(expr: Expr, type_: rty.Type) -> None:
Expand Down Expand Up @@ -2597,6 +2598,17 @@ def test_case_invalid() -> None:
'^<stdin>:2:2: model: error: case expression does not cover full range of "P::Tiny"\n'
"<stdin>:1:2: model: info: missing range 2 .. 3$",
)
assert_type_error(
CaseExpr(
Variable("C", type_=INT.type_),
[([Number(1), Number(2)], TRUE), ([Number(51)], FALSE), ([Number(53)], TRUE)],
location=Location((5, 2)),
),
'^<stdin>:5:2: model: error: case expression does not cover full range of "P::Int"\n'
"<stdin>:3:2: model: info: missing range 3 .. 50\n"
"<stdin>:3:2: model: info: missing value 52\n"
"<stdin>:3:2: model: info: missing range 54 .. 100$",
)
assert_type_error(
CaseExpr(
Variable("C", type_=TINY_INT.type_),
Expand Down

0 comments on commit 31e06b1

Please sign in to comment.