summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorCharles Brunet <charles.brunet@optelgroup.com>2024-08-06 10:15:33 -0400
committerDylan Baker <dylan@pnwbakers.com>2024-08-20 09:38:27 -0700
commitd9ba42217f49c4bd4caeac9050cc475e3453f75e (patch)
tree3c3bbc263fa8cde298236bfb7c9e58aeb4d4d490 /unittests
parent18f4a058bf7e4b7eb32553b10fe3a37e1c22aa15 (diff)
downloadmeson-d9ba42217f49c4bd4caeac9050cc475e3453f75e.tar.gz
format: fix indentation of comments
Fixes #13508 - Fix indentation of comments in arrays - Fix indentation of comments in dicts - Fix indentation of comments in if clauses - Fix indentation of comments in foreach clauses
Diffstat (limited to 'unittests')
-rw-r--r--unittests/platformagnostictests.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/unittests/platformagnostictests.py b/unittests/platformagnostictests.py
index c8f594d46..7d6ffa0f9 100644
--- a/unittests/platformagnostictests.py
+++ b/unittests/platformagnostictests.py
@@ -342,6 +342,21 @@ class PlatformAgnosticTests(BasePlatformTests):
for code in ('', '\n'):
formatted = formatter.format(code, Path())
self.assertEqual('\n', formatted)
+
+ def test_format_indent_comment_in_brackets(self) -> None:
+ """Ensure comments in arrays and dicts are correctly indented"""
+ formatter = Formatter(None, use_editor_config=False, fetch_subdirs=False)
+ code = 'a = [\n # comment\n]\n'
+ formatted = formatter.format(code, Path())
+ self.assertEqual(code, formatted)
+
+ code = 'a = [\n # comment\n 1,\n]\n'
+ formatted = formatter.format(code, Path())
+ self.assertEqual(code, formatted)
+
+ code = 'a = {\n # comment\n}\n'
+ formatted = formatter.format(code, Path())
+ self.assertEqual(code, formatted)
def test_error_configuring_subdir(self):
testdir = os.path.join(self.common_test_dir, '152 index customtarget')