about summary refs log tree commit diff
path: root/src/libcore/tests
diff options
context:
space:
mode:
authorStjepan Glavina <stjepang@gmail.com>2017-04-07 17:28:55 +0200
committerStjepan Glavina <stjepang@gmail.com>2017-04-07 17:36:50 +0200
commit5c5a5182c94d07409fac8cb40b2cdab488c140ff (patch)
tree26c8b3344ab5d7e448db21009d33c6e5ade7ff10 /src/libcore/tests
parent4c59c92bc4d4d6e5b2b66c4cc08dd1a058283a0d (diff)
downloadrust-5c5a5182c94d07409fac8cb40b2cdab488c140ff.tar.gz
rust-5c5a5182c94d07409fac8cb40b2cdab488c140ff.zip
Optimize AtomicBool::fetch_nand
Diffstat (limited to 'src/libcore/tests')
-rw-r--r--src/libcore/tests/atomic.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/libcore/tests/atomic.rs b/src/libcore/tests/atomic.rs
index b6bb5fddf4a..9babe24a985 100644
--- a/src/libcore/tests/atomic.rs
+++ b/src/libcore/tests/atomic.rs
@@ -24,11 +24,24 @@ fn bool_() {
 #[test]
 fn bool_and() {
     let a = AtomicBool::new(true);
-    assert_eq!(a.fetch_and(false, SeqCst),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);