diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-08-04 15:09:01 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-08-04 15:46:46 +0200 |
| commit | b8b0137504d388efbe2d1ba5082c0dcabcd8bc8a (patch) | |
| tree | 825abab07230c702bca8efee026d9b98ecfa2aae /tests/typ/compiler/bytes.typ | |
| parent | 028d2f53085022c39945b1a99c9dc78eb8069d4a (diff) | |
Bytes type
- Moves `Bytes` from `util` to `eval` module
- Accepts bytes in `str` function for bytes -> str conversion
- Adds `bytes` function for str | array -> bytes conversion
- Adds `array` function for bytes -> array conversion
- Adds `len`, `at`, and `slice` methods for bytes
- Adds `encoding` parameter to `read` function
Diffstat (limited to 'tests/typ/compiler/bytes.typ')
| -rw-r--r-- | tests/typ/compiler/bytes.typ | 21 |
1 files changed, 21 insertions, 0 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") |
