summaryrefslogtreecommitdiff
path: root/tests/typ/style/closure.typ
blob: 22626472377f4305321c2e72f44c21c3e7e016d0 (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
// Test styles with closure.

---
#set heading(
  size: 10pt,
  fill: lvl => if even(lvl) { red } else { blue },
)

= Heading 1
== Heading 2
=== Heading 3
==== Heading 4

---
// Test in constructor.
#heading(
  level: 3,
  size: 10pt,
  strong: lvl => {
    assert(lvl == 3)
    false
  }
)[Level 3]

---
// Error: 22-26 expected string or auto or function, found length
#set heading(family: 10pt)
= Heading

---
// Error: 29-38 cannot add integer and string
#set heading(strong: lvl => lvl + "2")
= Heading

---
// Error: 22-34 expected string or auto, found boolean
#set heading(family: lvl => false)
= Heading

---
// Error: 22-37 missing argument: b
#set heading(family: (a, b) => a + b)
= Heading

---
// Error: 22-30 unexpected argument
#set heading(family: () => {})
= Heading