aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_corner.py
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-14 20:55:02 +0200
committeruser <user@clank>2026-08-14 20:55:02 +0200
commit5a15f9519554e8e736955a1900f7bdffc79603a0 (patch)
tree0921187e8017ef5ba8a43ae72c787dd0bcc617f2 /tests/test_corner.py
parentsl0ppty: every place the boundaries meet is a crossing (diff)
downloadslosh-5a15f9519554e8e736955a1900f7bdffc79603a0.tar.gz
slosh-5a15f9519554e8e736955a1900f7bdffc79603a0.tar.xz
slosh-5a15f9519554e8e736955a1900f7bdffc79603a0.zip
sl0ppty: find the crossing whichever way the tree is nested
Half the crossings were invisible, and it was the half that depends on how you built the layout rather than on how it looks. Rows of columns gives a full-width row boundary with column boundaries running into it from above and below. Columns of rows gives a full-height column boundary with row boundaries running into it from the sides. On screen these are the same picture; in the tree they are opposite, and the adjacency test only looked for the first — two gaps touching side to side never matched, so a layout built by splitting the other way round had no crossings at all. The test is now that the two touch, in either axis. The crossing itself was never in doubt: it is the column boundary's columns by the row boundary's rows, which is the same cell either way. Corners now hold up to two boundaries of each kind rather than two column ones and a single row one. That asymmetry was an artefact of only ever having seen the first nesting — in the second it is two row boundaries that can line up and need to move together, for exactly the reason two column boundaries did.
Diffstat (limited to 'tests/test_corner.py')
-rw-r--r--tests/test_corner.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_corner.py b/tests/test_corner.py
index e89e0d0..244f65d 100644
--- a/tests/test_corner.py
+++ b/tests/test_corner.py
@@ -20,6 +20,11 @@ GRID = ('layout {\n tab name="t" {\n pane split="rows" {\n'
' pane split="cols" { pane\n pane }\n'
' pane split="cols" { pane\n pane }\n }\n }\n}\n')
COLUMNS = 'layout {\n tab name="t" {\n pane\n pane\n }\n}\n'
+# The other nesting: a full-height column boundary with row boundaries running
+# into it from the sides, rather than the other way round.
+GRID2 = ('layout {\n tab name="t" {\n pane split="cols" {\n'
+ ' pane split="rows" { pane\n pane }\n'
+ ' pane split="rows" { pane\n pane }\n }\n }\n}\n')
def lay(text):
@@ -223,6 +228,33 @@ def test_boundaries_out_of_line_are_two_crossings():
os.unlink(l)
+def test_it_finds_the_crossing_whichever_way_the_tree_is_nested():
+ """Rows of columns stops the column boundary where the row one begins;
+ columns of rows stops the row boundary where the column one begins. The
+ crossing is in the same place on screen either way, and only one of the two
+ was being found."""
+ for name, kdl in (("rows of columns", GRID), ("columns of rows", GRID2)):
+ l = lay(kdl)
+ with Session(SH, cols=70, rows=22, layout=l) as s:
+ s.settle(30)
+ c = corners(s)
+ check(f"{name}: the crossing is found", len(c) == 1, str(c))
+ if not c:
+ os.unlink(l)
+ continue
+ before = rects(s)
+ x, y = c[0]["x"], c[0]["y"]
+ s.send(rf"\e[<0;{x + 1};{y + 1}M")
+ s.send(rf"\e[<32;{x + 5};{y + 3}M")
+ s.send(rf"\e[<0;{x + 5};{y + 3}m")
+ s.settle(30)
+ after = rects(s)
+ check(f"{name}: dragging it moves both ways",
+ all(before[i] != after[i] for i in before),
+ f"{before} -> {after}")
+ os.unlink(l)
+
+
if __name__ == "__main__":
test_a_grid_has_a_corner_where_the_boundaries_cross()
test_a_layout_with_no_crossing_has_no_corner()
@@ -232,4 +264,5 @@ if __name__ == "__main__":
test_a_drag_keeps_the_boundaries_it_grabbed()
test_the_crossing_shows_itself_before_you_rest_on_it()
test_boundaries_out_of_line_are_two_crossings()
+ test_it_finds_the_crossing_whichever_way_the_tree_is_nested()
sys.exit(report())