summaryrefslogtreecommitdiff
path: root/tests/typ/code/call.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-07-30 18:04:08 +0200
committerLaurenz <laurmaedje@gmail.com>2021-07-30 18:49:19 +0200
commit1ee1d078e2480ddd08d40915bc7a74a8352acff0 (patch)
tree1e7ff367278a19fead3e404cf06d65bfb80a6cd9 /tests/typ/code/call.typ
parent42a27b48df427edf8dbb624c51551a90ecf2e7ea (diff)
Fatal errors
- Makes errors fatal, so that a phase is only reached when all previous phases were error-free - Parsing still recovers and can produce multiple errors - Evaluation fails fast and can thus produce only a single error (except for parse errors due to an import) - The single error that could occur during execution is removed for now - Removes Value::Error variant
Diffstat (limited to 'tests/typ/code/call.typ')
-rw-r--r--tests/typ/code/call.typ128
1 files changed, 94 insertions, 34 deletions
diff --git a/tests/typ/code/call.typ b/tests/typ/code/call.typ
index eb5c6732..28ce860c 100644
--- a/tests/typ/code/call.typ
+++ b/tests/typ/code/call.typ
@@ -1,34 +1,64 @@
// Test function calls.
+// Ref: false
---
-// One argument.
-#args(bold)
+// Ref: true
-// One argument and trailing comma.
-#args(1,)
+// Ommitted space.
+#font(weight:bold)[Bold]
-// One named argument.
-#args(a:2)
+// Call return value of function with body.
+#let f(x, body) = (y) => [#x] + body + [#y]
+#f(1)[2](3)
-// Mixed arguments.
-{args(1, b: "2", 3)}
+// Don't parse this as a function.
+// Should output `<function test> (it)`.
+#test (it)
-// Should output `() + 2`.
-#args() + 2
+#let f(body) = body
+#f[A]
+#f()[A]
+#f([A])
---
-// Ref: false
+// Ref: true
+
+// Test multiple wide calls in separate expressions inside a template.
+[
+ #font!(fill: eastern) - First
+ #font!(fill: forest) - Second
+]
+
+// Test wide call in heading.
+= A #align!(right) B
+C
+
+---
+// Test wide call in expression.
+
+// Error: 2-4 wide calls are only allowed directly in templates
+{f!()}
+
+// Error: 5-7 wide calls are only allowed directly in templates
+#g!(f!())
+
+---
+// Test wide call evaluation semantics.
+#let x = 1
+#let f(x, body) = test(x, 1)
+#f!(x)
+{ x = 2 }
+
+---
+// Trailing comma.
+#test(1 + 1, 2,)
// Call function assigned to variable.
#let alias = type
#test(alias(alias), "function")
----
// Callee expressions.
{
- // Error: 5-9 expected function, found boolean
- true()
-
// Wrapped in parens.
test((type)("hi"), "string")
@@ -37,30 +67,60 @@
test(adder(2)(5), 7)
}
-#let f(x, body) = (y) => {
- [{x}] + body + [{y}]
-}
-
-// Call return value of function with body.
-#f(1)[2](3)
+---
+// Error: 2-6 expected function, found boolean
+{true()}
-// Don't allow this to be a closure.
-// Should output `x => "hi"`.
+---
#let x = "x"
-#x => "hi"
+
+// Error: 1-3 expected function, found string
+#x()
+
+---
+#let f(x) = x
+
+// Error: 1-6 expected function, found integer
+#f(1)(2)
+
+---
+#let f(x) = x
+
+// Error: 1-6 expected function, found template
+#f[1](2)
---
-// Different forms of template arguments.
+// Error: 7 expected argument list
+#func!
+
+// Error: 7-8 expected expression, found colon
+#func(:)
+
+// Error: 10-12 expected expression, found end of block comment
+#func(a:1*/)
-#let a = "a"
+// Error: 8 expected comma
+#func(1 2)
-#args(a) \
-#args[a] \
-#args(a, [b])
+// Error: 7-8 expected identifier
+// Error: 9 expected expression
+#func(1:)
-// Template can be argument or body depending on whitespace.
-#if "template" == type[b] [Sure ]
-#if "template" == type [Nope.] #else [thing.]
+// Error: 7-8 expected identifier
+#func(1:2)
-// Should output `<function args> (Okay.)`.
-#args (Okay.)
+// Error: 7-10 expected identifier
+{func((x):1)}
+
+---
+// Error: 2:1 expected closing bracket
+#func[`a]`
+
+---
+// Error: 7 expected closing paren
+{func(}
+
+---
+// Error: 2:1 expected quote
+// Error: 2:1 expected closing paren
+#func("]