mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-07 21:25:31 +00:00
Add test for tuple bounds
This commit is contained in:
parent
76a3245479
commit
b06b2662c9
2 changed files with 91 additions and 0 deletions
|
@ -656,6 +656,16 @@ class Foo[T: str](A, B):
|
||||||
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());
|
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "all-nodes-with-ranges")]
|
||||||
|
fn test_parse_class_with_generic_type_with_tuple_bound() {
|
||||||
|
let source = "\
|
||||||
|
class Foo[T: (str, bytes)](A, B):
|
||||||
|
pass
|
||||||
|
";
|
||||||
|
insta::assert_debug_snapshot!(ast::Suite::parse(source, "<test>").unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "all-nodes-with-ranges")]
|
#[cfg(feature = "all-nodes-with-ranges")]
|
||||||
fn test_parse_class_with_multiple_generic_types() {
|
fn test_parse_class_with_multiple_generic_types() {
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
---
|
||||||
|
source: parser/src/parser.rs
|
||||||
|
expression: "ast::Suite::parse(source, \"<test>\").unwrap()"
|
||||||
|
---
|
||||||
|
[
|
||||||
|
ClassDef(
|
||||||
|
StmtClassDef {
|
||||||
|
range: 0..40,
|
||||||
|
name: Identifier(
|
||||||
|
"Foo",
|
||||||
|
),
|
||||||
|
bases: [
|
||||||
|
Name(
|
||||||
|
ExprName {
|
||||||
|
range: 27..28,
|
||||||
|
id: Identifier(
|
||||||
|
"A",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Name(
|
||||||
|
ExprName {
|
||||||
|
range: 30..31,
|
||||||
|
id: Identifier(
|
||||||
|
"B",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
keywords: [],
|
||||||
|
body: [
|
||||||
|
Pass(
|
||||||
|
StmtPass {
|
||||||
|
range: 36..40,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
decorator_list: [],
|
||||||
|
type_params: [
|
||||||
|
TypeVar(
|
||||||
|
TypeParamTypeVar {
|
||||||
|
range: 10..25,
|
||||||
|
name: Identifier(
|
||||||
|
"T",
|
||||||
|
),
|
||||||
|
bound: Some(
|
||||||
|
Tuple(
|
||||||
|
ExprTuple {
|
||||||
|
range: 13..25,
|
||||||
|
elts: [
|
||||||
|
Name(
|
||||||
|
ExprName {
|
||||||
|
range: 14..17,
|
||||||
|
id: Identifier(
|
||||||
|
"str",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Name(
|
||||||
|
ExprName {
|
||||||
|
range: 19..24,
|
||||||
|
id: Identifier(
|
||||||
|
"bytes",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
Loading…
Add table
Add a link
Reference in a new issue