Skip to content

Commit

Permalink
Isolate non-breaking whitespace indentation test case (#11721)
Browse files Browse the repository at this point in the history
As discussed in Discord, this moves the test case for non-breaking
whitespace into its own method.
  • Loading branch information
dhruvmanila authored Jun 3, 2024
1 parent 8db147c commit 2b28889
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions crates/ruff_python_codegen/src/stylist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,20 @@ x = (
let stylist = Stylist::from_tokens(parsed.tokens(), &locator);
assert_eq!(stylist.indentation(), &Indentation(" ".to_string()));

// formfeed indent, see `detect_indention` comment.
let contents = r"
class FormFeedIndent:
def __init__(self, a=[]):
print(a)
";
let locator = Locator::new(contents);
let parsed = parse_module(contents).unwrap();
let stylist = Stylist::from_tokens(parsed.tokens(), &locator);
assert_eq!(stylist.indentation(), &Indentation(" ".to_string()));
}

#[test]
fn indent_non_breaking_whitespace() {
let contents = r"
x = (
 1,
Expand All @@ -227,17 +241,6 @@ x = (
Stylist::from_tokens(parsed.tokens(), &locator).indentation(),
&Indentation(" ".to_string())
);

// formfeed indent, see `detect_indention` comment.
let contents = r"
class FormFeedIndent:
def __init__(self, a=[]):
print(a)
";
let locator = Locator::new(contents);
let parsed = parse_module(contents).unwrap();
let stylist = Stylist::from_tokens(parsed.tokens(), &locator);
assert_eq!(stylist.indentation(), &Indentation(" ".to_string()));
}

#[test]
Expand Down

0 comments on commit 2b28889

Please sign in to comment.