-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix libcore tests #806
Comments
Source#![feature(core_private_bignum)]
#![feature(is_sorted)]
#![feature(array_value_iter)]
use core::array::IntoIter;
use core::convert::TryFrom;
use core::iter::*;
use core::usize;
use core::time::Duration;
use core::num::bignum::tests::Big8x3 as Big;
#[test]
fn iterator_len() {
IntoIter::new([] as [String; 0]);
}
#[test]
fn test_iterator_step_by_nth_overflow() {
#[cfg(target_pointer_width = "32")]
type Bigger = u64;
#[cfg(target_pointer_width = "64")]
type Bigger = u128;
#[derive(Clone)]
struct Test(Bigger);
impl Iterator for &mut Test {
type Item = i32;
fn next(&mut self) -> Option<Self::Item> { Some(21) }
fn nth(&mut self, n: usize) -> Option<Self::Item> {
self.0 += n as Bigger + 1;
Some(42)
}
}
let mut it = Test(0);
let root = usize::MAX >> (::std::mem::size_of::<usize>() * 8 / 2);
let n = root + 20;
(&mut it).step_by(n).nth(n);
assert_eq!(it.0, n as Bigger * n as Bigger);
}
#[test]
fn test_range_size_hint() {
use core::usize::MAX as UMAX;
use core::isize::{MAX as IMAX, MIN as IMIN};
let imin = i128::try_from(IMIN).unwrap();
let imax = i128::try_from(IMAX).unwrap();
assert_eq!((imin..imax + 1).size_hint(), (UMAX, None));
}
#[test]
fn test_range_inclusive_size_hint() {
use core::usize::MAX as UMAX;
use core::isize::{MAX as IMAX, MIN as IMIN};
let imin = i128::try_from(IMIN).unwrap();
let imax = i128::try_from(IMAX).unwrap();
assert_eq!((imin..=imax + 1).size_hint(), (UMAX, None));
}
#[test]
fn test_successors() {
let mut powers_of_10 = successors(Some(1_u16), |n| n.checked_mul(10));
assert_eq!(powers_of_10.by_ref().collect::<Vec<_>>(), &[1, 10, 100, 1_000, 10_000]);
assert_eq!(powers_of_10.next(), None);
let mut empty = successors(None::<u32>, |_| unimplemented!());
assert_eq!(empty.next(), None);
assert_eq!(empty.next(), None);
}
#[test]
fn test_is_sorted() {
let empty: [i32; 0] = [];
assert!(empty.is_sorted());
}
#[test]
fn checked_mul() {
assert_eq!(Duration::new(::core::u64::MAX - 1, 0).checked_mul(2), None);
}
#[test]
fn from_str_issue7588() {
let u : Option<u8> = u8::from_str_radix("1000", 10).ok();
assert_eq!(u, None);
}
macro_rules! test_float {
($modname: ident, $fty: ty, $inf: expr, $neginf: expr, $nan: expr) => { mod $modname {
// FIXME(nagisa): these tests should test for sign of -0.0
#[test]
fn min() {
assert_eq!((0.0 as $fty).min(0.0), 0.0);
assert_eq!((-0.0 as $fty).min(-0.0), -0.0);
assert_eq!((9.0 as $fty).min(9.0), 9.0);
assert_eq!((-9.0 as $fty).min(0.0), -9.0);
assert_eq!((0.0 as $fty).min(9.0), 0.0);
assert_eq!((-0.0 as $fty).min(-9.0), -9.0);
assert_eq!(($inf as $fty).min(9.0), 9.0);
assert_eq!((9.0 as $fty).min($inf), 9.0);
assert_eq!(($inf as $fty).min(-9.0), -9.0);
assert_eq!((-9.0 as $fty).min($inf), -9.0);
assert_eq!(($neginf as $fty).min(9.0), $neginf);
assert_eq!((9.0 as $fty).min($neginf), $neginf);
assert_eq!(($neginf as $fty).min(-9.0), $neginf);
assert_eq!((-9.0 as $fty).min($neginf), $neginf);
assert_eq!(($nan as $fty).min(9.0), 9.0);
assert_eq!(($nan as $fty).min(-9.0), -9.0);
assert_eq!((9.0 as $fty).min($nan), 9.0);
assert_eq!((-9.0 as $fty).min($nan), -9.0);
assert!(($nan as $fty).min($nan).is_nan());
}
#[test]
fn max() {
assert_eq!((0.0 as $fty).max(0.0), 0.0);
assert_eq!((-0.0 as $fty).max(-0.0), -0.0);
assert_eq!((9.0 as $fty).max(9.0), 9.0);
assert_eq!((-9.0 as $fty).max(0.0), 0.0);
assert_eq!((0.0 as $fty).max(9.0), 9.0);
assert_eq!((-0.0 as $fty).max(-9.0), -0.0);
assert_eq!(($inf as $fty).max(9.0), $inf);
assert_eq!((9.0 as $fty).max($inf), $inf);
assert_eq!(($inf as $fty).max(-9.0), $inf);
assert_eq!((-9.0 as $fty).max($inf), $inf);
assert_eq!(($neginf as $fty).max(9.0), 9.0);
assert_eq!((9.0 as $fty).max($neginf), 9.0);
assert_eq!(($neginf as $fty).max(-9.0), -9.0);
assert_eq!((-9.0 as $fty).max($neginf), -9.0);
assert_eq!(($nan as $fty).max(9.0), 9.0);
assert_eq!(($nan as $fty).max(-9.0), -9.0);
assert_eq!((9.0 as $fty).max($nan), 9.0);
assert_eq!((-9.0 as $fty).max($nan), -9.0);
assert!(($nan as $fty).max($nan).is_nan());
}
} }
}
test_float!(f32, f32, ::core::f32::INFINITY, ::core::f32::NEG_INFINITY, ::core::f32::NAN);
test_float!(f64, f64, ::core::f64::INFINITY, ::core::f64::NEG_INFINITY, ::core::f64::NAN); |
|
Might be worth revisiting this now that https://github.com/bjorn3/rustc_codegen_cranelift/issues/6 is fixed :) |
I actually fixed #6 as part of revisiting this :) ef4186a, 177348f, 5f54cc7 The new broken test list is:
|
Fixed the float tests. I forgot to tick the checkbox for the rotate test previously it seems. |
Enabled |
…tolnay Don't declare test_variadic_fnptr with two conflicting signatures It is UB for LLVM and results in a compile error for Cranelift. cc https://github.com/bjorn3/rustc_codegen_cranelift/issues/806 Fixes rust-lang#66690
…tolnay Don't declare test_variadic_fnptr with two conflicting signatures It is UB for LLVM and results in a compile error for Cranelift. cc https://github.com/bjorn3/rustc_codegen_cranelift/issues/806 Fixes rust-lang#66690
…lnay Don't declare test_variadic_fnptr with two conflicting signatures It is UB for LLVM and results in a compile error for Cranelift. cc https://github.com/bjorn3/rustc_codegen_cranelift/issues/806 Fixes rust-lang#66690
With the exception of an s390x failure due to stack value alignment, and the AtomicU128/AtomicI128 tests due to missing 128bit atomic support in Cranelift, everything passes now. A couple of tests are disabled due to being way too slow when not being fully optimized though. |
When removing the tests requiring
rand
and adding aCargo.toml
tosrc/libcore/tests
, runningcargo test
in that directory gives the following failures:iter::test_successors
even hangs. You have to manually kill the process executing it to be able to continue the testing.Edit: some failures were due to panic catching not being implemented. Ignoring them.
The text was updated successfully, but these errors were encountered: