//! returns: 0 //! Test integer casting: zero-extension, sign-extension, truncation. fn zeroExtension() -> bool { let x: u8 = 9; let mut y: i32 = 42424242; set y = x as i32; let z: u8 = y as u8; return y == 9 and z == 9; } fn casting() -> bool { let x: u8 = 5; let y: i16 = 10; let mut z: i32 = y as i32; set z = 11 as i32 + z; return ((x as i32) + z) == 26; } fn signedCasting() -> bool { let x: i8 = -5; let y: i32 = x as i32; let z: i8 = y as i8; return y == -5 and z == -5; } fn unsignedToSigned() -> bool { let x: u8 = 250; let y: i32 = x as i32; let z: u8 = y as u8; return y == 250 and z == 250; } fn signed16bitCasting() -> bool { let x: i16 = -1000; let y: i32 = x as i32; let z: i16 = y as i16; return y == -1000 and z == -1000; } fn maxU8Casting() -> bool { let x: u8 = 255; let y: i32 = x as i32; let z: u8 = y as u8; return y == 255 and z == 255; } fn truncationTest() -> bool { let x: i32 = 1000; let y: u8 = x as u8; let z: i32 = y as i32; return y == 232 and z == 232; } fn sameSizeCasting() -> bool { let x: u32 = 2147483648; let y: i32 = x as i32; let z: u32 = y as u32; return y == -2147483648 and z == 2147483648; } @default fn main() -> i32 { assert casting(); assert zeroExtension(); assert signedCasting(); assert unsignedToSigned(); assert signed16bitCasting(); assert maxU8Casting(); assert truncationTest(); assert sameSizeCasting(); return 0; }