Skip to content

Commit ca4969d

Browse files
committed
consolidate atomic tests
1 parent d9d6df9 commit ca4969d

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

tests/run-pass/atomic-access-bool.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/run-pass/atomic-compare_exchange.rs renamed to tests/run-pass/atomic.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
1-
use std::sync::atomic::{AtomicIsize, Ordering::*};
2-
3-
static ATOMIC: AtomicIsize = AtomicIsize::new(0);
1+
use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering::*};
42

53
fn main() {
4+
atomic_bool();
5+
atomic_isize();
6+
}
7+
8+
fn atomic_bool() {
9+
static mut ATOMIC: AtomicBool = AtomicBool::new(false);
10+
11+
unsafe {
12+
assert_eq!(*ATOMIC.get_mut(), false);
13+
ATOMIC.store(true, SeqCst);
14+
assert_eq!(*ATOMIC.get_mut(), true);
15+
ATOMIC.fetch_or(false, SeqCst);
16+
assert_eq!(*ATOMIC.get_mut(), true);
17+
ATOMIC.fetch_and(false, SeqCst);
18+
assert_eq!(*ATOMIC.get_mut(), false);
19+
ATOMIC.fetch_nand(true, SeqCst);
20+
assert_eq!(*ATOMIC.get_mut(), true);
21+
ATOMIC.fetch_xor(true, SeqCst);
22+
assert_eq!(*ATOMIC.get_mut(), false);
23+
}
24+
}
25+
26+
fn atomic_isize() {
27+
static ATOMIC: AtomicIsize = AtomicIsize::new(0);
28+
629
// Make sure trans can emit all the intrinsics correctly
730
assert_eq!(ATOMIC.compare_exchange(0, 1, Relaxed, Relaxed), Ok(0));
831
assert_eq!(ATOMIC.compare_exchange(0, 2, Acquire, Relaxed), Err(1));

0 commit comments

Comments
 (0)