mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-13 08:05:17 +00:00
add tests
This commit is contained in:
parent
1f7a9e5cdc
commit
8e0bef913c
3 changed files with 126 additions and 0 deletions
|
@ -218,4 +218,18 @@ class Foo(A, B):
|
||||||
let parse_ast = parse_expression(&source, "<test>").unwrap();
|
let parse_ast = parse_expression(&source, "<test>").unwrap();
|
||||||
insta::assert_debug_snapshot!(parse_ast);
|
insta::assert_debug_snapshot!(parse_ast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_boolop_or() {
|
||||||
|
let source = String::from("x or y");
|
||||||
|
let parse_ast = parse_expression(&source, "<test>").unwrap();
|
||||||
|
insta::assert_debug_snapshot!(parse_ast);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_boolop_and() {
|
||||||
|
let source = String::from("x and y");
|
||||||
|
let parse_ast = parse_expression(&source, "<test>").unwrap();
|
||||||
|
insta::assert_debug_snapshot!(parse_ast);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
---
|
||||||
|
source: compiler/parser/src/parser.rs
|
||||||
|
expression: parse_ast
|
||||||
|
---
|
||||||
|
Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 7,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: BoolOp {
|
||||||
|
op: And,
|
||||||
|
values: [
|
||||||
|
Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 1,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Name {
|
||||||
|
id: "x",
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 6,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 7,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Name {
|
||||||
|
id: "y",
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
---
|
||||||
|
source: compiler/parser/src/parser.rs
|
||||||
|
expression: parse_ast
|
||||||
|
---
|
||||||
|
Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 6,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: BoolOp {
|
||||||
|
op: Or,
|
||||||
|
values: [
|
||||||
|
Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 1,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Name {
|
||||||
|
id: "x",
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 5,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 6,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Name {
|
||||||
|
id: "y",
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue