commit 0ebc7b66e6fe721d84f169ae714bbff7e82aa738 (tree)
parent 4de60dde6ed734acbc428887866ae3d528abbd37
Author: Ben Noordhuis <info@bnoordhuis.nl>
Date: Wed, 27 Jun 2018 16:20:04 +0200
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.
Diffstat:
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git 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" {