]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

torture test (#2815)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Sat, 29 Jan 2022 00:48:38 +0000 (16:48 -0800)
committerGitHub <noreply@github.com>
Sat, 29 Jan 2022 00:48:38 +0000 (16:48 -0800)
Fixes #2651. Fixes #2754. Fixes #2518. Fixes #2321.

This adds a test that lists a number of cases of unstable formatting
that we have seen in the issue tracker. Checking it in will ensure
that we don't regress on these cases.

tests/data/torture.py [new file with mode: 0644]
tests/test_format.py

diff --git a/tests/data/torture.py b/tests/data/torture.py
new file mode 100644 (file)
index 0000000..79a44c2
--- /dev/null
@@ -0,0 +1,81 @@
+importA;() << 0 ** 101234234242352525425252352352525234890264906820496920680926538059059209922523523525 #
+
+assert sort_by_dependency(
+    {
+        "1": {"2", "3"}, "2": {"2a", "2b"}, "3": {"3a", "3b"},
+        "2a": set(), "2b": set(), "3a": set(), "3b": set()
+    }
+) == ["2a", "2b", "2", "3a", "3b", "3", "1"]
+
+importA
+0;0^0#
+
+class A:
+    def foo(self):
+        for _ in range(10):
+            aaaaaaaaaaaaaaaaaaa = bbbbbbbbbbbbbbb.cccccccccc(  # pylint: disable=no-member
+                xxxxxxxxxxxx
+            )
+
+def test(self, othr):
+    return (1 == 2 and
+            (name, description, self.default, self.selected, self.auto_generated, self.parameters, self.meta_data, self.schedule) ==
+            (name, description, othr.default, othr.selected, othr.auto_generated, othr.parameters, othr.meta_data, othr.schedule))
+
+# output
+
+importA
+(
+    ()
+    << 0
+    ** 101234234242352525425252352352525234890264906820496920680926538059059209922523523525
+)  #
+
+assert (
+    sort_by_dependency(
+        {
+            "1": {"2", "3"},
+            "2": {"2a", "2b"},
+            "3": {"3a", "3b"},
+            "2a": set(),
+            "2b": set(),
+            "3a": set(),
+            "3b": set(),
+        }
+    )
+    == ["2a", "2b", "2", "3a", "3b", "3", "1"]
+)
+
+importA
+0
+0 ^ 0  #
+
+
+class A:
+    def foo(self):
+        for _ in range(10):
+            aaaaaaaaaaaaaaaaaaa = bbbbbbbbbbbbbbb.cccccccccc(
+                xxxxxxxxxxxx
+            )  # pylint: disable=no-member
+
+
+def test(self, othr):
+    return 1 == 2 and (
+        name,
+        description,
+        self.default,
+        self.selected,
+        self.auto_generated,
+        self.parameters,
+        self.meta_data,
+        self.schedule,
+    ) == (
+        name,
+        description,
+        othr.default,
+        othr.selected,
+        othr.auto_generated,
+        othr.parameters,
+        othr.meta_data,
+        othr.schedule,
+    )
index aef22545f5b4bd128469ed4ddbb51d47832036c3..04676c1c2c52a578a94a20845e1089149a4857ca 100644 (file)
@@ -53,6 +53,7 @@ SIMPLE_CASES: List[str] = [
     "remove_parens",
     "slices",
     "string_prefixes",
+    "torture",
     "trailing_comma_optional_parens1",
     "trailing_comma_optional_parens2",
     "trailing_comma_optional_parens3",