summaryrefslogtreecommitdiff
path: root/tests/typ/code
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-08-12 16:00:09 +0200
committerLaurenz <laurmaedje@gmail.com>2021-08-12 16:07:42 +0200
commitd002cdf451e1c6efbf7cd7f2303264526b6f8a92 (patch)
tree31b8446728a93550cab57d50bba92eb32f280678 /tests/typ/code
parentccb4be4da4e8aeda115b22f2a0b586a86f5e31bd (diff)
Named arguments for user defined functions
Diffstat (limited to 'tests/typ/code')
-rw-r--r--tests/typ/code/closure.typ14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/typ/code/closure.typ b/tests/typ/code/closure.typ
index 1bc369e9..3b8b4261 100644
--- a/tests/typ/code/closure.typ
+++ b/tests/typ/code/closure.typ
@@ -83,3 +83,17 @@
// Error: 8-13 unexpected argument
f(1, "two", () => x)
}
+
+---
+// Named arguments.
+{
+ let greet(name, birthday: false) = {
+ if birthday { "Happy Birthday, " } else { "Hey, " } + name + "!"
+ }
+
+ test(greet("Typst"), "Hey, Typst!")
+ test(greet("Typst", birthday: true), "Happy Birthday, Typst!")
+
+ // Error: 23-35 unexpected argument
+ test(greet("Typst", whatever: 10))
+}