fix and expand panic tests

This commit is contained in:
Ralf Jung 2019-11-29 13:18:54 +01:00
parent b2cddd27bd
commit ae53b1222a
27 changed files with 47 additions and 18 deletions

View File

@ -1,5 +0,0 @@
#![allow(const_err)]
fn main() {
let _n = 1 / 0; //~ ERROR attempt to divide by zero
}

View File

@ -1,6 +0,0 @@
#![allow(exceeding_bitshifts)]
#![allow(const_err)]
fn main() {
let _n = 2i64 << -1; //~ ERROR attempt to shift left with overflow
}

View File

@ -1,5 +0,0 @@
#![allow(exceeding_bitshifts, const_err)]
fn main() {
let _n = 1i64 >> 64; //~ ERROR attempt to shift right with overflow
}

View File

@ -0,0 +1,6 @@
// ignore-windows: Unwind panicking does not currently work on Windows
#![allow(const_err)]
fn main() {
let _n = 1 / 0;
}

View File

@ -0,0 +1 @@
thread 'main' panicked at 'attempt to divide by zero', $DIR/div-by-zero-2.rs:5:14

View File

@ -0,0 +1,7 @@
// ignore-windows: Unwind panicking does not currently work on Windows
#![allow(exceeding_bitshifts)]
#![allow(const_err)]
fn main() {
let _n = 2i64 << -1;
}

View File

@ -0,0 +1 @@
thread 'main' panicked at 'attempt to shift left with overflow', $DIR/overflowing-lsh-neg.rs:6:14

View File

@ -0,0 +1,6 @@
// ignore-windows: Unwind panicking does not currently work on Windows
#![allow(exceeding_bitshifts, const_err)]
fn main() {
let _n = 1i64 >> 64;
}

View File

@ -0,0 +1 @@
thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-1.rs:5:14

View File

@ -1,6 +1,7 @@
// ignore-windows: Unwind panicking does not currently work on Windows
#![allow(exceeding_bitshifts, const_err)]
fn main() {
// Make sure we catch overflows that would be hidden by first casting the RHS to u32
let _n = 1i64 >> (u32::max_value() as i64 + 1); //~ ERROR attempt to shift right with overflow
let _n = 1i64 >> (u32::max_value() as i64 + 1);
}

View File

@ -0,0 +1 @@
thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-2.rs:6:14

View File

@ -0,0 +1,4 @@
// ignore-windows: Unwind panicking does not currently work on Windows
fn main() {
std::panic!("panicking from libstd");
}

View File

@ -0,0 +1 @@
thread 'main' panicked at 'panicking from libstd', $DIR/panic1.rs:3:5

View File

@ -0,0 +1,4 @@
// ignore-windows: Unwind panicking does not currently work on Windows
fn main() {
std::panic!("{}-panicking from libstd", 42);
}

View File

@ -0,0 +1 @@
thread 'main' panicked at '42-panicking from libstd', $DIR/panic2.rs:3:5

View File

@ -0,0 +1,4 @@
// ignore-windows: Unwind panicking does not currently work on Windows
fn main() {
core::panic!("panicking from libcore");
}

View File

@ -0,0 +1 @@
thread 'main' panicked at 'panicking from libcore', $DIR/panic3.rs:3:5

View File

@ -0,0 +1,4 @@
// ignore-windows: Unwind panicking does not currently work on Windows
fn main() {
core::panic!("{}-panicking from libcore", 42);
}

View File

@ -0,0 +1 @@
thread 'main' panicked at '42-panicking from libcore', $DIR/panic4.rs:3:5

View File

@ -7,5 +7,5 @@ fn main() {
let bad = unsafe {
std::mem::transmute::<u64, &[u8]>(42)
};
bad[0]; //~ ERROR index out of bounds: the len is 0 but the index is 0
bad[0];
}

View File

@ -0,0 +1 @@
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', $DIR/transmute_fat2.rs:10:5