summaryrefslogtreecommitdiff
path: root/tests/typ/layout
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-06-10 16:46:01 +0200
committerLaurenz <laurmaedje@gmail.com>2021-06-10 16:46:01 +0200
commit5611c26577c4cf6d52b9b66b7b1a32253aa23ec1 (patch)
treeb06a64845ef691700aed7fd0ed1e22dd064cc742 /tests/typ/layout
parentbce553a991f19b2b5bb9efef6b74bd12e15a10c6 (diff)
Restructure tests
Diffstat (limited to 'tests/typ/layout')
-rw-r--r--tests/typ/layout/grid-1.typ54
-rw-r--r--tests/typ/layout/grid-2.typ29
-rw-r--r--tests/typ/layout/pad.typ13
-rw-r--r--tests/typ/layout/page.typ48
-rw-r--r--tests/typ/layout/pagebreak.typ23
-rw-r--r--tests/typ/layout/spacing.typ18
-rw-r--r--tests/typ/layout/stack.typ9
7 files changed, 194 insertions, 0 deletions
diff --git a/tests/typ/layout/grid-1.typ b/tests/typ/layout/grid-1.typ
new file mode 100644
index 00000000..6a4aee87
--- /dev/null
+++ b/tests/typ/layout/grid-1.typ
@@ -0,0 +1,54 @@
+// Test grid layouts.
+
+---
+#let rect(width, color) = rect(width: width, height: 2cm, fill: color)
+
+#page(width: 100pt, height: 140pt)
+#grid(
+ columns: (auto, 1fr, 3fr, 0.25cm, 3%, 2mm + 10%),
+ rect(0.5cm, #2a631a),
+ rect(100%, forest),
+ rect(100%, conifer),
+ rect(100%, #ff0000),
+ rect(100%, #00ff00),
+ rect(80%, #00faf0),
+ rect(1cm, #00ff00),
+ rect(0.5cm, #2a631a),
+ rect(100%, forest),
+ rect(100%, conifer),
+ rect(100%, #ff0000),
+ rect(100%, #00ff00),
+)
+
+#grid()
+
+---
+#grid(
+ columns: (auto, auto, 40%),
+ gutter: (1fr,),
+ rect(fill: eastern)[dddaa aaa aaa],
+ rect(fill: conifer)[ccc],
+ rect(width: 100%, fill: #dddddd)[aaa],
+)
+
+---
+#page(height: 3cm, width: 2cm)
+#grid(
+ columns: (1fr, 1cm, 1fr, 1fr),
+ column-dir: ttb,
+ rows: (auto, 1fr),
+ rect(height: 100%, fill: #222222)[foo],
+ rect(height: 100%, fill: #547d0a)[bar],
+ rect(height: 100%, fill: eastern)[hab],
+ rect(height: 100%, fill: conifer)[baz],
+ rect(height: 100%, width: 100%, fill: #547d0a)[bar],
+)
+
+---
+#page(height: 3cm, margins: 0pt)
+#align(center)
+#grid(
+ columns: (1fr,),
+ rows: (1fr, auto, 2fr),
+ [], rect(width: 100%)[A bit more to the top], [],
+)
diff --git a/tests/typ/layout/grid-2.typ b/tests/typ/layout/grid-2.typ
new file mode 100644
index 00000000..277e695c
--- /dev/null
+++ b/tests/typ/layout/grid-2.typ
@@ -0,0 +1,29 @@
+// Test using the `grid` function to create a finance table.
+
+---
+#page(width: 12cm, height: 2.5cm)
+#grid(
+ columns: 5,
+ gutter-columns: (2fr, 1fr, 1fr),
+ gutter-rows: 4 * (6pt,),
+ [*Quarter*],
+ [Expenditure],
+ [External Revenue],
+ [Financial ROI],
+ [_total_],
+ [*Q1*],
+ [173,472.57 \$],
+ [472,860.91 \$],
+ [51,286.84 \$],
+ [_350,675.18 \$_],
+ [*Q2*],
+ [93,382.12 \$],
+ [439,382.85 \$],
+ [-1,134.30 \$],
+ [_344,866.43 \$_],
+ [*Q3*],
+ [96,421.49 \$],
+ [238,583.54 \$],
+ [3,497.12 \$],
+ [_145,659.17 \$_],
+)
diff --git a/tests/typ/layout/pad.typ b/tests/typ/layout/pad.typ
new file mode 100644
index 00000000..3726ce53
--- /dev/null
+++ b/tests/typ/layout/pad.typ
@@ -0,0 +1,13 @@
+// Test the `pad` function.
+
+---
+// Use for indentation.
+#pad(left: 10pt, [Indented!])
+
+// All sides together.
+#rect(fill: conifer,
+ pad(10pt, right: 20pt,
+ rect(width: 20pt, height: 20pt, fill: #eb5278)))
+
+// Error: 14-24 missing argument: body
+Hi #rect(pad(left: 10pt)) there
diff --git a/tests/typ/layout/page.typ b/tests/typ/layout/page.typ
new file mode 100644
index 00000000..cf787e5d
--- /dev/null
+++ b/tests/typ/layout/page.typ
@@ -0,0 +1,48 @@
+// Test configuring page sizes and margins.
+
+---
+// Set width and height.
+#page(width: 120pt, height: 120pt)
+#page(width: 40pt)[High]
+#page(height: 40pt)[Wide]
+
+// Set all margins at once.
+#page(margins: 30pt)[
+ #align(top, left)[TL]
+ #align(bottom, right)[BR]
+]
+
+// Set individual margins.
+#page(height: 40pt)
+#page(left: 0pt, align(left)[Left])
+#page(right: 0pt, align(right)[Right])
+#page(top: 0pt, align(top)[Top])
+#page(bottom: 0pt, align(bottom)[Bottom])
+
+// Ensure that specific margins override general margins.
+#page(margins: 0pt, left: 20pt)[Overriden]
+
+// Error: 7-18 unknown variable
+#page(nonexistant)
+
+// Flipped predefined paper.
+#page("a11", flip: true)[Flipped A11]
+
+// Flipped custom page size.
+#page(width: 40pt, height: 120pt)
+#page(flip: true)
+Wide
+
+---
+// Test a combination of pages with bodies and normal content.
+
+#page(height: 50pt)
+
+#page[First]
+#page[Second]
+#pagebreak()
+#pagebreak()
+Fourth
+#page[]
+Sixth
+#page[Seventh and last]
diff --git a/tests/typ/layout/pagebreak.typ b/tests/typ/layout/pagebreak.typ
new file mode 100644
index 00000000..bb7013ab
--- /dev/null
+++ b/tests/typ/layout/pagebreak.typ
@@ -0,0 +1,23 @@
+// Test forced page breaks.
+
+---
+First of two
+#pagebreak()
+#page(height: 40pt)
+
+---
+// Make sure that you can't do page related stuff in a shape.
+A
+#rect[
+ B
+ // Error: 16 cannot modify page from here
+ #pagebreak()
+
+ // Error: 11-15 cannot modify page from here
+ #page("a4")
+]
+C
+
+// No consequences from the page("A4") call here.
+#pagebreak()
+D
diff --git a/tests/typ/layout/spacing.typ b/tests/typ/layout/spacing.typ
new file mode 100644
index 00000000..bd38631e
--- /dev/null
+++ b/tests/typ/layout/spacing.typ
@@ -0,0 +1,18 @@
+// Test the `h` and `v` functions.
+
+---
+// Ends paragraphs.
+Tightly #v(0pt) packed
+
+// Eating up soft spacing.
+Inv #h(0pt) isible
+
+// Multiple spacings in a row.
+Add #h(10pt) #h(10pt) up
+
+// Relative to font size.
+Relative #h(100%) spacing
+
+// Missing spacing.
+// Error: 12 missing argument: spacing
+Totally #h() ignored
diff --git a/tests/typ/layout/stack.typ b/tests/typ/layout/stack.typ
new file mode 100644
index 00000000..006a1412
--- /dev/null
+++ b/tests/typ/layout/stack.typ
@@ -0,0 +1,9 @@
+// Test stack layouts.
+
+---
+#let rect(width, color) = rect(width: width, height: 1cm, fill: color)
+#stack(
+ rect(2cm, #2a631a),
+ rect(3cm, forest),
+ rect(1cm, conifer),
+)