authorgravatar for info@bnoordhuis.nlBen Noordhuis <info@bnoordhuis.nl> 2018-06-27 16:20:04+02:00
committergravatar for info@bnoordhuis.nlBen Noordhuis <info@bnoordhuis.nl> 2018-06-27 16:20:04+02:00
log0ebc7b66e6fe721d84f169ae714bbff7e82aa738
tree6ffe389a580b88edc69ec22990ad9e9c58a45bdf
parent4de60dde6ed734acbc428887866ae3d528abbd37

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 files changed, 15 insertions(+), 10 deletions(-)

test/cases/cast.zig+15-10
...@@ -418,19 +418,24 @@ test "@intCast comptime_int" {...@@ -418,19 +418,24 @@ test "@intCast comptime_int" {
418}418}
419419
420test "@floatCast comptime_int and comptime_float" {420test "@floatCast comptime_int and comptime_float" {
421 const result = @floatCast(f32, 1234);421 {
422 assert(@typeOf(result) == f32);422 const result = @floatCast(f32, 1234);
423 assert(result == 1234.0);423 assert(@typeOf(result) == f32);
424424 assert(result == 1234.0);
425 const result2 = @floatCast(f32, 1234.0);425 }
426 assert(@typeOf(result) == f32);426 {
427 assert(result == 1234.0);427 const result = @floatCast(f32, 1234.0);
428 assert(@typeOf(result) == f32);
429 assert(result == 1234.0);
430 }
428}431}
429432
430test "comptime_int @intToFloat" {433test "comptime_int @intToFloat" {
431 const result = @intToFloat(f32, 1234);434 {
432 assert(@typeOf(result) == f32);435 const result = @intToFloat(f32, 1234);
433 assert(result == 1234.0);436 assert(@typeOf(result) == f32);
437 assert(result == 1234.0);
438 }
434}439}
435440
436test "@bytesToSlice keeps pointer alignment" {441test "@bytesToSlice keeps pointer alignment" {