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

Comparing jsr166/src/test/tck/AtomicMarkableReferenceTest.java (file contents):
Revision 1.13 by jsr166, Tue Dec 1 09:56:28 2009 UTC vs.
Revision 1.21 by jsr166, Wed Dec 31 19:21:20 2014 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.
7   */
8  
9 < import junit.framework.*;
10 < import java.util.concurrent.atomic.*;
9 > import java.util.concurrent.atomic.AtomicMarkableReference;
10 >
11 > import junit.framework.Test;
12 > import junit.framework.TestSuite;
13  
14   public class AtomicMarkableReferenceTest extends JSR166TestCase {
15 <    public static void main (String[] args) {
16 <        junit.textui.TestRunner.run (suite());
15 >    public static void main(String[] args) {
16 >        junit.textui.TestRunner.run(suite());
17      }
18      public static Test suite() {
19          return new TestSuite(AtomicMarkableReferenceTest.class);
20      }
21  
22      /**
23 <     *  constructor initializes to given reference and mark
23 >     * constructor initializes to given reference and mark
24       */
25      public void testConstructor() {
26          AtomicMarkableReference ai = new AtomicMarkableReference(one, false);
27 <        assertSame(one,ai.getReference());
27 >        assertSame(one, ai.getReference());
28          assertFalse(ai.isMarked());
29          AtomicMarkableReference a2 = new AtomicMarkableReference(null, true);
30          assertNull(a2.getReference());
# Line 30 | Line 32 | public class AtomicMarkableReferenceTest
32      }
33  
34      /**
35 <     *  get returns the last values of reference and mark set
35 >     * get returns the last values of reference and mark set
36       */
37      public void testGetSet() {
38          boolean[] mark = new boolean[1];
39          AtomicMarkableReference ai = new AtomicMarkableReference(one, false);
40 <        assertSame(one,ai.getReference());
40 >        assertSame(one, ai.getReference());
41          assertFalse(ai.isMarked());
42          assertSame(one, ai.get(mark));
43          assertFalse(mark[0]);
44          ai.set(two, false);
45 <        assertSame(two,ai.getReference());
45 >        assertSame(two, ai.getReference());
46          assertFalse(ai.isMarked());
47          assertSame(two, ai.get(mark));
48          assertFalse(mark[0]);
49          ai.set(one, true);
50 <        assertSame(one,ai.getReference());
50 >        assertSame(one, ai.getReference());
51          assertTrue(ai.isMarked());
52          assertSame(one, ai.get(mark));
53          assertTrue(mark[0]);
# Line 104 | Line 106 | public class AtomicMarkableReferenceTest
106          assertTrue(ai.compareAndSet(one, two, false, false));
107          t.join(LONG_DELAY_MS);
108          assertFalse(t.isAlive());
109 <        assertSame(ai.getReference(), three);
109 >        assertSame(three, ai.getReference());
110          assertFalse(ai.isMarked());
111      }
112  
# Line 124 | Line 126 | public class AtomicMarkableReferenceTest
126          assertTrue(ai.compareAndSet(one, one, false, true));
127          t.join(LONG_DELAY_MS);
128          assertFalse(t.isAlive());
129 <        assertSame(ai.getReference(), one);
129 >        assertSame(one, ai.getReference());
130          assertFalse(ai.isMarked());
131      }
132  
# Line 139 | Line 141 | public class AtomicMarkableReferenceTest
141          assertFalse(ai.isMarked());
142          assertFalse(mark[0]);
143  
144 <        while (!ai.weakCompareAndSet(one, two, false, false));
144 >        do {} while (!ai.weakCompareAndSet(one, two, false, false));
145          assertSame(two, ai.get(mark));
146          assertFalse(mark[0]);
147  
148 <        while (!ai.weakCompareAndSet(two, m3, false, true));
148 >        do {} while (!ai.weakCompareAndSet(two, m3, false, true));
149          assertSame(m3, ai.get(mark));
150          assertTrue(mark[0]);
151      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines