diff options
| author | Vexu <git@vexu.eu> | 2020-07-09 21:25:55 +0300 |
|---|---|---|
| committer | Vexu <git@vexu.eu> | 2020-07-09 21:25:55 +0300 |
| commit | 2e1bdd0d14f490a80bbed3ee0e0479a908715d33 (patch) | |
| tree | 491a48c67d5ac87b6e776d483065a5bf80027481 /test | |
| parent | a489ea0b2f38c67025c2b2424749a9a7320cdd5a (diff) | |
| download | zig-2e1bdd0d14f490a80bbed3ee0e0479a908715d33.tar.gz zig-2e1bdd0d14f490a80bbed3ee0e0479a908715d33.zip | |
use correct cast function when doing `@floatCast` at comptime
Closes #5832
Diffstat (limited to 'test')
| -rw-r--r-- | test/stage1/behavior/cast.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/stage1/behavior/cast.zig b/test/stage1/behavior/cast.zig index 77cdacc307..4325b0b9e4 100644 --- a/test/stage1/behavior/cast.zig +++ b/test/stage1/behavior/cast.zig @@ -384,6 +384,19 @@ test "@intCast i32 to u7" { expect(z == 0xff); } +test "@floatCast cast down" { + { + var double: f64 = 0.001534; + var single = @floatCast(f32, double); + expect(@TypeOf(single) == f32); + } + { + const double: f64 = 0.001534; + const single = @floatCast(f32, double); + expect(@TypeOf(single) == f32); + } +} + test "implicit cast undefined to optional" { expect(MakeType(void).getNull() == null); expect(MakeType(void).getNonNull() != null); |
