summaryrefslogtreecommitdiff
path: root/tests/typ/utility/string.typ
blob: e002b2070d3487e32d6c8a494d2cbdb257764b74 (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
// Test string related methods.
// Ref: false

---
// Test conversion to string.
#test(str(123), "123")
#test(str(50.14), "50.14")
#test(str(10 / 3).len() > 10, true)
#test(repr(ltr), "ltr")
#test(repr((1, 2, false, )), "(1, 2, false)")

---
// Error: 6-8 cannot convert content to string
#str([])

---
// Test the `split` and `trim` methods.
#test(
    "Typst, LaTeX, Word, InDesign".split(",").map(s => s.trim()),
    ("Typst", "LaTeX", "Word", "InDesign"),
)

---
// Test the `upper` and `lower` functions.
#let memes = "ArE mEmEs gReAt?";
#test(lower(memes), "are memes great?")
#test(upper(memes), "ARE MEMES GREAT?")
#test(upper("Ελλάδα"), "ΕΛΛΆΔΑ")

---
// Error: 8-9 expected string or content, found integer
#upper(1)

---
// Error: 9-11 must be at least zero
#symbol(-1)

---
// Test integrated lower, upper and symbols.
// Ref: true

#upper("Abc 8")
#upper[def]

#lower("SCREAMING MUST BE SILENCED in " + roman(1672) + " years")

#for i in range(9) {
    symbol(i)
    [ and ]
    roman(i)
    [ for #i]
    parbreak()
}