summaryrefslogtreecommitdiff
path: root/tests/typ/compute/version.typ
blob: e33eeb6f6079bb395d518a22f71212846d47f70c (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
// Test versions.
// Ref: false

---
// Test version constructor.

// Empty.
#version()

// Plain.
#version(1, 2)

// Single Array argument.
#version((1, 2))

// Mixed arguments.
#version(1, (2, 3), 4, (5, 6), 7)

---
// Test equality of different-length versions
#test(version(), version(0))
#test(version(0), version(0, 0))
#test(version(1, 2), version(1, 2, 0, 0, 0, 0))
---
// Test `version.at`.

// Non-negative index in bounds
#test(version(1, 2).at(1), 2)

// Non-negative index out of bounds
#test(version(1, 2).at(4), 0)

// Negative index in bounds
#test(version(1, 2).at(-2), 1)

// Error: 2-22 component index out of bounds (index: -3, len: 2)
#version(1, 2).at(-3)

---
// Test version fields.
#test(version(1, 2, 3).major, 1)
#test(version(1, 2, 3).minor, 2)
#test(version(1, 2, 3).patch, 3)

---
// Test the type of `sys.version`
#test(type(sys.version), version)