summaryrefslogtreecommitdiff
path: root/tests/typ/utility/math.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-03-18 23:36:18 +0100
committerLaurenz <laurmaedje@gmail.com>2022-03-18 23:43:58 +0100
commitbeca01c826ee51c9ee6d5eadd7e5ef10f7fb9f58 (patch)
treee0ebb40b8775bba3b4be7bc47dceda3d349e2ac0 /tests/typ/utility/math.typ
parent77d153d315a2a5909840ebcd47491e4cef14428b (diff)
Methods
Diffstat (limited to 'tests/typ/utility/math.typ')
-rw-r--r--tests/typ/utility/math.typ27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/typ/utility/math.typ b/tests/typ/utility/math.typ
index ec62dbd2..d4ac7aa2 100644
--- a/tests/typ/utility/math.typ
+++ b/tests/typ/utility/math.typ
@@ -2,6 +2,33 @@
// Ref: false
---
+// Test conversion to numbers.
+#test(int(false), 0)
+#test(int(true), 1)
+#test(int(10), 10)
+#test(int("150"), 150)
+#test(int(10 / 3), 3)
+#test(float(10), 10.0)
+#test(float("31.4e-1"), 3.14)
+#test(type(float(10)), "float")
+
+---
+// Error: 6-10 cannot convert length to integer
+#int(10pt)
+
+---
+// Error: 8-13 cannot convert function to float
+#float(float)
+
+---
+// Error: 6-12 invalid integer
+#int("nope")
+
+---
+// Error: 8-15 invalid float
+#float("1.2.3")
+
+---
// Test the `abs` function.
#test(abs(-3), 3)
#test(abs(3), 3)