diff options
| author | T0mstone <39707032+T0mstone@users.noreply.github.com> | 2023-10-02 20:28:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-02 20:28:19 +0200 |
| commit | cf9bde3245817e068c8253070e7a94dcc05369fb (patch) | |
| tree | ec6bcd27a9e38d307015f9c3d5a94acc4379a468 /tests/typ | |
| parent | 34ebbaeb1082b82b4f38d0b8da9a07675127ed79 (diff) | |
Add capability to get current compiler version (#2016)
Diffstat (limited to 'tests/typ')
| -rw-r--r-- | tests/typ/compiler/bytes.typ | 2 | ||||
| -rw-r--r-- | tests/typ/compute/construct.typ | 2 | ||||
| -rw-r--r-- | tests/typ/compute/version.typ | 47 |
3 files changed, 49 insertions, 2 deletions
diff --git a/tests/typ/compiler/bytes.typ b/tests/typ/compiler/bytes.typ index fa724858..9a26e826 100644 --- a/tests/typ/compiler/bytes.typ +++ b/tests/typ/compiler/bytes.typ @@ -28,5 +28,5 @@ #bytes((a: 1)) --- -// Error: 8-15 expected bytes or array, found string +// Error: 8-15 expected bytes, array, or version, found string #array("hello") diff --git a/tests/typ/compute/construct.typ b/tests/typ/compute/construct.typ index d3cea0b4..6980c922 100644 --- a/tests/typ/compute/construct.typ +++ b/tests/typ/compute/construct.typ @@ -168,7 +168,7 @@ #test(str(10 / 3).len() > 10, true) --- -// Error: 6-8 expected integer, float, bytes, label, type, or string, found content +// Error: 6-8 expected integer, float, version, bytes, label, type, or string, found content #str([]) --- diff --git a/tests/typ/compute/version.typ b/tests/typ/compute/version.typ new file mode 100644 index 00000000..e33eeb6f --- /dev/null +++ b/tests/typ/compute/version.typ @@ -0,0 +1,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) |
