-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[red-knot] Added collections infer tests
- Loading branch information
Showing
6 changed files
with
65 additions
and
131 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
crates/red_knot_python_semantic/resources/mdtest/literal/collections/dictionary.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Dictionaries | ||
|
||
## Empty dictionary | ||
|
||
```py | ||
x = {} | ||
reveal_type(x) # revealed: dict | ||
``` |
8 changes: 8 additions & 0 deletions
8
crates/red_knot_python_semantic/resources/mdtest/literal/collections/list.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Lists | ||
|
||
## Empty list | ||
|
||
```py | ||
x = [] | ||
reveal_type(x) # revealed: list | ||
``` |
8 changes: 8 additions & 0 deletions
8
crates/red_knot_python_semantic/resources/mdtest/literal/collections/set.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Sets | ||
|
||
## Basic set | ||
|
||
```py | ||
x = {1, 2} | ||
reveal_type(x) # revealed: set | ||
``` |
20 changes: 20 additions & 0 deletions
20
crates/red_knot_python_semantic/resources/mdtest/literal/collections/tuple.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Tuples | ||
|
||
## Empty tuple | ||
|
||
```py | ||
x = () | ||
reveal_type(x) # revealed: tuple[()] | ||
``` | ||
|
||
## Heterogeneous tuple | ||
|
||
```py | ||
x = (1, 'a') | ||
y = (1, (2, 3)) | ||
z = (x, 2) | ||
|
||
reveal_type(x) # revealed: tuple[Literal[1], Literal["a"]] | ||
reveal_type(y) # revealed: tuple[Literal[1], tuple[Literal[2], Literal[3]]] | ||
reveal_type(z) # revealed: tuple[tuple[Literal[1], Literal["a"]], Literal[2]] | ||
``` |
21 changes: 21 additions & 0 deletions
21
crates/red_knot_python_semantic/resources/mdtest/subscript/tuple.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Tuple subscripts | ||
|
||
## Basic | ||
|
||
```py | ||
t = (1, 'a', 'b') | ||
|
||
a = t[0] | ||
b = t[1] | ||
c = t[-1] | ||
d = t[-2] | ||
e = t[4] # error: [index-out-of-bounds] | ||
f = t[-4] # error: [index-out-of-bounds] | ||
|
||
reveal_type(a) # revealed: Literal[1] | ||
reveal_type(b) # revealed: Literal["a"] | ||
reveal_type(c) # revealed: Literal["b"] | ||
reveal_type(d) # revealed: Literal["a"] | ||
reveal_type(e) # revealed: Unknown | ||
reveal_type(f) # revealed: Unknown | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters