--- jsr166/src/test/tck/AtomicReferenceTest.java 2003/09/25 11:02:41 1.5 +++ jsr166/src/test/tck/AtomicReferenceTest.java 2005/05/25 14:27:37 1.8 @@ -1,8 +1,9 @@ /* - * Written by members of JCP JSR-166 Expert Group and released to the - * public domain. Use, modify, and redistribute this code in any way - * without acknowledgement. Other contributors include Andrew Wright, - * Jeffrey Hayes, Pat Fischer, Mike Judd. + * 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. */ import junit.framework.*; @@ -43,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 */ @@ -126,5 +139,15 @@ public class AtomicReferenceTest extends } } + /** + * toString returns current value. + */ + public void testToString() { + AtomicReference ai = new AtomicReference(one); + assertEquals(ai.toString(), one.toString()); + ai.set(two); + assertEquals(ai.toString(), two.toString()); + } + }