commit 1c1d9d41bd4768c440c269fc907019f2a6c11c11 parent 698eed8deb0ab97e7edb83e7dfb28a81fb1b9872 Author: Drew DeVault <sir@cmpwn.com> Date: Sat, 16 Jan 2021 13:08:31 -0500 tests/13-tagged: add test for cast from tagged Diffstat:
M | tests/13-tagged.ha | | | 12 | ++++++++++-- |
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tests/13-tagged.ha b/tests/13-tagged.ha @@ -66,8 +66,16 @@ fn reduction() void = { }; fn casts() void = { - let a: (i8 | i16) = 42i16; - assert(a as i16 == 42i16); + let a: (u8 | u16) = 42u16; + assert(a as u16 == 42u16); + let x = a: u8; + assert(x == 42u8); + + let val: u16 = 0xBEEFu16; + const is_little = (&val: *[2]u8)[0] == 0xEFu8; + a = 0xCAFEu16; + x = a: u8; + assert(x == (if (is_little) 0xFEu8 else 0xCAu8)); }; export fn main() void = {