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" {
418418}
419419
420420test "@floatCast comptime_int and comptime_float" {
421 const result = @floatCast(f32, 1234);
422 assert(@typeOf(result) == f32);
423 assert(result == 1234.0);
424
425 const result2 = @floatCast(f32, 1234.0);
426 assert(@typeOf(result) == f32);
427 assert(result == 1234.0);
421 {
422 const result = @floatCast(f32, 1234);
423 assert(@typeOf(result) == f32);
424 assert(result == 1234.0);
425 }
426 {
427 const result = @floatCast(f32, 1234.0);
428 assert(@typeOf(result) == f32);
429 assert(result == 1234.0);
430 }
428431}
429432
430433test "comptime_int @intToFloat" {
431 const result = @intToFloat(f32, 1234);
432 assert(@typeOf(result) == f32);
433 assert(result == 1234.0);
434 {
435 const result = @intToFloat(f32, 1234);
436 assert(@typeOf(result) == f32);
437 assert(result == 1234.0);
438 }
434439}
435440
436441test "@bytesToSlice keeps pointer alignment" {