summaryrefslogtreecommitdiff
path: root/tests/suite/foundations/version.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-04-13 10:39:45 +0200
committerGitHub <noreply@github.com>2024-04-13 08:39:45 +0000
commit020294fca9a7065d4b9cf4e677f606ebaaa29b00 (patch)
treec0027ad22046e2726c22298461327823d6b88d53 /tests/suite/foundations/version.typ
parent72dd79210602ecc799726fc096b078afbb47f299 (diff)
Better test runner (#3922)
Diffstat (limited to 'tests/suite/foundations/version.typ')
-rw-r--r--tests/suite/foundations/version.typ47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/suite/foundations/version.typ b/tests/suite/foundations/version.typ
new file mode 100644
index 00000000..bf2cadb1
--- /dev/null
+++ b/tests/suite/foundations/version.typ
@@ -0,0 +1,47 @@
+// Test versions.
+
+--- version-constructor ---
+// Test version constructor.
+
+// Empty.
+#version()
+
+// Plain.
+#test(version(1, 2).major, 1)
+
+// Single Array argument.
+#test(version((1, 2)).minor, 2)
+
+// Mixed arguments.
+#test(version(1, (2, 3), 4, (5, 6), 7).at(5), 6)
+
+--- version-equality ---
+// 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))
+
+--- version-at ---
+// 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)
+
+--- version-fields ---
+// Test version fields.
+#test(version(1, 2, 3).major, 1)
+#test(version(1, 2, 3).minor, 2)
+#test(version(1, 2, 3).patch, 3)
+
+--- version-type ---
+// Test the type of `sys.version`
+#test(type(sys.version), version)