From 0ebc7b66e6fe721d84f169ae714bbff7e82aa738 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 27 Jun 2018 16:20:04 +0200 Subject: [PATCH] scope variables in floating point cast tests Fixes a bug where the result of a @floatCast wasn't actually checked; it was checking the result from the previous @floatCast. --- test/cases/cast.zig | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/test/cases/cast.zig b/test/cases/cast.zig index 7b36bcd04..4209d87c1 100644 --- a/test/cases/cast.zig +++ b/test/cases/cast.zig @@ -418,19 +418,24 @@ test "@intCast comptime_int" { } test "@floatCast comptime_int and comptime_float" { - const result = @floatCast(f32, 1234); - assert(@typeOf(result) == f32); - assert(result == 1234.0); - - const result2 = @floatCast(f32, 1234.0); - assert(@typeOf(result) == f32); - assert(result == 1234.0); + { + const result = @floatCast(f32, 1234); + assert(@typeOf(result) == f32); + assert(result == 1234.0); + } + { + const result = @floatCast(f32, 1234.0); + assert(@typeOf(result) == f32); + assert(result == 1234.0); + } } test "comptime_int @intToFloat" { - const result = @intToFloat(f32, 1234); - assert(@typeOf(result) == f32); - assert(result == 1234.0); + { + const result = @intToFloat(f32, 1234); + assert(@typeOf(result) == f32); + assert(result == 1234.0); + } } test "@bytesToSlice keeps pointer alignment" {