mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-09 22:25:23 +00:00
Use insta to verify values.
This commit is contained in:
parent
d7e2e7361e
commit
8f425e9ce2
9 changed files with 344 additions and 0 deletions
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
source: compiler/parser/src/string.rs
|
||||||
|
expression: parse_ast
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 15,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Expr {
|
||||||
|
value: Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 15,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Constant {
|
||||||
|
value: Str(
|
||||||
|
"\u{8}",
|
||||||
|
),
|
||||||
|
kind: None,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
source: compiler/parser/src/string.rs
|
||||||
|
expression: parse_ast
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 9,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Expr {
|
||||||
|
value: Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 9,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Constant {
|
||||||
|
value: Str(
|
||||||
|
"\u{7}",
|
||||||
|
),
|
||||||
|
kind: None,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
source: compiler/parser/src/string.rs
|
||||||
|
expression: parse_ast
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 21,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Expr {
|
||||||
|
value: Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 21,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Constant {
|
||||||
|
value: Str(
|
||||||
|
"\r",
|
||||||
|
),
|
||||||
|
kind: None,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
source: compiler/parser/src/string.rs
|
||||||
|
expression: parse_ast
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 45,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Expr {
|
||||||
|
value: Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 45,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Constant {
|
||||||
|
value: Str(
|
||||||
|
"\u{89}",
|
||||||
|
),
|
||||||
|
kind: None,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
source: compiler/parser/src/string.rs
|
||||||
|
expression: parse_ast
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 12,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Expr {
|
||||||
|
value: Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 12,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Constant {
|
||||||
|
value: Str(
|
||||||
|
"\u{7f}",
|
||||||
|
),
|
||||||
|
kind: None,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
source: compiler/parser/src/string.rs
|
||||||
|
expression: parse_ast
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 12,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Expr {
|
||||||
|
value: Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 12,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Constant {
|
||||||
|
value: Str(
|
||||||
|
"\u{1b}",
|
||||||
|
),
|
||||||
|
kind: None,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
source: compiler/parser/src/string.rs
|
||||||
|
expression: parse_ast
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 15,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Expr {
|
||||||
|
value: Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 15,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Constant {
|
||||||
|
value: Str(
|
||||||
|
"\u{c}",
|
||||||
|
),
|
||||||
|
kind: None,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
source: compiler/parser/src/string.rs
|
||||||
|
expression: parse_ast
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 9,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Expr {
|
||||||
|
value: Located {
|
||||||
|
location: Location {
|
||||||
|
row: 1,
|
||||||
|
column: 0,
|
||||||
|
},
|
||||||
|
end_location: Some(
|
||||||
|
Location {
|
||||||
|
row: 1,
|
||||||
|
column: 9,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
custom: (),
|
||||||
|
node: Constant {
|
||||||
|
value: Str(
|
||||||
|
"\u{88}",
|
||||||
|
),
|
||||||
|
kind: None,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
|
@ -1048,4 +1048,28 @@ mod tests {
|
||||||
let parse_ast = parse_program(source, "<test>").unwrap();
|
let parse_ast = parse_program(source, "<test>").unwrap();
|
||||||
insta::assert_debug_snapshot!(parse_ast);
|
insta::assert_debug_snapshot!(parse_ast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! test_aliases_parse {
|
||||||
|
($($name:ident: $alias:expr,)*) => {
|
||||||
|
$(
|
||||||
|
#[test]
|
||||||
|
fn $name() {
|
||||||
|
let source = format!(r#""\N{{{0}}}""#, $alias);
|
||||||
|
let parse_ast = parse_program(&source, "<test>").unwrap();
|
||||||
|
insta::assert_debug_snapshot!(parse_ast);
|
||||||
|
}
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test_aliases_parse! {
|
||||||
|
test_backspace_alias: "BACKSPACE",
|
||||||
|
test_bell_alias: "BEL",
|
||||||
|
test_carriage_return_alias: "CARRIAGE RETURN",
|
||||||
|
test_delete_alias: "DELETE",
|
||||||
|
test_escape_alias: "ESCAPE",
|
||||||
|
test_form_feed_alias: "FORM FEED",
|
||||||
|
test_hts_alias: "HTS",
|
||||||
|
test_character_tabulation_with_justification_alias: "CHARACTER TABULATION WITH JUSTIFICATION",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue