Skip to content

Commit

Permalink
Add AtomicBool unit test and fix typo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Apprentice-Alchemist committed Oct 16, 2022
1 parent 00e5047 commit 70ffa78
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion std/java/_std/haxe/atomic/AtomicBool.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract AtomicBool(AtomicBoolean) {
}

public inline function exchange(value:Bool):Bool {
return this.getAndSet(Bool);
return this.getAndSet(value);
}

public inline function load():Bool {
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/src/unitstd/haxe/atomic/AtomicBool.unit.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#if (target.atomics)
var a = new haxe.atomic.AtomicBool(true);

a.load() == true;
a.store(false) == false;
a.load() == false;

a.compareExchange(false, true) == false;
a.load() == true;

a.compareExchange(false, false) == true;
a.load() == true;

a.exchange(true) == true;
a.load() == true;
#else
0 == 0; // prevent "no assertions" warning
#end

0 comments on commit 70ffa78

Please sign in to comment.