Skip to content

Commit 3bcf9eb

Browse files
committed
fix and expand panic tests
1 parent 2479032 commit 3bcf9eb

27 files changed

+47
-18
lines changed

tests/compile-fail/div-by-zero-2.rs

-5
This file was deleted.

tests/compile-fail/overflowing-lsh-neg.rs

-6
This file was deleted.

tests/compile-fail/overflowing-rsh-1.rs

-5
This file was deleted.
File renamed without changes.

tests/run-pass/panic/div-by-zero-2.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// ignore-windows: Unwind panicking does not currently work on Windows
2+
#![allow(const_err)]
3+
4+
fn main() {
5+
let _n = 1 / 0;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
thread 'main' panicked at 'attempt to divide by zero', $DIR/div-by-zero-2.rs:5:14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// ignore-windows: Unwind panicking does not currently work on Windows
2+
#![allow(exceeding_bitshifts)]
3+
#![allow(const_err)]
4+
5+
fn main() {
6+
let _n = 2i64 << -1;
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
thread 'main' panicked at 'attempt to shift left with overflow', $DIR/overflowing-lsh-neg.rs:6:14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// ignore-windows: Unwind panicking does not currently work on Windows
2+
#![allow(exceeding_bitshifts, const_err)]
3+
4+
fn main() {
5+
let _n = 1i64 >> 64;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-1.rs:5:14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
// ignore-windows: Unwind panicking does not currently work on Windows
12
#![allow(exceeding_bitshifts, const_err)]
23

34
fn main() {
45
// Make sure we catch overflows that would be hidden by first casting the RHS to u32
5-
let _n = 1i64 >> (u32::max_value() as i64 + 1); //~ ERROR attempt to shift right with overflow
6+
let _n = 1i64 >> (u32::max_value() as i64 + 1);
67
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-2.rs:6:14

tests/run-pass/panic/panic1.rs

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

tests/run-pass/panic/panic1.stderr

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

tests/run-pass/panic/panic2.rs

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

tests/run-pass/panic/panic2.stderr

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

tests/run-pass/panic/panic3.rs

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

tests/run-pass/panic/panic3.stderr

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

tests/run-pass/panic/panic4.rs

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

tests/run-pass/panic/panic4.stderr

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

tests/compile-fail/transmute_fat2.rs renamed to tests/run-pass/panic/transmute_fat2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ fn main() {
77
let bad = unsafe {
88
std::mem::transmute::<u64, &[u8]>(42)
99
};
10-
bad[0]; //~ ERROR index out of bounds: the len is 0 but the index is 0
10+
bad[0];
1111
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', $DIR/transmute_fat2.rs:10:5

0 commit comments

Comments
 (0)