ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/AtomicIntegerTest.java
(Generate patch)

Comparing jsr166/src/test/tck/AtomicIntegerTest.java (file contents):
Revision 1.23 by jsr166, Fri Jun 10 20:01:21 2011 UTC vs.
Revision 1.33 by dl, Tue Jan 26 13:33:05 2021 UTC

# Line 6 | Line 6
6   * Pat Fisher, Mike Judd.
7   */
8  
9 import junit.framework.*;
9   import java.util.concurrent.atomic.AtomicInteger;
10  
11 + import junit.framework.Test;
12 + import junit.framework.TestSuite;
13 +
14   public class AtomicIntegerTest extends JSR166TestCase {
15      public static void main(String[] args) {
16 <        junit.textui.TestRunner.run(suite());
16 >        main(suite(), args);
17      }
18      public static Test suite() {
19          return new TestSuite(AtomicIntegerTest.class);
# Line 91 | Line 93 | public class AtomicIntegerTest extends J
93          assertTrue(ai.compareAndSet(1, 2));
94          t.join(LONG_DELAY_MS);
95          assertFalse(t.isAlive());
96 <        assertEquals(ai.get(), 3);
96 >        assertEquals(3, ai.get());
97      }
98  
99      /**
100       * repeated weakCompareAndSet succeeds in changing value when equal
101       * to expected
102       */
103 +    @SuppressWarnings("deprecation")
104      public void testWeakCompareAndSet() {
105          AtomicInteger ai = new AtomicInteger(1);
106 <        while (!ai.weakCompareAndSet(1, 2));
107 <        while (!ai.weakCompareAndSet(2, -4));
106 >        do {} while (!ai.weakCompareAndSet(1, 2));
107 >        do {} while (!ai.weakCompareAndSet(2, -4));
108          assertEquals(-4, ai.get());
109 <        while (!ai.weakCompareAndSet(-4, 7));
109 >        do {} while (!ai.weakCompareAndSet(-4, 7));
110          assertEquals(7, ai.get());
111      }
112  
# Line 189 | Line 192 | public class AtomicIntegerTest extends J
192      }
193  
194      /**
195 <     * a deserialized serialized atomic holds same value
195 >     * a deserialized/reserialized atomic holds same value
196       */
197      public void testSerialization() throws Exception {
198          AtomicInteger x = new AtomicInteger();
199          AtomicInteger y = serialClone(x);
200 <        assertTrue(x != y);
200 >        assertNotSame(x, y);
201          x.set(22);
202          AtomicInteger z = serialClone(x);
203          assertEquals(22, x.get());
# Line 210 | Line 213 | public class AtomicIntegerTest extends J
213          assertEquals("0", ai.toString());
214          for (int x : VALUES) {
215              ai.set(x);
216 <            assertEquals(ai.toString(), Integer.toString(x));
216 >            assertEquals(Integer.toString(x), ai.toString());
217          }
218      }
219  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines