summaryrefslogtreecommitdiff
path: root/tests/typ/compiler/content-field.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-04-13 10:39:45 +0200
committerGitHub <noreply@github.com>2024-04-13 08:39:45 +0000
commit020294fca9a7065d4b9cf4e677f606ebaaa29b00 (patch)
treec0027ad22046e2726c22298461327823d6b88d53 /tests/typ/compiler/content-field.typ
parent72dd79210602ecc799726fc096b078afbb47f299 (diff)
Better test runner (#3922)
Diffstat (limited to 'tests/typ/compiler/content-field.typ')
-rw-r--r--tests/typ/compiler/content-field.typ63
1 files changed, 0 insertions, 63 deletions
diff --git a/tests/typ/compiler/content-field.typ b/tests/typ/compiler/content-field.typ
deleted file mode 100644
index 96ce1dca..00000000
--- a/tests/typ/compiler/content-field.typ
+++ /dev/null
@@ -1,63 +0,0 @@
-// Tests content field access.
-
----
-// Ensure that fields from set rules are materialized into the element before
-// a show rule runs.
-#set table(columns: (10pt, auto))
-#show table: it => it.columns
-#table[A][B][C][D]
-
----
-// Test it again with a different element.
-#set heading(numbering: "(I)")
-#show heading: set text(size: 11pt, weight: "regular")
-#show heading: it => it.numbering
-= Heading
-
----
-// Test it with query.
-#set raw(lang: "rust")
-#context query(<myraw>).first().lang
-`raw` <myraw>
-
----
-// Integrated test for content fields.
-#let compute(equation, ..vars) = {
- let vars = vars.named()
- let f(elem) = {
- let func = elem.func()
- if func == text {
- let text = elem.text
- if regex("^\d+$") in text {
- int(text)
- } else if text in vars {
- int(vars.at(text))
- } else {
- panic("unknown math variable: " + text)
- }
- } else if func == math.attach {
- let value = f(elem.base)
- if elem.has("t") {
- value = calc.pow(value, f(elem.t))
- }
- value
- } else if elem.has("children") {
- elem
- .children
- .filter(v => v != [ ])
- .split[+]
- .map(xs => xs.fold(1, (prod, v) => prod * f(v)))
- .fold(0, (sum, v) => sum + v)
- }
- }
- let result = f(equation.body)
- [With ]
- vars
- .pairs()
- .map(p => $#p.first() = #p.last()$)
- .join(", ", last: " and ")
- [ we have:]
- $ equation = result $
-}
-
-#compute($x y + y^2$, x: 2, y: 3)