mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-25 14:04:28 +00:00
Allow trailing commas in MappingPattern
This commit is contained in:
parent
2a8aa6f308
commit
b61f4d7b69
4 changed files with 983 additions and 4 deletions
|
@ -497,7 +497,7 @@ match match:
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_match_complex() {
|
||||
fn test_patma() {
|
||||
let source = r#"# Cases sampled from Lib/test/test_patma.py
|
||||
|
||||
# case test_patma_098
|
||||
|
@ -666,4 +666,34 @@ match w := x,:
|
|||
let parse_ast = parse_program(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_match() {
|
||||
let parse_ast = parse_program(
|
||||
r#"
|
||||
match {"test": 1}:
|
||||
case {
|
||||
**rest,
|
||||
}:
|
||||
print(rest)
|
||||
match {"label": "test"}:
|
||||
case {
|
||||
"label": str() | None as label,
|
||||
}:
|
||||
print(label)
|
||||
match x:
|
||||
case [0, 1,]:
|
||||
y = 0
|
||||
match x:
|
||||
case (0, 1,):
|
||||
y = 0
|
||||
match x:
|
||||
case (0,):
|
||||
y = 0
|
||||
"#,
|
||||
"<test>",
|
||||
)
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue