Skip to content

Commit ff51655

Browse files
committed
Add tests from the CPython corpus
1 parent 1b702aa commit ff51655

File tree

2 files changed

+428
-107
lines changed

2 files changed

+428
-107
lines changed

parser/src/parser.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -870,19 +870,17 @@ except* OSError as e:
870870
#[test]
871871
#[cfg(feature = "all-nodes-with-ranges")]
872872
fn test_parse_type_declaration() {
873-
let source = "\
874-
# A non-generic type alias
875-
type IntOrStr = int | str
876-
877-
# A generic type alias
878-
type ListOrSet[T] = list[T] | set[T]
879-
880-
# A type alias that includes a forward reference
881-
type AnimalOrVegetable = Animal | \"Vegetable\"
882-
883-
# A generic self-referential type alias
884-
type RecursiveList[T] = T | list[RecursiveList[T]]
885-
";
873+
let source = r#"
874+
type X = int
875+
type X = int | str
876+
type X = int | "ForwardRefY"
877+
type X[T] = T | list[X[T]] # recursive
878+
type X[T] = int
879+
type X[T] = list[T] | set[T]
880+
type X[T, *Ts, **P] = (T, Ts, P)
881+
type X[T: int, *Ts, **P] = (T, Ts, P)
882+
type X[T: (int, str), *Ts, **P] = (T, Ts, P)
883+
"#;
886884
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());
887885
}
888886

0 commit comments

Comments
 (0)