Skip to content

Commit

Permalink
Include i16 in run-tuples test
Browse files Browse the repository at this point in the history
  • Loading branch information
ichard26 committed Jun 24, 2023
1 parent 68811e2 commit 757aaa5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions mypyc/test-data/run-tuples.test
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def test_final_boxed_tuple() -> None:
# tuple->tuple coerces are optimized away with each tuple item being
# coerced individually instead. No need to test that here.
from typing import Any, Tuple, cast
from mypy_extensions import i64, i32
from mypy_extensions import i64, i32, i16
from testutil import assertRaises

class A: pass
Expand All @@ -266,8 +266,8 @@ def test_generic() -> None:
assert t1 == src
t2: Tuple[int, float, str, bytes, bool, A] = cast(Tuple[Any, Any, Any, Any, Any, Any], src)
assert t2 == src
src = (2, 4)
t3: Tuple[i64, i32] = src
src = (2, 4, 8)
t3: Tuple[i64, i32, i16] = src
assert t3 == src

def test_errors_generic() -> None:
Expand All @@ -279,13 +279,15 @@ def test_errors_generic() -> None:
with assertRaises(TypeError, "must be real number, not str"):
t3: Tuple[float, float] = cast(Any, (1.0, "2.5"))
with assertRaises(TypeError, "str"): # Error changes on Python 3.10
t4: Tuple[i64, i32] = cast(Any, (1, "2"))
t4: Tuple[i64, i32, i16] = cast(Any, (1, "2", 3))
with assertRaises(OverflowError, "int too large to convert to i16"):
t5: Tuple[i64, i32, i16] = cast(Any, (1, 2, 2**16))
with assertRaises(OverflowError, "int too large to convert to i32"):
t5: Tuple[i64, i32] = cast(Any, (1, 2**32))
t6: Tuple[i64, i32, i16] = cast(Any, (1, 2**32, 3))
with assertRaises(OverflowError, "int too large to convert to i64"):
t6: Tuple[i64, i32] = cast(Any, (2**64, 2))
t7: Tuple[i64, i32, i16] = cast(Any, (2**64, 2, 3))

with assertRaises(TypeError, "tuple[int] object expected; got int"):
t7: Tuple[int] = cast(Any, 1)
t8: Tuple[int] = cast(Any, 1)
with assertRaises(TypeError, "tuple[int] object expected; got tuple[int, int]"):
t8: Tuple[int] = cast(Any, (1, 2))
t9: Tuple[int] = cast(Any, (1, 2))

0 comments on commit 757aaa5

Please sign in to comment.