]> git.lizzy.rs Git - rust.git/commitdiff
Add test that exercises ReentrantMutex
authorDavid Cook <divergentdave@gmail.com>
Fri, 21 Feb 2020 04:19:51 +0000 (22:19 -0600)
committerDavid Cook <divergentdave@gmail.com>
Sun, 5 Apr 2020 15:04:33 +0000 (10:04 -0500)
tests/run-pass/reentrant-println.rs [new file with mode: 0644]
tests/run-pass/reentrant-println.stdout [new file with mode: 0644]

diff --git a/tests/run-pass/reentrant-println.rs b/tests/run-pass/reentrant-println.rs
new file mode 100644 (file)
index 0000000..3703d21
--- /dev/null
@@ -0,0 +1,17 @@
+use std::fmt::{Display, Error, Formatter};
+
+// This test case exercises std::sys_common::remutex::ReentrantMutex
+// by calling println!() from inside fmt
+
+struct InterruptingCow();
+
+impl Display for InterruptingCow {
+    fn fmt(&self, _f: &mut Formatter<'_>) -> Result<(), Error> {
+        println!("Moo");
+        Ok(())
+    }
+}
+
+fn main() {
+    println!("\"Knock knock\" \"Who's {} there?\"", InterruptingCow());
+}
diff --git a/tests/run-pass/reentrant-println.stdout b/tests/run-pass/reentrant-println.stdout
new file mode 100644 (file)
index 0000000..8a57d32
--- /dev/null
@@ -0,0 +1,2 @@
+"Knock knock" "Who's Moo
+ there?"