Test fixes and rebase conflicts, round 2
Conflicts: src/libcore/num/mod.rs
This commit is contained in:
parent
07ff8ab885
commit
f86318d63c
@ -1088,7 +1088,7 @@ fn test_bytes_set_memory() {
|
||||
#[should_panic]
|
||||
fn test_overflow_does_not_cause_segfault() {
|
||||
let mut v = vec![];
|
||||
v.reserve_exact(-1);
|
||||
v.reserve_exact(!0);
|
||||
v.push(1);
|
||||
v.push(2);
|
||||
}
|
||||
@ -1097,7 +1097,7 @@ fn test_overflow_does_not_cause_segfault() {
|
||||
#[should_panic]
|
||||
fn test_overflow_does_not_cause_segfault_managed() {
|
||||
let mut v = vec![Rc::new(1)];
|
||||
v.reserve_exact(-1);
|
||||
v.reserve_exact(!0);
|
||||
v.push(Rc::new(2));
|
||||
}
|
||||
|
||||
|
@ -125,14 +125,14 @@ fn test_format_int_flags() {
|
||||
assert!(format!("{:>8x}", 10) == " a");
|
||||
assert!(format!("{:#08x}", 10) == "0x00000a");
|
||||
assert!(format!("{:08}", -10) == "-0000010");
|
||||
assert!(format!("{:x}", -1u8) == "ff");
|
||||
assert!(format!("{:X}", -1u8) == "FF");
|
||||
assert!(format!("{:b}", -1u8) == "11111111");
|
||||
assert!(format!("{:o}", -1u8) == "377");
|
||||
assert!(format!("{:#x}", -1u8) == "0xff");
|
||||
assert!(format!("{:#X}", -1u8) == "0xFF");
|
||||
assert!(format!("{:#b}", -1u8) == "0b11111111");
|
||||
assert!(format!("{:#o}", -1u8) == "0o377");
|
||||
assert!(format!("{:x}", !0u8) == "ff");
|
||||
assert!(format!("{:X}", !0u8) == "FF");
|
||||
assert!(format!("{:b}", !0u8) == "11111111");
|
||||
assert!(format!("{:o}", !0u8) == "377");
|
||||
assert!(format!("{:#x}", !0u8) == "0xff");
|
||||
assert!(format!("{:#X}", !0u8) == "0xFF");
|
||||
assert!(format!("{:#b}", !0u8) == "0b11111111");
|
||||
assert!(format!("{:#o}", !0u8) == "0o377");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -2865,7 +2865,7 @@ pub mod consts {
|
||||
pub const MAP_FIXED : c_int = 0x0010;
|
||||
pub const MAP_ANON : c_int = 0x0020;
|
||||
|
||||
pub const MAP_FAILED : *mut c_void = -1 as *mut c_void;
|
||||
pub const MAP_FAILED : *mut c_void = !0 as *mut c_void;
|
||||
|
||||
pub const MCL_CURRENT : c_int = 0x0001;
|
||||
pub const MCL_FUTURE : c_int = 0x0002;
|
||||
|
@ -361,7 +361,7 @@ mod tests {
|
||||
}
|
||||
#[test] #[should_panic]
|
||||
fn test_weighted_choice_weight_overflows() {
|
||||
let x = (-1) as usize / 2; // x + x + 2 is the overflow
|
||||
let x = (!0) as usize / 2; // x + x + 2 is the overflow
|
||||
WeightedChoice::new(&mut [Weighted { weight: x, item: 0 },
|
||||
Weighted { weight: 1, item: 1 },
|
||||
Weighted { weight: x, item: 2 },
|
||||
|
@ -396,7 +396,7 @@ pub fn const_int_checked_neg<'a>(
|
||||
pub fn const_uint_checked_neg<'a>(
|
||||
a: u64, _e: &'a Expr, _opt_ety: Option<UintTy>) -> EvalResult {
|
||||
// This always succeeds, and by definition, returns `(!a)+1`.
|
||||
Ok(const_uint(-a))
|
||||
Ok(const_uint((!a).wrapping_add(1)))
|
||||
}
|
||||
|
||||
macro_rules! overflow_checking_body {
|
||||
|
@ -946,7 +946,7 @@ mod tests {
|
||||
let mut read_stream = check!(File::open(filename));
|
||||
let mut read_buf = [0; 1028];
|
||||
let read_str = match check!(read_stream.read(&mut read_buf)) {
|
||||
-1|0 => panic!("shouldn't happen"),
|
||||
0 => panic!("shouldn't happen"),
|
||||
n => str::from_utf8(&read_buf[..n]).unwrap().to_string()
|
||||
};
|
||||
assert_eq!(read_str, message);
|
||||
|
@ -970,7 +970,7 @@ mod test {
|
||||
let mut read_stream = File::open_mode(filename, Open, Read);
|
||||
let mut read_buf = [0; 1028];
|
||||
let read_str = match check!(read_stream.read(&mut read_buf)) {
|
||||
-1|0 => panic!("shouldn't happen"),
|
||||
0 => panic!("shouldn't happen"),
|
||||
n => str::from_utf8(&read_buf[..n]).unwrap().to_string()
|
||||
};
|
||||
assert_eq!(read_str, message);
|
||||
|
@ -3048,7 +3048,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_signed_int_to_string() {
|
||||
let pos_int = ast::LitInt(42, ast::SignedIntLit(ast::TyI32, ast::Plus));
|
||||
let neg_int = ast::LitInt((-42) as u64, ast::SignedIntLit(ast::TyI32, ast::Minus));
|
||||
let neg_int = ast::LitInt((!42 + 1) as u64, ast::SignedIntLit(ast::TyI32, ast::Minus));
|
||||
assert_eq!(format!("-{}", lit_to_string(&codemap::dummy_spanned(pos_int))),
|
||||
lit_to_string(&codemap::dummy_spanned(neg_int)));
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#![feature(negate_unsigned)]
|
||||
|
||||
#![allow(unused_imports)]
|
||||
#![feature(negate_unsigned)]
|
||||
|
||||
// Note: the relevant lint pass here runs before some of the constant
|
||||
// evaluation below (e.g. that performed by trans and llvm), so if you
|
||||
|
@ -12,7 +12,7 @@
|
||||
#![deny(exceeding_bitshifts)]
|
||||
#![allow(unused_variables)]
|
||||
#![allow(dead_code)]
|
||||
#![feature(core)]
|
||||
#![feature(core, negate_unsigned)]
|
||||
|
||||
fn main() {
|
||||
let n = 1u8 << 7;
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#![feature(negate_unsigned)]
|
||||
#![allow(dead_code)]
|
||||
#![feature(negate_unsigned)]
|
||||
|
||||
// compile-flags: -D unused-comparisons
|
||||
fn main() { }
|
||||
|
Loading…
Reference in New Issue
Block a user