Commit 0ebc7b66e6

Ben Noordhuis <info@bnoordhuis.nl>
2018-06-27 16:20:04
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.
1 parent 4de60dd
Changed files (1)
test
cases
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" {