Better function call tests ✔

This commit is contained in:
Laurenz 2021-02-18 14:17:20 +01:00
parent 84cdc85ca7
commit cc964e32c9
14 changed files with 64 additions and 52 deletions

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
tests/lang/ref/call.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1,4 +1,4 @@
// Test return value of code blocks.
// Test code blocks.
---
All none

View File

@ -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)}

View File

@ -4,6 +4,26 @@
// Error: 1-2 unexpected invalid token
#
---
// 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"

View File

@ -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")

40
tests/lang/typ/call.typ Normal file
View File

@ -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")

View File

@ -1,4 +1,4 @@
// Test which things are iterable.
// Test for loops.
// Ref: false
---

View File

@ -1,4 +1,4 @@
// Test conditions of if-else expressions.
// Test if-else expressions.
---
// Test condition evaluation.

View File

@ -1,4 +1,4 @@
// Test value of let binding.
// Test let bindings.
// Ref: false
---