From 2b28889ca9d7935488875b5c944a159a2db20a23 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Mon, 3 Jun 2024 18:50:55 +0530 Subject: [PATCH] Isolate non-breaking whitespace indentation test case (#11721) As discussed in Discord, this moves the test case for non-breaking whitespace into its own method. --- crates/ruff_python_codegen/src/stylist.rs | 25 +++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/crates/ruff_python_codegen/src/stylist.rs b/crates/ruff_python_codegen/src/stylist.rs index 375f0c8e16..d5a1ea53cd 100644 --- a/crates/ruff_python_codegen/src/stylist.rs +++ b/crates/ruff_python_codegen/src/stylist.rs @@ -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, @@ -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]