aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-31 21:22:05 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-31 21:22:05 -0700
commita4e19f94f10445273b977e21e721d236a37c5cf4 (patch)
tree842e06c40599c418b67553dfa6859c3dfcf220bc /test/run_tests.cpp
parente74a7264ad3b221dfef0c959c1fdd6275f7c70ef (diff)
downloadzig-a4e19f94f10445273b977e21e721d236a37c5cf4.tar.gz
zig-a4e19f94f10445273b977e21e721d236a37c5cf4.zip
support casting between floats
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index e93145d4d0..39cecb72d5 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -1493,7 +1493,8 @@ c_import {
@c_include("stdio.h");
}
export fn main(argc: c_int, argv: &&u8) -> c_int {
- const x : f64 = 3.25;
+ const small: f32 = 3.25;
+ const x: f64 = small;
const y = i32(x);
const z = f64(y);
printf(c"%.2f\n%d\n%.2f\n", x, y, z);
@@ -1945,6 +1946,12 @@ pub fn a(x: i32) -> i32 {x + 0}
pub fn b(x: i32) -> i32 {x + 1}
export fn c(x: i32) -> i32 {x + 2}
)SOURCE", 1, ".tmp_source.zig:2:37: error: expected type 'fn(i32) -> i32', got 'extern fn(i32) -> i32'");
+
+
+ add_compile_fail_case("implicit cast from f64 to f32", R"SOURCE(
+const x : f64 = 1.0;
+const y : f32 = x;
+ )SOURCE", 1, ".tmp_source.zig:3:17: error: expected type 'f32', got 'f64'");
}
//////////////////////////////////////////////////////////////////////////////