Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zenlyj committed Nov 24, 2024
1 parent 8906179 commit a67f2d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/functional/p/potential_index_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,22 @@ def my_func():
# Test that we don't crash on more complicated indices/slices
# We do not raise here (currently)
print([1, 2, 3][2:3])


# Test for cases with unpacking operation
my_list = ["foo", "bar"]
my_set = {"foo", "bar"}
my_tuple = ("foo", "bar")
my_iterable = (*my_list, *my_set, *my_tuple, *("foo", "bar"))

print([*my_list][1])
print([*my_list][2]) # [potential-index-error]

print([*my_set][1])
print([*my_set][2]) # [potential-index-error]

print((*my_tuple,)[1])
print((*my_tuple,)[2]) # [potential-index-error]

print((*my_iterable,)[7])
print((*my_iterable,)[8]) # [potential-index-error]
4 changes: 4 additions & 0 deletions tests/functional/p/potential_index_error.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
potential-index-error:6:6:6:18::Invalid index for iterable length:INFERENCE
potential-index-error:7:6:7:18::Invalid index for iterable length:INFERENCE
potential-index-error:8:6:8:22::Invalid index for iterable length:INFERENCE
potential-index-error:35:6:35:19::Invalid index for iterable length:INFERENCE
potential-index-error:38:6:38:18::Invalid index for iterable length:INFERENCE
potential-index-error:41:6:41:21::Invalid index for iterable length:INFERENCE
potential-index-error:44:6:44:24::Invalid index for iterable length:INFERENCE

0 comments on commit a67f2d8

Please sign in to comment.