aboutsummaryrefslogtreecommitdiff
path: root/test/behavior
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-10-21 23:01:05 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-10-21 23:01:05 -0700
commit895aea0b630df97edbbcf68bfad251968c9b9fbf (patch)
tree8ff1152e5f318976d9835c15cc40c0ef66131243 /test/behavior
parent0a6851cc6de540ed95c3ec1c78eb3da7897bd930 (diff)
downloadzig-895aea0b630df97edbbcf68bfad251968c9b9fbf.tar.gz
zig-895aea0b630df97edbbcf68bfad251968c9b9fbf.zip
Sema: fix type checking of `@intToFloat` operands
There was a typo and they were backwards.
Diffstat (limited to 'test/behavior')
-rw-r--r--test/behavior/cast.zig29
-rw-r--r--test/behavior/cast_stage1.zig29
2 files changed, 29 insertions, 29 deletions
diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig
index c8ffa361ab..1a5b3c99d2 100644
--- a/test/behavior/cast.zig
+++ b/test/behavior/cast.zig
@@ -77,3 +77,32 @@ test "pointer reinterpret const float to int" {
else
try expect(int_val == 0x3fe33333);
}
+
+test "comptime_int @intToFloat" {
+ {
+ const result = @intToFloat(f16, 1234);
+ try expect(@TypeOf(result) == f16);
+ try expect(result == 1234.0);
+ }
+ {
+ const result = @intToFloat(f32, 1234);
+ try expect(@TypeOf(result) == f32);
+ try expect(result == 1234.0);
+ }
+ {
+ const result = @intToFloat(f64, 1234);
+ try expect(@TypeOf(result) == f64);
+ try expect(result == 1234.0);
+ }
+ {
+ const result = @intToFloat(f128, 1234);
+ try expect(@TypeOf(result) == f128);
+ try expect(result == 1234.0);
+ }
+ // big comptime_int (> 64 bits) to f128 conversion
+ {
+ const result = @intToFloat(f128, 0x1_0000_0000_0000_0000);
+ try expect(@TypeOf(result) == f128);
+ try expect(result == 0x1_0000_0000_0000_0000.0);
+ }
+}
diff --git a/test/behavior/cast_stage1.zig b/test/behavior/cast_stage1.zig
index 619fe81968..c6d3b5c430 100644
--- a/test/behavior/cast_stage1.zig
+++ b/test/behavior/cast_stage1.zig
@@ -356,35 +356,6 @@ test "vector casts" {
comptime try S.doTheTestFloat();
}
-test "comptime_int @intToFloat" {
- {
- const result = @intToFloat(f16, 1234);
- try expect(@TypeOf(result) == f16);
- try expect(result == 1234.0);
- }
- {
- const result = @intToFloat(f32, 1234);
- try expect(@TypeOf(result) == f32);
- try expect(result == 1234.0);
- }
- {
- const result = @intToFloat(f64, 1234);
- try expect(@TypeOf(result) == f64);
- try expect(result == 1234.0);
- }
- {
- const result = @intToFloat(f128, 1234);
- try expect(@TypeOf(result) == f128);
- try expect(result == 1234.0);
- }
- // big comptime_int (> 64 bits) to f128 conversion
- {
- const result = @intToFloat(f128, 0x1_0000_0000_0000_0000);
- try expect(@TypeOf(result) == f128);
- try expect(result == 0x1_0000_0000_0000_0000.0);
- }
-}
-
test "@floatCast cast down" {
{
var double: f64 = 0.001534;