summaryrefslogtreecommitdiff
path: root/tests/typ/layout
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-06-26 15:47:37 +0200
committerLaurenz <laurmaedje@gmail.com>2021-06-26 15:47:37 +0200
commitd53c933e4d56e6c0484d81814779ddb1597ee032 (patch)
tree493aa2f8397a26b11a1137d2882994686b5ac7de /tests/typ/layout
parent784018124d13a4cfb050b8bf1fecd283cdc309db (diff)
Add box and block functions
Diffstat (limited to 'tests/typ/layout')
-rw-r--r--tests/typ/layout/containers.typ42
-rw-r--r--tests/typ/layout/fixed.typ14
-rw-r--r--tests/typ/layout/pad.typ19
-rw-r--r--tests/typ/layout/pagebreak.typ4
4 files changed, 60 insertions, 19 deletions
diff --git a/tests/typ/layout/containers.typ b/tests/typ/layout/containers.typ
new file mode 100644
index 00000000..b2835b5e
--- /dev/null
+++ b/tests/typ/layout/containers.typ
@@ -0,0 +1,42 @@
+// Test the `box` and `block` containers.
+
+---
+// Test box in paragraph.
+A #box[B \ C] D.
+
+// Test box with height.
+Spaced \
+#box(height: 0.5cm) \
+Apart
+
+---
+// Test block over multiple pages.
+
+#page(height: 60pt)
+
+First!
+#block[
+ But, soft! what light through yonder window breaks? It is the east, and Juliet
+ is the sun.
+]
+
+---
+// Test shrink-to-fit vs expand.
+
+// Top-level paragraph fills page
+L #align(right)[R]
+
+// Block also fills page.
+#block[
+ L #align(right)[R]
+]
+
+// Boxed paragraph respects width.
+#box(width: 50pt)[
+ L #align(right)[R]
+]
+
+// Boxed paragraph without width doesn't expand.
+#box[
+ L #align(right)[R]
+]
diff --git a/tests/typ/layout/fixed.typ b/tests/typ/layout/fixed.typ
deleted file mode 100644
index 51646eaa..00000000
--- a/tests/typ/layout/fixed.typ
+++ /dev/null
@@ -1,14 +0,0 @@
-// Test shrink-to-fit vs expand.
-
----
-#let right(body) = align(right, body)
-#let pad(body) = pad(left: 10pt, right: 10pt, body)
-
-// Top-level paragraph fills page, boxed paragraph only when the width is set.
-L #right[R] \
-#rect(width: 50pt)[L #right[R]] \
-#rect[L #right[R]]
-
-// Pad inherits expansion behaviour.
-#rect(pad[PL #right[PR]])
-#pad[PL #right[PR]]
diff --git a/tests/typ/layout/pad.typ b/tests/typ/layout/pad.typ
index 8c23549a..142ae4a9 100644
--- a/tests/typ/layout/pad.typ
+++ b/tests/typ/layout/pad.typ
@@ -11,13 +11,26 @@
]
]
-// Error: 14-24 missing argument: body
-Hi #rect(pad(left: 10pt)) there
+// Error: 13-23 missing argument: body
+Hi #box(pad(left: 10pt)) there
+
+---
+#let pad(body) = pad(left: 10pt, right: 10pt, body)
+
+// Pad inherits expansion behaviour from stack ....
+#pad[PL #align(right)[PR]]
+
+// ... block ...
+#block(pad[PL #align(right)[PR]])
+
+// ... and box.
+#box(pad[PL #align(right)[PR]])
---
// Test that the pad node doesn't consume the whole region.
-#page(width: 4cm, height: 5cm)
+#page(height: 6cm)
+
#align(left)[Before]
#pad(10pt, image("../../res/tiger.jpg"))
#align(right)[After]
diff --git a/tests/typ/layout/pagebreak.typ b/tests/typ/layout/pagebreak.typ
index bb7013ab..dedf1ce6 100644
--- a/tests/typ/layout/pagebreak.typ
+++ b/tests/typ/layout/pagebreak.typ
@@ -6,9 +6,9 @@ First of two
#page(height: 40pt)
---
-// Make sure that you can't do page related stuff in a shape.
+// Make sure that you can't do page related stuff in a container.
A
-#rect[
+#box[
B
// Error: 16 cannot modify page from here
#pagebreak()