summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-10-25 13:34:49 +0200
committerLaurenz <laurmaedje@gmail.com>2021-10-25 13:38:32 +0200
commit3968181622694c4a15ae336049439b328649bca0 (patch)
tree979093e93b49bfde47e54bc4475cedf24d12e3d8 /tests
parentadf52a873f0cdff310c236998fc5018a886b339b (diff)
Replace `..` syntax with `range` function
Diffstat (limited to 'tests')
-rw-r--r--tests/typ/code/ops-invalid.typ6
-rw-r--r--tests/typ/code/ops.typ12
-rw-r--r--tests/typ/utility/basics.typ2
-rw-r--r--tests/typ/utility/color.typ4
-rw-r--r--tests/typ/utility/math.typ36
5 files changed, 38 insertions, 22 deletions
diff --git a/tests/typ/code/ops-invalid.typ b/tests/typ/code/ops-invalid.typ
index 1355181a..91dd576f 100644
--- a/tests/typ/code/ops-invalid.typ
+++ b/tests/typ/code/ops-invalid.typ
@@ -53,7 +53,7 @@
---
{
let x = 2
- for _ in 0..61 {
+ for _ in range(61) {
x *= 2
}
// Error: 4-18 cannot repeat this string 4611686018427387904 times
@@ -73,10 +73,6 @@
{ 1 with () }
---
-// Error: 3-10 cannot apply '..' to integer and string
-{ 1 .. "" }
-
----
// Error: 3-6 cannot access this expression mutably
{ (x) = "" }
diff --git a/tests/typ/code/ops.typ b/tests/typ/code/ops.typ
index 149837b2..61d1ce38 100644
--- a/tests/typ/code/ops.typ
+++ b/tests/typ/code/ops.typ
@@ -162,18 +162,6 @@
{ x += "thing" } #test(x, "something")
---
-// Test range operator.
-
-#let array = (1, 2, 3)
-#test(1..4, array)
-#test(1.. 4, array)
-#test(1 ..4, array)
-#test(1 .. 4, array)
-
-#test(-4..2, (-4, -3, -2, -1, 0, 1))
-#test(10..5, ())
-
----
// Test with operator.
// Ref: true
diff --git a/tests/typ/utility/basics.typ b/tests/typ/utility/basics.typ
index 3cd4ffa9..304fe769 100644
--- a/tests/typ/utility/basics.typ
+++ b/tests/typ/utility/basics.typ
@@ -4,7 +4,7 @@
---
// Test the `assert` function.
#assert(1 + 1 == 2)
-#assert(2..5 == (2, 3, 4))
+#assert(range(2, 5) == (2, 3, 4))
#assert(not false)
---
diff --git a/tests/typ/utility/color.typ b/tests/typ/utility/color.typ
index 31d3dae8..54316a37 100644
--- a/tests/typ/utility/color.typ
+++ b/tests/typ/utility/color.typ
@@ -29,3 +29,7 @@
---
// Error: 5-11 missing argument: blue component
#rgb(0, 1)
+
+---
+// Error: 21-26 expected float, found boolean
+#rgb(0.1, 0.2, 0.3, false)
diff --git a/tests/typ/utility/math.typ b/tests/typ/utility/math.typ
index 7217babe..c01d497f 100644
--- a/tests/typ/utility/math.typ
+++ b/tests/typ/utility/math.typ
@@ -2,7 +2,7 @@
// Ref: false
---
-// Test `abs` function.
+// Test the `abs` function.
#test(abs(-3), 3)
#test(abs(3), 3)
#test(abs(-0.0), 0.0)
@@ -20,7 +20,7 @@
#abs("no number")
---
-// Test `min` and `max` functions.
+// 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)
@@ -31,5 +31,33 @@
#min()
---
-// Error: 14-18 cannot compare integer with string
-#test(min(1, "hi"), error)
+// Error: 9-13 cannot compare integer with string
+#min(1, "hi")
+
+---
+// Test the `range` function.
+#test(range(4), (0, 1, 2, 3))
+#test(range(1, 4), (1, 2, 3))
+#test(range(-4, 2), (-4, -3, -2, -1, 0, 1))
+#test(range(10, 5), ())
+#test(range(10, step: 3), (0, 3, 6, 9))
+#test(range(1, 4, step: 1), (1, 2, 3))
+#test(range(1, 8, step: 2), (1, 3, 5, 7))
+#test(range(5, 2, step: -1), (5, 4, 3))
+#test(range(10, 0, step: -3), (10, 7, 4, 1))
+
+---
+// Error: 7-9 missing argument: end
+#range()
+
+---
+// Error: 11-14 expected integer, found float
+#range(1, 2.0)
+
+---
+// Error: 17-22 expected integer, found string
+#range(4, step: "one")
+
+---
+// Error: 18-19 step must not be zero
+#range(10, step: 0)