mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 23:52:31 +00:00
19961c50e4
closes #1118
28 lines
504 B
Zig
28 lines
504 B
Zig
const std = @import("std");
|
|
const assert = std.debug.assert;
|
|
const mem = std.mem;
|
|
|
|
test "integer widening" {
|
|
var a: u8 = 250;
|
|
var b: u16 = a;
|
|
var c: u32 = b;
|
|
var d: u64 = c;
|
|
var e: u64 = d;
|
|
var f: u128 = e;
|
|
assert(f == a);
|
|
}
|
|
|
|
test "implicit unsigned integer to signed integer" {
|
|
var a: u8 = 250;
|
|
var b: i16 = a;
|
|
assert(b == 250);
|
|
}
|
|
|
|
test "float widening" {
|
|
var a: f16 = 12.34;
|
|
var b: f32 = a;
|
|
var c: f64 = b;
|
|
var d: f128 = c;
|
|
assert(d == a);
|
|
}
|