diff options
| author | Ian Wrzesinski <wrzian@umich.edu> | 2024-07-29 00:25:03 -0500 |
|---|---|---|
| committer | Ian Wrzesinski <wrzian@umich.edu> | 2025-01-23 16:28:29 -0500 |
| commit | c47b71b4350434a73734789ebde1374b791dc88e (patch) | |
| tree | 0157e3dc277010bb9581eac8a5881109aedc269f /tests/suite | |
| parent | 0b8b7d0f233f748a5c12d1b8e31f657803122eba (diff) | |
Basic SymbolElem addition
Diffstat (limited to 'tests/suite')
| -rw-r--r-- | tests/suite/foundations/content.typ | 12 | ||||
| -rw-r--r-- | tests/suite/math/symbols.typ | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/tests/suite/foundations/content.typ b/tests/suite/foundations/content.typ index 31ef1c54..9ddee597 100644 --- a/tests/suite/foundations/content.typ +++ b/tests/suite/foundations/content.typ @@ -50,12 +50,14 @@ `raw` <myraw> --- content-fields-complex --- -// Integrated test for content fields. +// Integrated test for content fields. The idea is to parse a normal looking +// equation and symbolically evaluate it with the given variable values. + #let compute(equation, ..vars) = { let vars = vars.named() let f(elem) = { let func = elem.func() - if func == text { + if elem.has("text") { let text = elem.text if regex("^\d+$") in text { int(text) @@ -74,7 +76,7 @@ elem .children .filter(v => v != [ ]) - .split[+] + .split($+$.body) .map(xs => xs.fold(1, (prod, v) => prod * f(v))) .fold(0, (sum, v) => sum + v) } @@ -83,13 +85,15 @@ [With ] vars .pairs() - .map(p => $#p.first() = #p.last()$) + .map(((name, value)) => $name = value$) .join(", ", last: " and ") [ we have:] $ equation = result $ } #compute($x y + y^2$, x: 2, y: 3) +// This should generate the same output as: +// With $x = 2$ and $y = 3$ we have: $ x y + y^2 = 15 $ --- content-label-has-method --- // Test whether the label is accessible through the `has` method. diff --git a/tests/suite/math/symbols.typ b/tests/suite/math/symbols.typ index 65a48316..6dd9db62 100644 --- a/tests/suite/math/symbols.typ +++ b/tests/suite/math/symbols.typ @@ -2,7 +2,7 @@ --- math-symbol-basic --- #let sym = symbol("s", ("basic", "s")) -#test($sym.basic$, $#"s"$) +#test($sym.basic$, $s$) --- math-symbol-underscore --- #let sym = symbol("s", ("test_underscore", "s")) @@ -16,7 +16,7 @@ $sym.test-dash$ --- math-symbol-double --- #let sym = symbol("s", ("test.basic", "s")) -#test($sym.test.basic$, $#"s"$) +#test($sym.test.basic$, $s$) --- math-symbol-double-underscore --- #let sym = symbol("s", ("one.test_underscore", "s")) |
