Auto merge of #1351 - RalfJung:float-test-source, r=RalfJung
note source of float cast test values, and some more UB tests
This commit is contained in:
commit
4155fb610f
10
tests/compile-fail/intrinsics/float_to_int_64_too_big6.rs
Normal file
10
tests/compile-fail/intrinsics/float_to_int_64_too_big6.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#![feature(intrinsics)]
|
||||||
|
|
||||||
|
// Directly call intrinsic to avoid debug assertions in libstd
|
||||||
|
extern "rust-intrinsic" {
|
||||||
|
fn float_to_int_unchecked<Float: Copy, Int: Copy>(value: Float) -> Int;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
unsafe { float_to_int_unchecked::<f64, u128>(f64::MAX); } //~ ERROR: cannot be represented in target type `u128`
|
||||||
|
}
|
10
tests/compile-fail/intrinsics/float_to_int_64_too_big7.rs
Normal file
10
tests/compile-fail/intrinsics/float_to_int_64_too_big7.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#![feature(intrinsics)]
|
||||||
|
|
||||||
|
// Directly call intrinsic to avoid debug assertions in libstd
|
||||||
|
extern "rust-intrinsic" {
|
||||||
|
fn float_to_int_unchecked<Float: Copy, Int: Copy>(value: Float) -> Int;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
unsafe { float_to_int_unchecked::<f64, i128>(f64::MIN); } //~ ERROR: cannot be represented in target type `i128`
|
||||||
|
}
|
@ -114,6 +114,8 @@ fn basic() {
|
|||||||
assert_eq(y, 42.0_f32);
|
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() {
|
fn casts() {
|
||||||
// f32 -> i8
|
// f32 -> i8
|
||||||
test_both_cast::<f32, i8>(127.99, 127);
|
test_both_cast::<f32, i8>(127.99, 127);
|
||||||
|
Loading…
Reference in New Issue
Block a user