diff options
Diffstat (limited to 'tests/typ/compiler')
| -rw-r--r-- | tests/typ/compiler/bytes.typ | 21 | ||||
| -rw-r--r-- | tests/typ/compiler/string.typ | 3 |
2 files changed, 22 insertions, 2 deletions
diff --git a/tests/typ/compiler/bytes.typ b/tests/typ/compiler/bytes.typ new file mode 100644 index 00000000..32d0d573 --- /dev/null +++ b/tests/typ/compiler/bytes.typ @@ -0,0 +1,21 @@ +// Test the bytes type. +// Ref: false + +--- +#let data = read("/files/rhino.png", encoding: none) +#test(data.len(), 232243) +#test(data.slice(0, count: 5), bytes((137, 80, 78, 71, 13))) +#test(str(data.slice(1, 4)), "PNG") +#test(repr(data), "bytes(232243)") + +--- +#test(str(bytes(range(0x41, 0x50))), "ABCDEFGHIJKLMNO") +#test(array(bytes("Hello")), (0x48, 0x65, 0x6C, 0x6C, 0x6F)) + +--- +// Error: 8-14 expected string, array, or bytes, found dictionary +#bytes((a: 1)) + +--- +// Error: 8-15 expected bytes or array, found string +#array("hello") diff --git a/tests/typ/compiler/string.typ b/tests/typ/compiler/string.typ index c4c1669e..4241361a 100644 --- a/tests/typ/compiler/string.typ +++ b/tests/typ/compiler/string.typ @@ -41,8 +41,7 @@ #"Hello".at(5) --- -// Error: 25-32 expected string, found dictionary -#"Hello".at(5, default: (a: 10)) +#test("Hello".at(5, default: (a: 10)), (a: 10)) --- // Test the `slice` method. |
