aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-31 21:05:17 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-31 21:05:17 -0700
commite74a7264ad3b221dfef0c959c1fdd6275f7c70ef (patch)
tree915b1d379b4dbe803f89d26242ba1d876229a9fa /test/run_tests.cpp
parent954afe5d9a5ae634f7db22641ebac6e755cdaba7 (diff)
downloadzig-e74a7264ad3b221dfef0c959c1fdd6275f7c70ef.tar.gz
zig-e74a7264ad3b221dfef0c959c1fdd6275f7c70ef.zip
support casting between int and float types
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 7cc8b0c565..e93145d4d0 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -1483,6 +1483,23 @@ export fn main(args: c_int, argv: &&u8) -> c_int {
return 0;
}
)SOURCE", "");
+
+
+
+ add_simple_case("casting between float and integer types", R"SOURCE(
+#link("c")
+export executable "test";
+c_import {
+ @c_include("stdio.h");
+}
+export fn main(argc: c_int, argv: &&u8) -> c_int {
+ const x : f64 = 3.25;
+ const y = i32(x);
+ const z = f64(y);
+ printf(c"%.2f\n%d\n%.2f\n", x, y, z);
+ return 0;
+}
+ )SOURCE", "3.25\n3\n3.00\n");
}