Skip to content
This repository was archived by the owner on Jul 27, 2023. It is now read-only.

Commit 1d4b7a3

Browse files
committed
Consolidate tests and add coverage for trailing comma
1 parent ce3ce07 commit 1d4b7a3

9 files changed

+392
-513
lines changed

parser/src/parser.rs

Lines changed: 17 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -634,70 +634,31 @@ class Foo(A, B):
634634

635635
#[test]
636636
#[cfg(feature = "all-nodes-with-ranges")]
637-
fn test_parse_class_with_generic_type() {
637+
fn test_parse_class_generic_types() {
638638
let source = "\
639-
class Foo[T](A, B):
640-
pass
641-
";
642-
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());
643-
}
639+
# TypeVar
640+
class Foo[T](): ...
644641
645-
#[test]
646-
#[cfg(feature = "all-nodes-with-ranges")]
647-
fn test_parse_class_with_generic_type_with_bound() {
648-
let source = "\
649-
class Foo[T: str](A, B):
650-
pass
651-
";
652-
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());
653-
}
642+
# TypeVar with bound
643+
class Foo[T: str](): ...
654644
655-
#[test]
656-
#[cfg(feature = "all-nodes-with-ranges")]
657-
fn test_parse_class_with_generic_type_with_tuple_bound() {
658-
let source = "\
659-
class Foo[T: (str, bytes)](A, B):
660-
pass
661-
";
662-
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());
663-
}
645+
# TypeVar with tuple bound
646+
class Foo[T: (str, bytes)](): ...
664647
665-
#[test]
666-
#[cfg(feature = "all-nodes-with-ranges")]
667-
fn test_parse_class_with_multiple_generic_types() {
668-
let source = "\
669-
class Foo[T, U](A, B):
670-
pass
671-
";
672-
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());
673-
}
648+
# Multiple TypeVar
649+
class Foo[T, U](): ...
674650
675-
#[test]
676-
#[cfg(feature = "all-nodes-with-ranges")]
677-
fn test_parse_class_with_generic_type_var_tuple() {
678-
let source = "\
679-
class Foo[*U](A, B):
680-
pass
681-
";
682-
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());
683-
}
651+
# Trailing comma
652+
class Foo[T, U,](): ...
684653
654+
# TypeVarTuple
655+
class Foo[*Ts](): ...
685656
686-
#[test]
687-
#[cfg(feature = "all-nodes-with-ranges")]
688-
fn test_parse_class_with_generic_param_spec() {
689-
let source = "\
690-
class Foo[**P](A, B):
691-
pass
692-
";
693-
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());
694-
}
657+
# ParamSpec
658+
class Foo[**P](): ...
695659
696-
#[test]
697-
#[cfg(feature = "all-nodes-with-ranges")]
698-
fn test_parse_class_with_all_possible_generic_types() {
699-
let source = "\
700-
class Foo[X, Y: str, *U, **P](A, B):
660+
# Mixed types
661+
class Foo[X, Y: str, *U, **P]():
701662
pass
702663
";
703664
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());

0 commit comments

Comments
 (0)