diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-02-18 14:17:20 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-02-18 15:06:06 +0100 |
| commit | cc964e32c993e9446896f8a75731783108866ce8 (patch) | |
| tree | 37e70f8ef81c955601f2de019e9a703dc562ac25 | |
| parent | 84cdc85ca7494368e7ce2039fcef06ac2d3bd2ed (diff) | |
Better function call tests ✔
| -rw-r--r-- | tests/lang/ref/block.png (renamed from tests/lang/ref/block-value.png) | bin | 1367 -> 1367 bytes | |||
| -rw-r--r-- | tests/lang/ref/call-args.png | bin | 3432 -> 0 bytes | |||
| -rw-r--r-- | tests/lang/ref/call-invalid.png | bin | 1729 -> 3032 bytes | |||
| -rw-r--r-- | tests/lang/ref/call.png | bin | 0 -> 5157 bytes | |||
| -rw-r--r-- | tests/lang/ref/for.png (renamed from tests/lang/ref/for-loop.png) | bin | 1389 -> 1389 bytes | |||
| -rw-r--r-- | tests/lang/ref/if.png (renamed from tests/lang/ref/if-branch.png) | bin | 1959 -> 1959 bytes | |||
| -rw-r--r-- | tests/lang/typ/block.typ (renamed from tests/lang/typ/block-value.typ) | 2 | ||||
| -rw-r--r-- | tests/lang/typ/call-args.typ | 34 | ||||
| -rw-r--r-- | tests/lang/typ/call-invalid.typ | 20 | ||||
| -rw-r--r-- | tests/lang/typ/call-value.typ | 14 | ||||
| -rw-r--r-- | tests/lang/typ/call.typ | 40 | ||||
| -rw-r--r-- | tests/lang/typ/for.typ (renamed from tests/lang/typ/for-loop.typ) | 2 | ||||
| -rw-r--r-- | tests/lang/typ/if.typ (renamed from tests/lang/typ/if-branch.typ) | 2 | ||||
| -rw-r--r-- | tests/lang/typ/let.typ (renamed from tests/lang/typ/let-value.typ) | 2 |
14 files changed, 64 insertions, 52 deletions
diff --git a/tests/lang/ref/block-value.png b/tests/lang/ref/block.png Binary files differindex a3c03698..a3c03698 100644 --- a/tests/lang/ref/block-value.png +++ b/tests/lang/ref/block.png diff --git a/tests/lang/ref/call-args.png b/tests/lang/ref/call-args.png Binary files differdeleted file mode 100644 index b288be22..00000000 --- a/tests/lang/ref/call-args.png +++ /dev/null diff --git a/tests/lang/ref/call-invalid.png b/tests/lang/ref/call-invalid.png Binary files differindex 05db4b7e..f6c2d67f 100644 --- a/tests/lang/ref/call-invalid.png +++ b/tests/lang/ref/call-invalid.png diff --git a/tests/lang/ref/call.png b/tests/lang/ref/call.png Binary files differnew file mode 100644 index 00000000..d44d7178 --- /dev/null +++ b/tests/lang/ref/call.png diff --git a/tests/lang/ref/for-loop.png b/tests/lang/ref/for.png Binary files differindex 2f13985a..2f13985a 100644 --- a/tests/lang/ref/for-loop.png +++ b/tests/lang/ref/for.png diff --git a/tests/lang/ref/if-branch.png b/tests/lang/ref/if.png Binary files differindex 4e7f471a..4e7f471a 100644 --- a/tests/lang/ref/if-branch.png +++ b/tests/lang/ref/if.png diff --git a/tests/lang/typ/block-value.typ b/tests/lang/typ/block.typ index 4a075c03..196e6c14 100644 --- a/tests/lang/typ/block-value.typ +++ b/tests/lang/typ/block.typ @@ -1,4 +1,4 @@ -// Test return value of code blocks. +// Test code blocks. --- All none diff --git a/tests/lang/typ/call-args.typ b/tests/lang/typ/call-args.typ deleted file mode 100644 index 53ae0b97..00000000 --- a/tests/lang/typ/call-args.typ +++ /dev/null @@ -1,34 +0,0 @@ -// Test function call arguments. - ---- -// One argument. -#f(bold) - -// One argument and trailing comma. -#f(1,) - -// One named argument. -#f(a:2) - -// Mixed arguments. -{f(1, a: (3, 4), 2, b: "5")} - ---- -// Error: 4-5 expected expression, found colon -#f(:) - -// Error: 7-9 expected expression, found end of block comment -#f(a:1*/) - -// Error: 5 expected comma -#f(1 2) - -// Error: 2:4-2:5 expected identifier -// Error: 1:6 expected expression -#f(1:) - -// Error: 4-5 expected identifier -#f(1:2) - -// Error: 4-7 expected identifier -{f((x):1)} diff --git a/tests/lang/typ/call-invalid.typ b/tests/lang/typ/call-invalid.typ index 153f7a39..56b23a19 100644 --- a/tests/lang/typ/call-invalid.typ +++ b/tests/lang/typ/call-invalid.typ @@ -5,6 +5,26 @@ # --- +// Error: 4-5 expected expression, found colon +#f(:) + +// Error: 7-9 expected expression, found end of block comment +#f(a:1*/) + +// Error: 5 expected comma +#f(1 2) + +// Error: 2:4-2:5 expected identifier +// Error: 1:6 expected expression +#f(1:) + +// Error: 4-5 expected identifier +#f(1:2) + +// Error: 4-7 expected identifier +{f((x):1)} + +--- #let x = "string" // Error: 1-3 expected function, found string diff --git a/tests/lang/typ/call-value.typ b/tests/lang/typ/call-value.typ deleted file mode 100644 index 26e48d0f..00000000 --- a/tests/lang/typ/call-value.typ +++ /dev/null @@ -1,14 +0,0 @@ -// Test function calls. -// Ref: false - ---- -// Whitespace is significant. -#test(type(1), "integer") -#test (type (1), "integer") - -// From variable. -#let alias = type -#test(alias(alias), "function") - -// Returns template. -#test(type(font(12pt)), "template") diff --git a/tests/lang/typ/call.typ b/tests/lang/typ/call.typ new file mode 100644 index 00000000..101fb99c --- /dev/null +++ b/tests/lang/typ/call.typ @@ -0,0 +1,40 @@ +// Test function calls. + +--- +// One argument. +#f(bold) + +// One argument and trailing comma. +#f(1,) + +// One named argument. +#f(a:2) + +// Mixed arguments. +{f(1, a: (3, 4), 2, b: "5")} + +--- +// Different forms of template arguments. +// Ref: true + +#let a = "a" + +#f[a] \ +#f(a) \ +#f(a, [b]) \ +#f(a)[b] \ + +// Template can be argument or body depending on whitespace. +#if "template" == type[b] [Sure ] +#if "template" == type [Nope.] #else [thing.] + +// Should output `<function f> (Okay.)`. +#f (Okay.) + +--- +// Call function assigned to variable. +#let alias = type +#test(alias(alias), "function") + +// Library function `font` returns template. +#test(type(font(12pt)), "template") diff --git a/tests/lang/typ/for-loop.typ b/tests/lang/typ/for.typ index e38ed190..294345b5 100644 --- a/tests/lang/typ/for-loop.typ +++ b/tests/lang/typ/for.typ @@ -1,4 +1,4 @@ -// Test which things are iterable. +// Test for loops. // Ref: false --- diff --git a/tests/lang/typ/if-branch.typ b/tests/lang/typ/if.typ index 64523a63..4ed6b649 100644 --- a/tests/lang/typ/if-branch.typ +++ b/tests/lang/typ/if.typ @@ -1,4 +1,4 @@ -// Test conditions of if-else expressions. +// Test if-else expressions. --- // Test condition evaluation. diff --git a/tests/lang/typ/let-value.typ b/tests/lang/typ/let.typ index 700d337d..e609d3a9 100644 --- a/tests/lang/typ/let-value.typ +++ b/tests/lang/typ/let.typ @@ -1,4 +1,4 @@ -// Test value of let binding. +// Test let bindings. // Ref: false --- |
