Skip to content

Commit 82e0eb6

Browse files
authored
[mypyc] Add back test for next with list iterator (#19419)
Adding back a test for `next` with a list iterator as argument. Previously this test only checked if compilation succeeded so I have removed it in #19416, now it calls the test function and checks the result.
1 parent 77ce646 commit 82e0eb6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

mypyc/test-data/run-lists.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,17 @@ def test_from_gen() -> None:
486486
f = list("str:" + x for x in source_str)
487487
assert f == ["str:a", "str:b", "str:c", "str:d"]
488488

489+
[case testNext]
490+
from typing import List
491+
492+
def get_next(x: List[int]) -> int:
493+
return next((i for i in x), -1)
494+
495+
def test_next() -> None:
496+
assert get_next([]) == -1
497+
assert get_next([1]) == 1
498+
assert get_next([3,2,1]) == 3
499+
489500
[case testListGetItemWithBorrow]
490501
from typing import List
491502

0 commit comments

Comments
 (0)