diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_big6.rs b/tests/compile-fail/intrinsics/float_to_int_64_too_big6.rs new file mode 100644 index 00000000000..f008131a6e5 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_big6.rs @@ -0,0 +1,10 @@ +#![feature(intrinsics)] + +// Directly call intrinsic to avoid debug assertions in libstd +extern "rust-intrinsic" { + fn float_to_int_unchecked(value: Float) -> Int; +} + +fn main() { + unsafe { float_to_int_unchecked::(f64::MAX); } //~ ERROR: cannot be represented in target type `u128` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_big7.rs b/tests/compile-fail/intrinsics/float_to_int_64_too_big7.rs new file mode 100644 index 00000000000..69922e60a6b --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_big7.rs @@ -0,0 +1,10 @@ +#![feature(intrinsics)] + +// Directly call intrinsic to avoid debug assertions in libstd +extern "rust-intrinsic" { + fn float_to_int_unchecked(value: Float) -> Int; +} + +fn main() { + unsafe { float_to_int_unchecked::(f64::MIN); } //~ ERROR: cannot be represented in target type `i128` +} diff --git a/tests/run-pass/float.rs b/tests/run-pass/float.rs index c56d12a0c00..fc513ead8dd 100644 --- a/tests/run-pass/float.rs +++ b/tests/run-pass/float.rs @@ -114,6 +114,8 @@ fn basic() { assert_eq(y, 42.0_f32); } +/// Many of these test values are taken from +/// https://github.com/WebAssembly/testsuite/blob/master/conversions.wast. fn casts() { // f32 -> i8 test_both_cast::(127.99, 127);