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
95
96
97
98
99
100
101
102
103
104
105
106
107
|
// Test foundational functions.
// Ref: false
---
#test(type(1), int)
#test(type(ltr), direction)
#test(type(10 / 3), float)
---
#test(repr(ltr), "ltr")
#test(repr((1, 2, false, )), "(1, 2, false)")
---
// Test panic.
// Error: 7-9 panicked
#panic()
---
// Test panic.
// Error: 7-12 panicked with: 123
#panic(123)
---
// Test panic.
// Error: 7-24 panicked with: "this is wrong"
#panic("this is wrong")
---
// Test failing assertions.
// Error: 8-16 assertion failed
#assert(1 == 2)
---
// Test failing assertions.
// Error: 8-51 assertion failed: two is smaller than one
#assert(2 < 1, message: "two is smaller than one")
---
// Test failing assertions.
// Error: 9-15 expected boolean, found string
#assert("true")
---
// Test failing assertions.
// Error: 11-19 equality assertion failed: value 10 was not equal to 11
#assert.eq(10, 11)
---
// Test failing assertions.
// Error: 11-55 equality assertion failed: 10 and 12 are not equal
#assert.eq(10, 12, message: "10 and 12 are not equal")
---
// Test failing assertions.
// Error: 11-19 inequality assertion failed: value 11 was equal to 11
#assert.ne(11, 11)
---
// Test failing assertions.
// Error: 11-57 inequality assertion failed: must be different from 11
#assert.ne(11, 11, message: "must be different from 11")
---
// Test successful assertions.
#assert(5 > 3)
#assert.eq(15, 15)
#assert.ne(10, 12)
---
// Test the `type` function.
#test(type(1), int)
#test(type(ltr), direction)
#test(type(10 / 3), float)
---
// Test the eval function.
#test(eval("1 + 2"), 3)
#test(eval("1 + x", scope: (x: 3)), 4)
#test(eval("let x = x + 1; x + 1", scope: (x: 1)), 3)
---
// Test evaluation in other modes.
// Ref: true
#eval("[_Hello" + " World!_]") \
#eval("_Hello" + " World!_", mode: "markup") \
#eval("RR_1^NN", mode: "math", scope: (RR: math.NN, NN: math.RR))
---
// Error: 7-12 expected pattern
#eval("let")
---
#show raw: it => text(font: "PT Sans", eval("[" + it.text + "]"))
Interacting
```
#set text(blue)
Blue #move(dy: -0.15em)[🌊]
```
---
// Error: 7-17 cannot continue outside of loop
#eval("continue")
---
// Error: 7-12 expected semicolon or line break
#eval("1 2")
|