summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Haug <mhaug@live.de>2023-01-30 21:04:34 +0100
committerMartin Haug <mhaug@live.de>2023-01-30 21:04:34 +0100
commit0287b98ef31172c6da4d5a4c76d8d88d1d5c9049 (patch)
tree000bd243993a5212ce52c08374cf20cd0f61bcf9 /tests
parent1ea0a933254d866e00acb9034bba39a5f4790682 (diff)
Add calc module
Diffstat (limited to 'tests')
-rw-r--r--tests/typ/basics/enum.typ2
-rw-r--r--tests/typ/basics/table.typ2
-rw-r--r--tests/typ/compiler/array.typ4
-rw-r--r--tests/typ/compiler/break-continue.typ4
-rw-r--r--tests/typ/compiler/spread.typ10
-rw-r--r--tests/typ/compiler/string.typ2
-rw-r--r--tests/typ/compute/calc.typ60
-rw-r--r--tests/typ/layout/par.typ2
8 files changed, 43 insertions, 43 deletions
diff --git a/tests/typ/basics/enum.typ b/tests/typ/basics/enum.typ
index c1ce17b7..02eb03c2 100644
--- a/tests/typ/basics/enum.typ
+++ b/tests/typ/basics/enum.typ
@@ -43,7 +43,7 @@
spacing: 0.65em - 3pt,
tight: false,
numbering: n => text(
- fill: (red, green, blue).at(mod(n, 3)),
+ fill: (red, green, blue).at(calc.mod(n, 3)),
numbering("A", n),
),
[Red], [Green], [Blue],
diff --git a/tests/typ/basics/table.typ b/tests/typ/basics/table.typ
index e806b1aa..5d423e03 100644
--- a/tests/typ/basics/table.typ
+++ b/tests/typ/basics/table.typ
@@ -2,7 +2,7 @@
---
#set page(height: 70pt)
-#set table(fill: (x, y) => if even(x + y) { rgb("aaa") })
+#set table(fill: (x, y) => if calc.even(x + y) { rgb("aaa") })
#table(
columns: (1fr,) * 3,
diff --git a/tests/typ/compiler/array.typ b/tests/typ/compiler/array.typ
index 3d4d6106..2fea8632 100644
--- a/tests/typ/compiler/array.typ
+++ b/tests/typ/compiler/array.typ
@@ -148,8 +148,8 @@
---
// Test the `filter` method.
-#test(().filter(even), ())
-#test((1, 2, 3, 4).filter(even), (2, 4))
+#test(().filter(calc.even), ())
+#test((1, 2, 3, 4).filter(calc.even), (2, 4))
#test((7, 3, 2, 5, 1).filter(x => x < 5), (3, 2, 1))
---
diff --git a/tests/typ/compiler/break-continue.typ b/tests/typ/compiler/break-continue.typ
index 566234a7..e1041551 100644
--- a/tests/typ/compiler/break-continue.typ
+++ b/tests/typ/compiler/break-continue.typ
@@ -41,7 +41,7 @@
#while x < 8 {
i += 1
- if mod(i, 3) == 0 {
+ if calc.mod(i, 3) == 0 {
continue
}
x += i
@@ -55,7 +55,7 @@
#let x = for i in range(5) {
"a"
- if mod(i, 3) == 0 {
+ if calc.mod(i, 3) == 0 {
"_"
continue
}
diff --git a/tests/typ/compiler/spread.typ b/tests/typ/compiler/spread.typ
index ce3d8cea..e5724739 100644
--- a/tests/typ/compiler/spread.typ
+++ b/tests/typ/compiler/spread.typ
@@ -37,9 +37,9 @@
// Test spreading array and dictionary.
#{
let more = (3, -3, 6, 10)
- test(min(1, 2, ..more), -3)
- test(max(..more, 9), 10)
- test(max(..more, 11), 11)
+ test(calc.min(1, 2, ..more), -3)
+ test(calc.max(..more, 9), 10)
+ test(calc.max(..more, 11), 11)
}
#{
@@ -56,8 +56,8 @@
#f(..for x in () [])
---
-// Error: 8-14 cannot spread string
-#min(.."nope")
+// Error: 13-19 cannot spread string
+#calc.min(.."nope")
---
// Error: 10-14 expected identifier, found boolean
diff --git a/tests/typ/compiler/string.typ b/tests/typ/compiler/string.typ
index 57699074..d96213b6 100644
--- a/tests/typ/compiler/string.typ
+++ b/tests/typ/compiler/string.typ
@@ -88,7 +88,7 @@
let caps = match.captures
time += 60 * int(caps.at(0)) + int(caps.at(1))
}
- str(int(time / 60)) + ":" + str(mod(time, 60))
+ str(int(time / 60)) + ":" + str(calc.mod(time, 60))
}
#test(timesum(""), "0:0")
diff --git a/tests/typ/compute/calc.typ b/tests/typ/compute/calc.typ
index be207a05..195e3285 100644
--- a/tests/typ/compute/calc.typ
+++ b/tests/typ/compute/calc.typ
@@ -30,55 +30,55 @@
---
// Test the `abs` function.
-#test(abs(-3), 3)
-#test(abs(3), 3)
-#test(abs(-0.0), 0.0)
-#test(abs(0.0), -0.0)
-#test(abs(-3.14), 3.14)
-#test(abs(50%), 50%)
-#test(abs(-25%), 25%)
+#test(calc.abs(-3), 3)
+#test(calc.abs(3), 3)
+#test(calc.abs(-0.0), 0.0)
+#test(calc.abs(0.0), -0.0)
+#test(calc.abs(-3.14), 3.14)
+#test(calc.abs(50%), 50%)
+#test(calc.abs(-25%), 25%)
---
-// Error: 6-17 expected integer, float, length, angle, ratio, or fraction, found string
-#abs("no number")
+// Error: 11-22 expected integer, float, length, angle, ratio, or fraction, found string
+#calc.abs("no number")
---
// Test the `even` and `odd` functions.
-#test(even(2), true)
-#test(odd(2), false)
-#test(odd(-1), true)
-#test(even(-11), false)
+#test(calc.even(2), true)
+#test(calc.odd(2), false)
+#test(calc.odd(-1), true)
+#test(calc.even(-11), false)
---
// Test the `mod` function.
-#test(mod(1, 1), 0)
-#test(mod(5, 3), 2)
-#test(mod(5, -3), 2)
-#test(mod(22.5, 10), 2.5)
-#test(mod(9, 4.5), 0)
+#test(calc.mod(1, 1), 0)
+#test(calc.mod(5, 3), 2)
+#test(calc.mod(5, -3), 2)
+#test(calc.mod(22.5, 10), 2.5)
+#test(calc.mod(9, 4.5), 0)
---
-// Error: 9-10 divisor must not be zero
-#mod(5, 0)
+// Error: 14-15 divisor must not be zero
+#calc.mod(5, 0)
---
-// Error: 11-14 divisor must not be zero
-#mod(3.0, 0.0)
+// Error: 16-19 divisor must not be zero
+#calc.mod(3.0, 0.0)
---
// Test the `min` and `max` functions.
-#test(min(2, -4), -4)
-#test(min(3.5, 1e2, -0.1, 3), -0.1)
-#test(max(-3, 11), 11)
-#test(min("hi"), "hi")
+#test(calc.min(2, -4), -4)
+#test(calc.min(3.5, 1e2, -0.1, 3), -0.1)
+#test(calc.max(-3, 11), 11)
+#test(calc.min("hi"), "hi")
---
-// Error: 5-7 missing argument: value
-#min()
+// Error: 10-12 missing argument: value
+#calc.min()
---
-// Error: 9-13 cannot compare integer and string
-#min(1, "hi")
+// Error: 14-18 cannot compare integer and string
+#calc.min(1, "hi")
---
// Test the `range` function.
diff --git a/tests/typ/layout/par.typ b/tests/typ/layout/par.typ
index 264209b8..45b60cf5 100644
--- a/tests/typ/layout/par.typ
+++ b/tests/typ/layout/par.typ
@@ -19,7 +19,7 @@ It is the east, and Juliet is the sun.
#set block(spacing: 100pt)
#show table: set block(above: 5pt, below: 5pt)
Hello
-#table(columns: 4, fill: (x, y) => if odd(x + y) { silver })[A][B][C][D]
+#table(columns: 4, fill: (x, y) => if calc.odd(x + y) { silver })[A][B][C][D]
---
// While we're at it, test the larger block spacing wins.