summaryrefslogtreecommitdiff
path: root/tests/typ/expr/ops-invalid.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-02-20 17:53:40 +0100
committerLaurenz <laurmaedje@gmail.com>2021-02-20 23:34:33 +0100
commit05727bfc3a9cfd45a8e2028dfd0806f7a8f88015 (patch)
tree6c0b66eb2a9dff224cb39eb6ccb478656a706c04 /tests/typ/expr/ops-invalid.typ
parent927341d93ae29678095e3b874bd68bfc57d4bc05 (diff)
Reorganize tests 🔀
Diffstat (limited to 'tests/typ/expr/ops-invalid.typ')
-rw-r--r--tests/typ/expr/ops-invalid.typ59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/typ/expr/ops-invalid.typ b/tests/typ/expr/ops-invalid.typ
new file mode 100644
index 00000000..f760ae31
--- /dev/null
+++ b/tests/typ/expr/ops-invalid.typ
@@ -0,0 +1,59 @@
+// Test invalid expressions.
+// Ref: false
+
+---
+// Missing expressions.
+
+// Error: 3 expected expression
+{-}
+
+// Error: 10 expected expression
+#test({1+}, 1)
+
+// Error: 10 expected expression
+#test({2*}, 2)
+
+---
+// Mismatched types.
+
+// Error: 2-12 cannot apply '+' to template
+{+([] + [])}
+
+// Error: 2-5 cannot apply '-' to string
+{-""}
+
+// Error: 2-8 cannot apply 'not' to array
+{not ()}
+
+// Error: 1:2-1:12 cannot apply '<=' to relative and relative
+{30% <= 40%}
+
+// Special messages for +, -, * and /.
+// Error: 4:03-4:10 cannot add integer and string
+// Error: 3:12-3:19 cannot subtract integer from relative
+// Error: 2:21-2:29 cannot multiply integer with boolean
+// Error: 1:31-1:39 cannot divide integer by length
+{(1 + "2", 40% - 1, 2 * true, 3 / 12pt)}
+
+// Error: 14-22 cannot apply '+=' to integer and string
+{ let x = 1; x += "2" }
+
+---
+// Bad left-hand sides of assignment.
+
+// Error: 3-6 cannot assign to this expression
+{ (x) = "" }
+
+// Error: 3-8 cannot assign to this expression
+{ 1 + 2 += 3 }
+
+// Error: 3-4 unknown variable
+{ z = 1 }
+
+// Error: 3-6 cannot assign to a constant
+{ box = "hi" }
+
+// Works if we define box beforehand
+// (since then it doesn't resolve to the standard library version anymore).
+#let box = ""
+{ box = "hi" }