//# run // Casting to u8. main() { label b0: // 0 remains unchanged. assert(to_u8(0u8) == 0u8, 1000); assert(to_u8(0u64) == 0u8, 1001); assert(to_u8(0u128) == 0u8, 1002); // Random small number unchanged. assert(to_u8(21u8) == 21u8, 1100); assert(to_u8(21u64) == 21u8, 1101); assert(to_u8(21u128) == 21u8, 1102); // Max representable values remain unchanged. assert(to_u8(255u8) == 255u8, 1200); assert(to_u8(255u64) == 255u8, 1201); assert(to_u8(255u128) == 255u8, 1202); return; } // check: "Keep(EXECUTED)" // Casting to u64. //# run main() { label b0: // 0 remains unchanged. assert(to_u64(0u8) == 0u64, 2000); assert(to_u64(0u64) == 0u64, 2001); assert(to_u64(0u128) == 0u64, 2002); // Random small number unchanged. assert(to_u64(21u8) == 21u64, 2100); assert(to_u64(21u64) == 21u64, 2101); assert(to_u64(21u128) == 21u64, 2102); // Max representable values remain unchanged. assert(to_u64(255u8) == 255u64, 2200); assert(to_u64(18446744073709551615u64) == 18446744073709551615u64, 2201); assert(to_u64(18446744073709551615u128) == 18446744073709551615u64, 2202); return; } // check: "Keep(EXECUTED)" // Casting to u128. //# run main() { label b0: // 0 remains unchanged. assert(to_u128(0u8) == 0u128, 3000); assert(to_u128(0u64) == 0u128, 3001); assert(to_u128(0u128) == 0u128, 3002); // Random small number unchanged. assert(to_u128(21u8) == 21u128, 3100); assert(to_u128(21u64) == 21u128, 3101); assert(to_u128(21u128) == 21u128, 3102); // Max representable values remain unchanged. assert(to_u128(255u8) == 255u128, 3200); assert(to_u128(18446744073709551615u64) == 18446744073709551615u128, 3201); assert(to_u128(340282366920938463463374607431768211455u128) == 340282366920938463463374607431768211455u128, 3202); return; } // check: "Keep(EXECUTED)" // Casting to u8, overflowing. //# run main() { label b0: _ = to_u8(256u64); return; } // check: ARITHMETIC_ERROR //# run main() { label b0: _ = to_u8(303u64); return; } // check: ARITHMETIC_ERROR //# run main() { label b0: _ = to_u8(256u128); return; } // check: ARITHMETIC_ERROR //# run main() { label b0: _ = to_u8(56432u128); return; } // check: ARITHMETIC_ERROR //# run main() { label b0: _ = to_u8(18446744073709551615u64); return; } // check: ARITHMETIC_ERROR //# run main() { label b0: _ = to_u8(340282366920938463463374607431768211455u128); return; } // check: ARITHMETIC_ERROR // Casting to u64, overflowing. //# run main() { label b0: _ = to_u64(18446744073709551616u128); return; } // check: ARITHMETIC_ERROR //# run main() { label b0: _ = to_u64(18446744073709551647u128); return; } // check: ARITHMETIC_ERROR //# run main() { label b0: _ = to_u64(340282366920938463463374607431768211455u128); return; } // check: ARITHMETIC_ERROR