summaryrefslogtreecommitdiff
path: root/src/libcore/tests/atomic.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore/tests/atomic.rs')
-rw-r--r--src/libcore/tests/atomic.rs103
1 files changed, 0 insertions, 103 deletions
diff --git a/src/libcore/tests/atomic.rs b/src/libcore/tests/atomic.rs
deleted file mode 100644
index acbd913982c..00000000000
--- a/src/libcore/tests/atomic.rs
+++ /dev/null
@@ -1,103 +0,0 @@
-use core::sync::atomic::Ordering::SeqCst;
-use core::sync::atomic::*;
-
-#[test]
-fn bool_() {
- let a = AtomicBool::new(false);
- assert_eq!(a.compare_and_swap(false, true, SeqCst), false);
- assert_eq!(a.compare_and_swap(false, true, SeqCst), true);
-
- a.store(false, SeqCst);
- assert_eq!(a.compare_and_swap(false, true, SeqCst), false);
-}
-
-#[test]
-fn bool_and() {
- let a = AtomicBool::new(true);
- assert_eq!(a.fetch_and(false, SeqCst), true);
- assert_eq!(a.load(SeqCst), false);
-}
-
-#[test]
-fn bool_nand() {
- let a = AtomicBool::new(false);
- assert_eq!(a.fetch_nand(false, SeqCst), false);
- assert_eq!(a.load(SeqCst), true);
- assert_eq!(a.fetch_nand(false, SeqCst), true);
- assert_eq!(a.load(SeqCst), true);
- assert_eq!(a.fetch_nand(true, SeqCst), true);
- assert_eq!(a.load(SeqCst), false);
- assert_eq!(a.fetch_nand(true, SeqCst), false);
- assert_eq!(a.load(SeqCst), true);
-}
-
-#[test]
-fn uint_and() {
- let x = AtomicUsize::new(0xf731);
- assert_eq!(x.fetch_and(0x137f, SeqCst), 0xf731);
- assert_eq!(x.load(SeqCst), 0xf731 & 0x137f);
-}
-
-#[test]
-fn uint_nand() {
- let x = AtomicUsize::new(0xf731);
- assert_eq!(x.fetch_nand(0x137f, SeqCst), 0xf731);
- assert_eq!(x.load(SeqCst), !(0xf731 & 0x137f));
-}
-
-#[test]
-fn uint_or() {
- let x = AtomicUsize::new(0xf731);
- assert_eq!(x.fetch_or(0x137f, SeqCst), 0xf731);
- assert_eq!(x.load(SeqCst), 0xf731 | 0x137f);
-}
-
-#[test]
-fn uint_xor() {
- let x = AtomicUsize::new(0xf731);
- assert_eq!(x.fetch_xor(0x137f, SeqCst), 0xf731);
- assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
-}
-
-#[test]
-fn int_and() {
- let x = AtomicIsize::new(0xf731);
- assert_eq!(x.fetch_and(0x137f, SeqCst), 0xf731);
- assert_eq!(x.load(SeqCst), 0xf731 & 0x137f);
-}
-
-#[test]
-fn int_nand() {
- let x = AtomicIsize::new(0xf731);
- assert_eq!(x.fetch_nand(0x137f, SeqCst), 0xf731);
- assert_eq!(x.load(SeqCst), !(0xf731 & 0x137f));
-}
-
-#[test]
-fn int_or() {
- let x = AtomicIsize::new(0xf731);
- assert_eq!(x.fetch_or(0x137f, SeqCst), 0xf731);
- assert_eq!(x.load(SeqCst), 0xf731 | 0x137f);
-}
-
-#[test]
-fn int_xor() {
- let x = AtomicIsize::new(0xf731);
- assert_eq!(x.fetch_xor(0x137f, SeqCst), 0xf731);
- assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
-}
-
-static S_FALSE: AtomicBool = AtomicBool::new(false);
-static S_TRUE: AtomicBool = AtomicBool::new(true);
-static S_INT: AtomicIsize = AtomicIsize::new(0);
-static S_UINT: AtomicUsize = AtomicUsize::new(0);
-
-#[test]
-fn static_init() {
- // Note that we're not really testing the mutability here but it's important
- // on Android at the moment (#49775)
- assert!(!S_FALSE.swap(true, SeqCst));
- assert!(S_TRUE.swap(false, SeqCst));
- assert!(S_INT.fetch_add(1, SeqCst) == 0);
- assert!(S_UINT.fetch_add(1, SeqCst) == 0);
-}