Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #115 from 9rnsr/fix_cas_test
Browse files Browse the repository at this point in the history
Use `is` instead of `==` for CAS test
  • Loading branch information
complexmath committed Jan 6, 2012
2 parents 4b2ec04 + b50e4f2 commit cf40272
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/core/atomic.d
Expand Up @@ -1038,30 +1038,28 @@ version( unittest )
{
T base;
shared(T) atom;
static if (is(T : real))
base = atom = cast(T) 0;

assert( base != val, T.stringof );
assert( atom == base, T.stringof );
assert( base !is val, T.stringof );
assert( atom is base, T.stringof );

cas( &atom, base, val ) || assert( 0, T.stringof );
assert( atom == val, T.stringof );
!cas( &atom, base, base ) || assert( 0, T.stringof );
assert( atom == val, T.stringof );
assert( cas( &atom, base, val ), T.stringof );
assert( atom is val, T.stringof );
assert( !cas( &atom, base, base ), T.stringof );
assert( atom is val, T.stringof );
}

void testLoadStore(msync ms = msync.seq, T)( T val = T.init + 1 )
{
T base = cast(T) 0;
shared(T) atom = cast(T) 0;

assert( base != val );
assert( atom == base );
assert( base !is val );
assert( atom is base );
atomicStore!(ms)( atom, val );
base = atomicLoad!(ms)( atom );

assert( base == val, T.stringof );
assert( atom == val );
assert( base is val, T.stringof );
assert( atom is val );
}


Expand Down

0 comments on commit cf40272

Please sign in to comment.