--- jsr166/src/test/tck/AtomicReferenceTest.java 2004/01/09 20:07:36 1.7 +++ jsr166/src/test/tck/AtomicReferenceTest.java 2009/11/02 20:28:31 1.9 @@ -2,8 +2,8 @@ * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. + * Other contributors include Andrew Wright, Jeffrey Hayes, + * Pat Fisher, Mike Judd. */ import junit.framework.*; @@ -44,8 +44,20 @@ public class AtomicReferenceTest extends assertEquals(two,ai.get()); ai.set(m3); assertEquals(m3,ai.get()); - } + + /** + * get returns the last value lazySet in same thread + */ + public void testGetLazySet(){ + AtomicReference ai = new AtomicReference(one); + assertEquals(one,ai.get()); + ai.lazySet(two); + assertEquals(two,ai.get()); + ai.lazySet(m3); + assertEquals(m3,ai.get()); + } + /** * compareAndSet succeeds in changing value if equal to expected else fails */ @@ -84,7 +96,7 @@ public class AtomicReferenceTest extends /** * repeated weakCompareAndSet succeeds in changing value when equal - * to expected + * to expected */ public void testWeakCompareAndSet(){ AtomicReference ai = new AtomicReference(one); @@ -129,13 +141,12 @@ public class AtomicReferenceTest extends /** * toString returns current value. - */ + */ public void testToString() { - AtomicReference ai = new AtomicReference(one); + AtomicReference ai = new AtomicReference(one); assertEquals(ai.toString(), one.toString()); ai.set(two); assertEquals(ai.toString(), two.toString()); } } -