xref: /wasmtime-44.0.1/tests/all/store.rs (revision 7a1b7cdf)
1 use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
2 use wasmtime::{Engine, Store};
3 
4 #[test]
into_inner()5 fn into_inner() {
6     static HITS: AtomicUsize = AtomicUsize::new(0);
7 
8     struct A;
9 
10     impl Drop for A {
11         fn drop(&mut self) {
12             HITS.fetch_add(1, SeqCst);
13         }
14     }
15 
16     let engine = Engine::default();
17     assert_eq!(HITS.load(SeqCst), 0);
18     drop(Store::new(&engine, A));
19     assert_eq!(HITS.load(SeqCst), 1);
20     Store::new(&engine, A).into_data();
21     assert_eq!(HITS.load(SeqCst), 2);
22 }
23