]> git.lizzy.rs Git - rust.git/commitdiff
test panics in threads
authorRalf Jung <post@ralfj.de>
Sun, 3 May 2020 10:25:07 +0000 (12:25 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 3 May 2020 10:43:38 +0000 (12:43 +0200)
tests/run-pass/concurrency/simple.rs
tests/run-pass/concurrency/simple.stderr

index ad47bb144b58db6b9cd50e124ce7b2283b7d2757..a06581349057986280dbb280bc433b874b9b1b70 100644 (file)
@@ -49,6 +49,16 @@ fn create_move_out() {
     assert_eq!(result.len(), 6);
 }
 
+fn panic() {
+    let result = thread::spawn(|| {
+        panic!("Hello!")
+    })
+    .join()
+    .unwrap_err();
+    let msg = result.downcast_ref::<&'static str>().unwrap();
+    assert_eq!(*msg, "Hello!");
+}
+
 fn main() {
     create_and_detach();
     create_and_join();
@@ -58,4 +68,5 @@ fn main() {
     create_nested_and_join();
     create_move_in();
     create_move_out();
+    panic();
 }
index 2dbfb7721d3683fb4d82c2ce771e3784be86fdc9..dff33c6531c4cd571408aa0abf89372d7a1e8ff5 100644 (file)
@@ -1,2 +1,3 @@
 warning: thread support is experimental. For example, Miri does not detect data races yet.
 
+thread '<unnamed>' panicked at 'Hello!', $DIR/simple.rs:54:9