Commit 3c12ba7180

Andrew Kelley <superjoe30@gmail.com>
2018-06-17 10:32:57
update test cases
1 parent 7912061
test/compare_output.zig
@@ -331,8 +331,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
         \\    }
         \\    const small: f32 = 3.25;
         \\    const x: f64 = small;
-        \\    const y = i32(x);
-        \\    const z = f64(y);
+        \\    const y = @floatToInt(i32, x);
+        \\    const z = @intToFloat(f64, y);
         \\    _ = c.printf(c"%.2f\n%d\n%.2f\n%.2f\n", x, y, z, f64(-0.4));
         \\    return 0;
         \\}
test/compile_errors.zig
@@ -2931,10 +2931,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
         "cast negative value to unsigned integer",
         \\comptime {
         \\    const value: i32 = -1;
-        \\    const unsigned = u32(value);
+        \\    const unsigned = @intCast(u32, value);
         \\}
     ,
-        ".tmp_source.zig:3:25: error: attempt to cast negative value to unsigned integer",
+        ".tmp_source.zig:3:22: error: attempt to cast negative value to unsigned integer",
     );
 
     cases.add(
@@ -2963,10 +2963,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
         "compile-time integer cast truncates bits",
         \\comptime {
         \\    const spartan_count: u16 = 300;
-        \\    const byte = u8(spartan_count);
+        \\    const byte = @intCast(u8, spartan_count);
         \\}
     ,
-        ".tmp_source.zig:3:20: error: cast from 'u16' to 'u8' truncates bits",
+        ".tmp_source.zig:3:18: error: cast from 'u16' to 'u8' truncates bits",
     );
 
     cases.add(
test/runtime_safety.zig
@@ -188,7 +188,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
         \\    if (x == 0) return error.Whatever;
         \\}
         \\fn shorten_cast(x: i32) i8 {
-        \\    return i8(x);
+        \\    return @intCast(i8, x);
         \\}
     );
 
@@ -201,7 +201,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
         \\    if (x == 0) return error.Whatever;
         \\}
         \\fn unsigned_cast(x: i32) u32 {
-        \\    return u32(x);
+        \\    return @intCast(u32, x);
         \\}
     );