summaryrefslogtreecommitdiff
path: root/tests/typ/layout
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-02-13 16:50:57 +0100
committerLaurenz <laurmaedje@gmail.com>2023-02-13 16:50:57 +0100
commit8f68bc7a8ea619af12d95bec7025bd9f3a86625f (patch)
tree7f9b454ed419b45d7787de4ace992b40078d4072 /tests/typ/layout
parentb1b4e52af9e2da8f8ae1fc17a81ed6cbcbb8f525 (diff)
Dissolve basics folder
Diffstat (limited to 'tests/typ/layout')
-rw-r--r--tests/typ/layout/enum.typ28
-rw-r--r--tests/typ/layout/list-attach.typ54
-rw-r--r--tests/typ/layout/list.typ56
-rw-r--r--tests/typ/layout/table.typ22
-rw-r--r--tests/typ/layout/terms.typ52
5 files changed, 212 insertions, 0 deletions
diff --git a/tests/typ/layout/enum.typ b/tests/typ/layout/enum.typ
new file mode 100644
index 00000000..9512e1b5
--- /dev/null
+++ b/tests/typ/layout/enum.typ
@@ -0,0 +1,28 @@
+// Test enumerations.
+
+---
+#enum[Embrace][Extend][Extinguish]
+
+---
+1. First.
+ 2. Indented
+
++ Second
+
+---
+// Test automatic numbering in summed content.
+#for i in range(5) {
+ [+ #numbering("I", 1 + i)]
+}
+
+---
+// Mix of different lists
+- Bullet List
++ Numbered List
+/ Term: List
+
+---
+// Edge cases.
++
+Empty
++Nope
diff --git a/tests/typ/layout/list-attach.typ b/tests/typ/layout/list-attach.typ
new file mode 100644
index 00000000..9d043eb0
--- /dev/null
+++ b/tests/typ/layout/list-attach.typ
@@ -0,0 +1,54 @@
+// Test list attaching.
+
+---
+// Test basic attached list.
+Attached to:
+- the bottom
+- of the paragraph
+
+Next paragraph.
+
+---
+// Test that attached list isn't affected by block spacing.
+#show list: set block(above: 100pt)
+Hello
+- A
+World
+- B
+
+---
+// Test non-attached list followed by attached list,
+// separated by only word.
+Hello
+
+- A
+
+World
+- B
+
+---
+// Test non-attached tight list.
+#set block(spacing: 15pt)
+Hello
+- A
+World
+
+- B
+- C
+
+More.
+
+---
+// Test that wide lists cannot be ...
+#set block(spacing: 15pt)
+Hello
+- A
+
+- B
+World
+
+---
+// ... even if forced to.
+Hello
+#list(tight: false)[A][B]
+World
diff --git a/tests/typ/layout/list.typ b/tests/typ/layout/list.typ
new file mode 100644
index 00000000..3fd9ddb1
--- /dev/null
+++ b/tests/typ/layout/list.typ
@@ -0,0 +1,56 @@
+// Test bullet lists.
+
+---
+_Shopping list_
+#list[Apples][Potatoes][Juice]
+
+---
+- First level.
+
+ - Second level.
+ There are multiple paragraphs.
+
+ - Third level.
+
+ Still the same bullet point.
+
+ - Still level 2.
+
+- At the top.
+
+---
+- Level 1
+ - Level #[
+2 through content block
+]
+
+---
+ - Top-level indent
+- is fine.
+
+---
+ - A
+ - B
+ - C
+- D
+
+---
+// This works because tabs are used consistently.
+ - A with 1 tab
+ - B with 2 tabs
+
+---
+// This doesn't work because of mixed tabs and spaces.
+ - A with 2 spaces
+ - B with 2 tabs
+
+---
+#set list(marker: [-])
+- Bare hyphen
+- is not a list
+
+---
+// Edge cases.
+-
+Not in list
+-Nope
diff --git a/tests/typ/layout/table.typ b/tests/typ/layout/table.typ
new file mode 100644
index 00000000..5d423e03
--- /dev/null
+++ b/tests/typ/layout/table.typ
@@ -0,0 +1,22 @@
+// Test tables.
+
+---
+#set page(height: 70pt)
+#set table(fill: (x, y) => if calc.even(x + y) { rgb("aaa") })
+
+#table(
+ columns: (1fr,) * 3,
+ stroke: 2pt + rgb("333"),
+ [A], [B], [C], [], [], [D \ E \ F \ \ \ G], [H],
+)
+
+---
+#table(columns: 3, stroke: none, fill: green, [A], [B], [C])
+
+---
+// Ref: false
+#table()
+
+---
+// Error: 14-19 expected color, none, or function, found string
+#table(fill: "hey")
diff --git a/tests/typ/layout/terms.typ b/tests/typ/layout/terms.typ
new file mode 100644
index 00000000..57864423
--- /dev/null
+++ b/tests/typ/layout/terms.typ
@@ -0,0 +1,52 @@
+// Test term list.
+
+---
+// Test with constructor.
+#terms(
+ ([One], [First]),
+ ([Two], [Second]),
+)
+
+---
+// Test joining.
+#for word in lorem(4).split().map(s => s.trim(".")) [
+ / #word: Latin stuff.
+]
+
+---
+// Test multiline.
+#set text(8pt)
+
+/ Fruit: A tasty, edible thing.
+/ Veggie:
+ An important energy source
+ for vegetarians.
+
+---
+// Test style change.
+#set text(8pt)
+/ First list: #lorem(4)
+
+#set terms(hanging-indent: 30pt)
+/ Second list: #lorem(4)
+
+---
+// Test grid like show rule.
+#show terms: it => table(
+ columns: 2,
+ inset: 3pt,
+ ..it.items.map(item => (emph(item.at(0)), item.at(1))).flatten(),
+)
+
+/ A: One letter
+/ BB: Two letters
+/ CCC: Three letters
+
+---
+/ Term:
+Not in list
+/Nope
+
+---
+// Error: 8 expected colon
+/ Hello