From 8e0bef913c29b14915d426fe18796b51e8441dc6 Mon Sep 17 00:00:00 2001 From: harupy Date: Sun, 4 Dec 2022 05:59:51 +0900 Subject: [PATCH] add tests --- parser/src/parser.rs | 14 +++++ ...rser__parser__tests__parse_boolop_and.snap | 56 +++++++++++++++++++ ...arser__parser__tests__parse_boolop_or.snap | 56 +++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 parser/src/snapshots/rustpython_parser__parser__tests__parse_boolop_and.snap create mode 100644 parser/src/snapshots/rustpython_parser__parser__tests__parse_boolop_or.snap diff --git a/parser/src/parser.rs b/parser/src/parser.rs index d0f71fc..f120dae 100644 --- a/parser/src/parser.rs +++ b/parser/src/parser.rs @@ -218,4 +218,18 @@ class Foo(A, B): let parse_ast = parse_expression(&source, "").unwrap(); 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, "").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, "").unwrap(); + insta::assert_debug_snapshot!(parse_ast); + } } diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_boolop_and.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_boolop_and.snap new file mode 100644 index 0000000..f0e8562 --- /dev/null +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_boolop_and.snap @@ -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, + }, + }, + ], + }, +} diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_boolop_or.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_boolop_or.snap new file mode 100644 index 0000000..5d5abad --- /dev/null +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_boolop_or.snap @@ -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, + }, + }, + ], + }, +}