Skip to content

Commit 625929f

Browse files
committed
add run tests
1 parent 29c62b3 commit 625929f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

mypyc/test-data/run-lists.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,8 @@ def test_in_operator_various_cases() -> None:
479479
assert list_in_mixed(type)
480480

481481
[case testListBuiltFromGenerator]
482+
from typing import Final
483+
abc: Final = "abc"
482484
def test_from_gen() -> None:
483485
source_a = ["a", "b", "c"]
484486
a = list(x + "f2" for x in source_a)
@@ -498,6 +500,10 @@ def test_from_gen() -> None:
498500
source_str = "abcd"
499501
f = list("str:" + x for x in source_str)
500502
assert f == ["str:a", "str:b", "str:c", "str:d"]
503+
def test_known_length() -> None:
504+
# not built from generator but doesnt need its own test either
505+
built = [str(x) for x in [*abc, *"def", *b"ghi", ("j", "k"), *("l", "m", "n")]]
506+
assert built == ['a', 'b', 'c', 'd', 'e', 'f', '103', '104', '105', "('j', 'k')", 'l', 'm', 'n']
501507

502508
[case testNext]
503509
from typing import List

mypyc/test-data/run-tuples.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,11 @@ def test_slicing() -> None:
270270
def f8(val: int) -> bool:
271271
return val % 2 == 0
272272

273+
abc: Final = "abc"
274+
275+
def known_length() -> tuple[str, ...]:
276+
return tuple(str(x) for x in [*abc, *"def", *b"ghi", ("j", "k"), *("l", "m", "n")])
277+
273278
def test_sequence_generator() -> None:
274279
source_list = [1, 2, 3]
275280
a = tuple(f8(x) for x in source_list)
@@ -287,6 +292,8 @@ def test_sequence_generator() -> None:
287292
b = tuple('s:' + x for x in source_str)
288293
assert b == ('s:a', 's:b', 's:b', 's:c')
289294

295+
assert known_length() == ['a', 'b', 'c', 'd', 'e', 'f', '103', '104', '105', "('j', 'k')", 'l', 'm', 'n']
296+
290297
TUPLE: Final[Tuple[str, ...]] = ('x', 'y')
291298

292299
def test_final_boxed_tuple() -> None:

0 commit comments

Comments
 (0)