summaryrefslogtreecommitdiff
path: root/tests/typ
diff options
context:
space:
mode:
Diffstat (limited to 'tests/typ')
-rw-r--r--tests/typ/code/dict.typ2
-rw-r--r--tests/typ/code/field.typ2
-rw-r--r--tests/typ/style/construct.typ2
-rw-r--r--tests/typ/style/set-site.typ28
-rw-r--r--tests/typ/style/set.typ27
-rw-r--r--tests/typ/style/show-node.typ67
-rw-r--r--tests/typ/style/show-recursive.typ65
-rw-r--r--tests/typ/style/show.typ52
8 files changed, 161 insertions, 84 deletions
diff --git a/tests/typ/code/dict.typ b/tests/typ/code/dict.typ
index aa840eb3..23af145f 100644
--- a/tests/typ/code/dict.typ
+++ b/tests/typ/code/dict.typ
@@ -23,7 +23,7 @@
// Test rvalue missing key.
{
let dict = (a: 1, b: 2)
- // Error: 11-20 dictionary does not contain key: "c"
+ // Error: 11-20 dictionary does not contain key "c"
let x = dict("c")
}
diff --git a/tests/typ/code/field.typ b/tests/typ/code/field.typ
index ff1dad9e..abccaede 100644
--- a/tests/typ/code/field.typ
+++ b/tests/typ/code/field.typ
@@ -12,7 +12,7 @@
}
---
-// Error: 6-13 dictionary does not contain key: "invalid"
+// Error: 6-13 dictionary does not contain key "invalid"
{(:).invalid}
---
diff --git a/tests/typ/style/construct.typ b/tests/typ/style/construct.typ
index 890c4b94..4b0f966a 100644
--- a/tests/typ/style/construct.typ
+++ b/tests/typ/style/construct.typ
@@ -1,4 +1,4 @@
-// Test class construction.
+// Test node functions.
---
// Ensure that constructor styles aren't passed down the tree.
diff --git a/tests/typ/style/set-site.typ b/tests/typ/style/set-site.typ
deleted file mode 100644
index b49d1027..00000000
--- a/tests/typ/style/set-site.typ
+++ /dev/null
@@ -1,28 +0,0 @@
-// Test that set affects the instantiation site and not the
-// definition site of a content.
-
----
-// Test that text is affected by instantiation-site bold.
-#let x = [World]
-Hello *{x}*
-
----
-// Test that lists are affected by correct indents.
-#let fruit = [
- - Apple
- - Orange
- #list(body-indent: 20pt, [Pear])
-]
-
-- Fruit
-[#set list(indent: 10pt)
- #fruit]
-- No more fruit
-
----
-// Test that that par spacing and text style are respected from
-// the outside, but the more specific fill is respected.
-#set par(spacing: 4pt)
-#set text(style: "italic", fill: eastern)
-#let x = [And the forest #parbreak() lay silent!]
-#text(fill: forest, x)
diff --git a/tests/typ/style/set.typ b/tests/typ/style/set.typ
index 927d8aa6..24966612 100644
--- a/tests/typ/style/set.typ
+++ b/tests/typ/style/set.typ
@@ -1,5 +1,30 @@
// General tests for set.
-// Ref: false
+
+---
+// Test that text is affected by instantiation-site bold.
+#let x = [World]
+Hello *{x}*
+
+---
+// Test that lists are affected by correct indents.
+#let fruit = [
+ - Apple
+ - Orange
+ #list(body-indent: 20pt, [Pear])
+]
+
+- Fruit
+[#set list(indent: 10pt)
+ #fruit]
+- No more fruit
+
+---
+// Test that that par spacing and text style are respected from
+// the outside, but the more specific fill is respected.
+#set par(spacing: 4pt)
+#set text(style: "italic", fill: eastern)
+#let x = [And the forest #parbreak() lay silent!]
+#text(fill: forest, x)
---
// Error: 2-10 set, show and wrap are only allowed directly in markup
diff --git a/tests/typ/style/show-node.typ b/tests/typ/style/show-node.typ
new file mode 100644
index 00000000..4fcee9aa
--- /dev/null
+++ b/tests/typ/style/show-node.typ
@@ -0,0 +1,67 @@
+// Test node show rules.
+
+---
+// Override lists.
+#set list(around: none)
+#show v: list as "(" + v.items.join(", ") + ")"
+
+- A
+ - B
+ - C
+- D
+- E
+
+---
+// Test full reset.
+#set heading(size: 1em, strong: false, around: none)
+#show heading as [B]
+A [= Heading] C
+
+---
+// Test full removal.
+#show heading as []
+#set heading(around: none)
+
+Where is
+= There are not headings around here!
+my heading?
+
+---
+// Test integrated example.
+#set heading(size: 1em)
+#show node: heading as {
+ move(dy: -1pt)[📖]
+ h(5pt)
+ if node.level == 1 {
+ underline(text(1.25em, blue, node.body))
+ } else {
+ text(red, node.body)
+ }
+}
+
+= Task 1
+Some text.
+
+== Subtask
+Some more text.
+
+= Task 2
+Another text.
+
+---
+// Error: 18-22 expected content, found string
+#show heading as "hi"
+= Heading
+
+---
+// Error: 25-29 unknown field "page"
+#show it: heading as it.page
+= Heading
+
+---
+// Error: 10-15 this function cannot be customized with show
+#show _: upper as {}
+
+---
+// Error: 2-16 set, show and wrap are only allowed directly in markup
+{show list as a}
diff --git a/tests/typ/style/show-recursive.typ b/tests/typ/style/show-recursive.typ
new file mode 100644
index 00000000..423bbd80
--- /dev/null
+++ b/tests/typ/style/show-recursive.typ
@@ -0,0 +1,65 @@
+// Test recursive show rules.
+
+---
+// Test basic identity.
+#show it: heading as it
+= Heading
+
+---
+// Test more recipes down the chain.
+#show it: list as scale(origin: left, x: 80%, it)
+#show heading as []
+#show enum as []
+- Actual
+- Tight
+- List
+
+---
+// Test recursive base recipe. (Burn it with fire!)
+#set list(label: [- Hey])
+- Labelless
+- List
+
+---
+// Test show rule in function.
+#let starwars(body) = [
+ #show v: list as {
+ stack(dir: ltr,
+ text(red, v),
+ 1fr,
+ scale(x: -100%, text(blue, v)),
+ )
+ }
+ #body
+]
+
+- Normal list
+#starwars[
+ - Star
+ - Wars
+ - List
+]
+- Normal list
+
+---
+// Test multi-recursion with nested lists.
+#set rect(padding: 2pt)
+#show v: list as rect(stroke: blue, v)
+#show v: list as rect(stroke: red, v)
+
+- List
+ - Nested
+ - List
+- Recursive!
+
+---
+// Inner heading is not finalized. Bug?
+#set heading(around: none)
+#show it: heading as it.body
+#show heading as [
+ = A [
+ = B
+ ]
+]
+
+= Discarded
diff --git a/tests/typ/style/show.typ b/tests/typ/style/show.typ
deleted file mode 100644
index a71b8df2..00000000
--- a/tests/typ/style/show.typ
+++ /dev/null
@@ -1,52 +0,0 @@
-// Test show rules.
-
-#set page("a8", footer: p => v(-5pt) + align(right, [#p]))
-
-#let i = 1
-#set heading(size: 1em)
-#show node: heading as {
- if node.level == 1 {
- v(10pt)
- underline(text(1.5em, blue)[{i}. {node.body}])
- i += 1
- } else {
- text(red, node.body)
- }
-}
-
-#v(-10pt)
-
-= Aufgabe
-Some text.
-
-== Subtask
-Some more text.
-
-== Another subtask
-Some more text.
-
-= Aufgabe
-Another text.
-
----
-#set heading(size: 1em, strong: false, around: none)
-#show _: heading as [B]
-A [= Heading] C
-
----
-// Error: 21-25 expected content, found string
-#show _: heading as "hi"
-= Heading
-
----
-// Error: 22-29 dictionary does not contain key: "page"
-#show it: heading as it.page
-= Heading
-
----
-// Error: 10-15 this function cannot be customized with show
-#show _: upper as {}
-
----
-// Error: 2-19 set, show and wrap are only allowed directly in markup
-{show a: list as a}