mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-08 05:35:22 +00:00
Add test
This commit is contained in:
parent
25cc1da319
commit
41a0ef8740
2 changed files with 92 additions and 0 deletions
|
@ -853,4 +853,24 @@ def args_to_tuple(*args: *Ts) -> Tuple[*Ts]: ...
|
|||
.unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "all-nodes-with-ranges"))]
|
||||
fn decorator_ranges() {
|
||||
let parse_ast = parse_program(
|
||||
r#"
|
||||
@my_decorator
|
||||
def test():
|
||||
pass
|
||||
|
||||
@class_decorator
|
||||
class Abcd:
|
||||
pass
|
||||
"#
|
||||
.trim(),
|
||||
"<test>",
|
||||
)
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
}
|
||||
|
|
72
parser/src/snapshots/rustpython_parser__parser__tests__decorator_ranges.snap
generated
Normal file
72
parser/src/snapshots/rustpython_parser__parser__tests__decorator_ranges.snap
generated
Normal file
|
@ -0,0 +1,72 @@
|
|||
---
|
||||
source: parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
range: 0..34,
|
||||
name: Identifier(
|
||||
"test",
|
||||
),
|
||||
args: Arguments {
|
||||
range: (),
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: None,
|
||||
kwonlyargs: [],
|
||||
kw_defaults: [],
|
||||
kwarg: None,
|
||||
defaults: [],
|
||||
},
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 30..34,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 1..13,
|
||||
id: Identifier(
|
||||
"my_decorator",
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
returns: None,
|
||||
type_comment: None,
|
||||
},
|
||||
),
|
||||
ClassDef(
|
||||
StmtClassDef {
|
||||
range: 40..77,
|
||||
name: Identifier(
|
||||
"Abcd",
|
||||
),
|
||||
bases: [],
|
||||
keywords: [],
|
||||
body: [
|
||||
Pass(
|
||||
StmtPass {
|
||||
range: 73..77,
|
||||
},
|
||||
),
|
||||
],
|
||||
decorator_list: [
|
||||
Name(
|
||||
ExprName {
|
||||
range: 41..56,
|
||||
id: Identifier(
|
||||
"class_decorator",
|
||||
),
|
||||
ctx: Load,
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue