diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-11-02 11:04:49 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-11-02 11:05:00 +0800 |
commit | 8b53b38f40625ab0510f541d69db3f83332a830a (patch) | |
tree | dbf4627b0416e73b259dfa81bca405484f874fa8 /samples/test/thread_drop.rs | |
parent | b60a84ffbb31809bed57664dc0e8a90d632213ad (diff) | |
download | mrust-8b53b38f40625ab0510f541d69db3f83332a830a.tar.gz |
Tests - add some random tests lying about
Diffstat (limited to 'samples/test/thread_drop.rs')
-rw-r--r-- | samples/test/thread_drop.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/samples/test/thread_drop.rs b/samples/test/thread_drop.rs new file mode 100644 index 00000000..ae2e6be4 --- /dev/null +++ b/samples/test/thread_drop.rs @@ -0,0 +1,17 @@ + +use std::sync::Arc; +use std::sync::atomic::{Ordering, AtomicBool}; + +fn main() { + struct Foo(Arc<AtomicBool>); + impl Drop for Foo { + fn drop(&mut self) { + self.0.store(true, Ordering::SeqCst); + } + } + let h = Arc::new(AtomicBool::new(false)); + let h2 = Foo(h.clone()); + let th = ::std::thread::spawn(move || { let _ = h2; }); + th.join().unwrap(); + assert!(h.load(Ordering::SeqCst), "Foo's Drop impl was never called"); +} |