summaryrefslogtreecommitdiff
path: root/tests/typ/code/call.typ
blob: ffd91769660a20084cbaef53473c54ae013ca161 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Test function calls.
// Ref: false

---
// Ref: true

// Ommitted space.
[#font(weight:bold)Bold]

// Call return value of function with body.
#let f(x, body) = (y) => [#x] + body + [#y]
#f(1)[2](3)

// Don't parse this as a function.
// Should output `<function test> (it)`.
#test (it)

#let f(body) = body
#f[A]
#f()[A]
#f([A])

---
// Trailing comma.
#test(1 + 1, 2,)

// Call function assigned to variable.
#let alias = type
#test(alias(alias), "function")

// Callee expressions.
{
  // Wrapped in parens.
  test((type)("hi"), "string")

  // Call the return value of a function.
  let adder(dx) = x => x + dx
  test(adder(2)(5), 7)
}

---
// Error: 2-6 expected function or collection, found boolean
{true()}

---
#let x = "x"

// Error: 1-3 expected function or collection, found string
#x()

---
#let f(x) = x

// Error: 1-6 expected function or collection, found integer
#f(1)(2)

---
#let f(x) = x

// Error: 1-6 expected function or collection, found template
#f[1](2)

---
// Error: 7-8 expected expression, found colon
#func(:)

// Error: 10-12 expected expression, found end of block comment
#func(a:1*/)

// Error: 8 expected comma
#func(1 2)

// Error: 7-8 expected identifier
// Error: 9 expected expression
#func(1:)

// Error: 7-8 expected identifier
#func(1:2)

// 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("]