diff --git a/tests/compile-fail/intrinsics/float_to_int_32_inf1.rs b/tests/compile-fail/intrinsics/float_to_int_32_inf1.rs new file mode 100644 index 00000000000..a56f4aefad3 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_inf1.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::(f32::INFINITY); } //~ ERROR: cannot be represented in target type `i32` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_32_infneg1.rs b/tests/compile-fail/intrinsics/float_to_int_32_infneg1.rs new file mode 100644 index 00000000000..d18f75fcca8 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_infneg1.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::(f32::NEG_INFINITY); } //~ ERROR: cannot be represented in target type `i32` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_32_nan.rs b/tests/compile-fail/intrinsics/float_to_int_32_nan.rs new file mode 100644 index 00000000000..e1fe8c7cf2f --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_nan.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::(f32::NAN); } //~ ERROR: cannot be represented in target type `u32` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_32_nanneg.rs b/tests/compile-fail/intrinsics/float_to_int_32_nanneg.rs new file mode 100644 index 00000000000..38899045c92 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_nanneg.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::(-f32::NAN); } //~ ERROR: cannot be represented in target type `u32` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_32_neg.rs b/tests/compile-fail/intrinsics/float_to_int_32_neg.rs new file mode 100644 index 00000000000..f15cf9a9cd6 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_neg.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::(-1.000000001f32); } //~ ERROR: cannot be represented in target type `u32` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_32_too_big1.rs b/tests/compile-fail/intrinsics/float_to_int_32_too_big1.rs new file mode 100644 index 00000000000..ccbf917c8e8 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_too_big1.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::(2147483648.0f32); } //~ ERROR: cannot be represented in target type `i32` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_32_too_big2.rs b/tests/compile-fail/intrinsics/float_to_int_32_too_big2.rs new file mode 100644 index 00000000000..6598fd36e03 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_too_big2.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::((u32::MAX-127) as f32); } //~ ERROR: cannot be represented in target type `u32` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_32_too_small1.rs b/tests/compile-fail/intrinsics/float_to_int_32_too_small1.rs new file mode 100644 index 00000000000..89f09e1e3f1 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_too_small1.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::(-2147483904.0f32); } //~ ERROR: cannot be represented in target type `i32` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_64_inf1.rs b/tests/compile-fail/intrinsics/float_to_int_64_inf1.rs new file mode 100644 index 00000000000..e1a7b818d85 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_inf1.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::INFINITY); } //~ ERROR: cannot be represented in target type `u128` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_64_infneg1.rs b/tests/compile-fail/intrinsics/float_to_int_64_infneg1.rs new file mode 100644 index 00000000000..a1d757b1511 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_infneg1.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::NEG_INFINITY); } //~ ERROR: cannot be represented in target type `u128` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_64_infneg2.rs b/tests/compile-fail/intrinsics/float_to_int_64_infneg2.rs new file mode 100644 index 00000000000..e48d19f1a6a --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_infneg2.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::NEG_INFINITY); } //~ ERROR: cannot be represented in target type `i128` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_64_nan.rs b/tests/compile-fail/intrinsics/float_to_int_64_nan.rs new file mode 100644 index 00000000000..03f378f5bcb --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_nan.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::NAN); } //~ ERROR: cannot be represented in target type `u32` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_64_neg.rs b/tests/compile-fail/intrinsics/float_to_int_64_neg.rs new file mode 100644 index 00000000000..d0b5a3e21cf --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_neg.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::(-1.0000000000001f64); } //~ ERROR: cannot be represented in target type `u128` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_big1.rs b/tests/compile-fail/intrinsics/float_to_int_64_too_big1.rs new file mode 100644 index 00000000000..f928f161872 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_big1.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::(2147483648.0f64); } //~ ERROR: cannot be represented in target type `i32` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_big2.rs b/tests/compile-fail/intrinsics/float_to_int_64_too_big2.rs new file mode 100644 index 00000000000..feb24c362dd --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_big2.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::(9223372036854775808.0f64); } //~ ERROR: cannot be represented in target type `i64` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_big3.rs b/tests/compile-fail/intrinsics/float_to_int_64_too_big3.rs new file mode 100644 index 00000000000..cd491bfed7e --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_big3.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::(18446744073709551616.0f64); } //~ ERROR: cannot be represented in target type `u64` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_big4.rs b/tests/compile-fail/intrinsics/float_to_int_64_too_big4.rs new file mode 100644 index 00000000000..d5b24347b94 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_big4.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::(340282366920938463463374607431768211455.0f64); } //~ ERROR: cannot be represented in target type `u128` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_big5.rs b/tests/compile-fail/intrinsics/float_to_int_64_too_big5.rs new file mode 100644 index 00000000000..9c31c690b4e --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_big5.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::(240282366920938463463374607431768211455.0f64); } //~ ERROR: cannot be represented in target type `i128` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_small1.rs b/tests/compile-fail/intrinsics/float_to_int_64_too_small1.rs new file mode 100644 index 00000000000..08f2f9e3fd2 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_small1.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::(-2147483649.0f64); } //~ ERROR: cannot be represented in target type `i32` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_small2.rs b/tests/compile-fail/intrinsics/float_to_int_64_too_small2.rs new file mode 100644 index 00000000000..f7b205de534 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_small2.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::(-9223372036854777856.0f64); } //~ ERROR: cannot be represented in target type `i64` +} diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_small3.rs b/tests/compile-fail/intrinsics/float_to_int_64_too_small3.rs new file mode 100644 index 00000000000..779441f7448 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_small3.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::(-240282366920938463463374607431768211455.0f64); } //~ ERROR: cannot be represented in target type `i128` +}