Skip to content

Commit 28f9f65

Browse files
authored
Merge pull request RustPython#4306 from harupy/fix-boolop-location
Fix `ExprKind::BoolOp` location
2 parents 39bed0d + 18293dc commit 28f9f65

File tree

5 files changed

+128
-4
lines changed

5 files changed

+128
-4
lines changed

Lib/test/test_ast.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,8 +2100,6 @@ def test_binop(self):
21002100
self._check_content(s, binop.left, '1 * 2 + (3 )')
21012101
self._check_content(s, binop.left.right, '3')
21022102

2103-
# TODO: RUSTPYTHON
2104-
@unittest.expectedFailure
21052103
def test_boolop(self):
21062104
s = dedent('''
21072105
if (one_condition and

compiler/parser/python.lalrpop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ LambdaDef: ast::Expr = {
756756
}
757757

758758
OrTest: ast::Expr = {
759-
<e1:AndTest> <location:@L> <e2:("or" AndTest)*> <end_location:@R> => {
759+
<location:@L> <e1:AndTest> <e2:("or" AndTest)*> <end_location:@R> => {
760760
if e2.is_empty() {
761761
e1
762762
} else {
@@ -773,7 +773,7 @@ OrTest: ast::Expr = {
773773
};
774774

775775
AndTest: ast::Expr = {
776-
<e1:NotTest> <location:@L> <e2:("and" NotTest)*> <end_location:@R> => {
776+
<location:@L> <e1:NotTest> <e2:("and" NotTest)*> <end_location:@R> => {
777777
if e2.is_empty() {
778778
e1
779779
} else {

compiler/parser/src/parser.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,18 @@ class Foo(A, B):
218218
let parse_ast = parse_expression(&source, "<test>").unwrap();
219219
insta::assert_debug_snapshot!(parse_ast);
220220
}
221+
222+
#[test]
223+
fn test_parse_boolop_or() {
224+
let source = String::from("x or y");
225+
let parse_ast = parse_expression(&source, "<test>").unwrap();
226+
insta::assert_debug_snapshot!(parse_ast);
227+
}
228+
229+
#[test]
230+
fn test_parse_boolop_and() {
231+
let source = String::from("x and y");
232+
let parse_ast = parse_expression(&source, "<test>").unwrap();
233+
insta::assert_debug_snapshot!(parse_ast);
234+
}
221235
}

compiler/parser/src/snapshots/rustpython_parser__parser__tests__parse_boolop_and.snap

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/parser/src/snapshots/rustpython_parser__parser__tests__parse_boolop_or.snap

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)