summaryrefslogtreecommitdiff
path: root/tests/typ/structure
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-03-11 11:58:56 +0100
committerLaurenz <laurmaedje@gmail.com>2022-03-11 11:58:56 +0100
commite6b532391deb1e30dc356c4d20dd48199f748f29 (patch)
tree7b631414931164b9a47c9d154172195fc0e1316c /tests/typ/structure
parentb71113d37a29bab5c7dc4b501c33ee9afbdb8213 (diff)
More restructuring
Diffstat (limited to 'tests/typ/structure')
-rw-r--r--tests/typ/structure/enum.typ60
-rw-r--r--tests/typ/structure/heading.typ50
-rw-r--r--tests/typ/structure/list.typ51
-rw-r--r--tests/typ/structure/table.typ13
4 files changed, 174 insertions, 0 deletions
diff --git a/tests/typ/structure/enum.typ b/tests/typ/structure/enum.typ
new file mode 100644
index 00000000..8ba3cea6
--- /dev/null
+++ b/tests/typ/structure/enum.typ
@@ -0,0 +1,60 @@
+// Test enums.
+
+---
+. Embrace
+. Extend
+. Extinguish
+
+---
+1. First.
+ 2. Second.
+
+1. Back to first.
+
+---
+2. Second
+1. First
+ . Indented
+
+---
+// Test automatic numbering in summed templates.
+#for i in range(5) {
+ [. #roman(1 + i)]
+}
+
+---
+// Test label pattern.
+#set enum(label: "~ A:")
+. First
+. Second
+
+#set enum(label: "(*)")
+. A
+. B
+. C
+
+#set enum(label: "i)")
+. A
+. B
+
+---
+// Test label closure.
+#enum(
+ start: 4,
+ spacing: -3pt,
+ label: n => text(fill: (red, green, blue)(mod(n, 3)), [#upper(letter(n))]),
+ [Red], [Green], [Blue],
+)
+
+---
+// Error: 18-20 invalid pattern
+#set enum(label: "")
+
+---
+// Error: 18-24 invalid pattern
+#set enum(label: "(())")
+
+---
+// Error: 18-28 expected template, found boolean
+#set enum(label: n => false)
+. A
diff --git a/tests/typ/structure/heading.typ b/tests/typ/structure/heading.typ
new file mode 100644
index 00000000..2ae97aa8
--- /dev/null
+++ b/tests/typ/structure/heading.typ
@@ -0,0 +1,50 @@
+// Test headings.
+
+---
+// Different number of hashtags.
+
+// Valid levels.
+= Level 1
+=== Level 2
+====== Level 6
+
+// At some point, it should stop shrinking.
+=========== Level 11
+
+---
+// Heading vs. no heading.
+
+// Parsed as headings if at start of the context.
+/**/ = Level 1
+{[== Level 2]}
+#box[=== Level 3]
+
+// Not at the start of the context.
+No = heading
+
+// Escaped.
+\= No heading
+
+---
+// While indented at least as much as the start, the heading continues.
+
+= This
+ is
+ indented.
+
+= This
+is not.
+
+// Code blocks continue heading.
+= A {
+ "B"
+}
+
+---
+// Test styling.
+= Heading
+
+#set heading(family: "Roboto", fill: eastern)
+
+===== Heading 🌍
+#heading(level: 5)[Heading]
diff --git a/tests/typ/structure/list.typ b/tests/typ/structure/list.typ
new file mode 100644
index 00000000..38fc2c63
--- /dev/null
+++ b/tests/typ/structure/list.typ
@@ -0,0 +1,51 @@
+// Test lists.
+
+---
+_Shopping list_
+- Apples
+- Potatoes
+- Juice
+
+---
+Tightly
+- surrounded
+- by two
+paragraphs.
+
+---
+- 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 template
+]
+
+---
+ - 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
diff --git a/tests/typ/structure/table.typ b/tests/typ/structure/table.typ
new file mode 100644
index 00000000..0372951c
--- /dev/null
+++ b/tests/typ/structure/table.typ
@@ -0,0 +1,13 @@
+#set page(height: 70pt)
+#set table(primary: rgb("aaa"), secondary: none)
+
+#table(
+ columns: (1fr,) * 3,
+ stroke: rgb("333"),
+ thickness: 2pt,
+ [A], [B], [C], [], [], [D \ E \ F \ \ \ G], [H],
+)
+
+---
+// Ref: false
+#table()