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

Comparing jsr166/src/test/tck/AtomicLongFieldUpdaterTest.java (file contents):
Revision 1.10 by jsr166, Mon Nov 2 20:28:31 2009 UTC vs.
Revision 1.12 by jsr166, Mon Nov 16 05:30:07 2009 UTC

# Line 15 | Line 15 | public class AtomicLongFieldUpdaterTest
15      int z;
16      long w;
17  
18 <    public static void main(String[] args){
18 >    public static void main(String[] args) {
19          junit.textui.TestRunner.run(suite());
20      }
21      public static Test suite() {
# Line 25 | Line 25 | public class AtomicLongFieldUpdaterTest
25      /**
26       * Construction with non-existent field throws RuntimeException
27       */
28 <    public void testConstructor(){
29 <        try{
28 >    public void testConstructor() {
29 >        try {
30              AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest>
31                  a = AtomicLongFieldUpdater.newUpdater
32                  (AtomicLongFieldUpdaterTest.class, "y");
# Line 38 | Line 38 | public class AtomicLongFieldUpdaterTest
38      /**
39       * construction with field not of given type throws RuntimeException
40       */
41 <    public void testConstructor2(){
42 <        try{
41 >    public void testConstructor2() {
42 >        try {
43              AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest>
44                  a = AtomicLongFieldUpdater.newUpdater
45                  (AtomicLongFieldUpdaterTest.class, "z");
# Line 51 | Line 51 | public class AtomicLongFieldUpdaterTest
51      /**
52       * construction with non-volatile field throws RuntimeException
53       */
54 <    public void testConstructor3(){
55 <        try{
54 >    public void testConstructor3() {
55 >        try {
56              AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest>
57                  a = AtomicLongFieldUpdater.newUpdater
58                  (AtomicLongFieldUpdaterTest.class, "w");
# Line 65 | Line 65 | public class AtomicLongFieldUpdaterTest
65      /**
66       *  get returns the last value set or assigned
67       */
68 <    public void testGetSet(){
68 >    public void testGetSet() {
69          AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
70          try {
71              a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
# Line 83 | Line 83 | public class AtomicLongFieldUpdaterTest
83      /**
84       *  get returns the last value lazySet by same thread
85       */
86 <    public void testGetLazySet(){
86 >    public void testGetLazySet() {
87          AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
88          try {
89              a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
# Line 102 | Line 102 | public class AtomicLongFieldUpdaterTest
102      /**
103       * compareAndSet succeeds in changing value if equal to expected else fails
104       */
105 <    public void testCompareAndSet(){
105 >    public void testCompareAndSet() {
106          AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
107          try {
108              a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
# Line 135 | Line 135 | public class AtomicLongFieldUpdaterTest
135  
136          Thread t = new Thread(new Runnable() {
137                  public void run() {
138 <                    while(!a.compareAndSet(AtomicLongFieldUpdaterTest.this, 2, 3)) Thread.yield();
138 >                    while (!a.compareAndSet(AtomicLongFieldUpdaterTest.this, 2, 3)) Thread.yield();
139                  }});
140          try {
141              t.start();
# Line 144 | Line 144 | public class AtomicLongFieldUpdaterTest
144              assertFalse(t.isAlive());
145              assertEquals(a.get(this), 3);
146          }
147 <        catch(Exception e) {
147 >        catch (Exception e) {
148              unexpectedException();
149          }
150      }
# Line 153 | Line 153 | public class AtomicLongFieldUpdaterTest
153       * repeated weakCompareAndSet succeeds in changing value when equal
154       * to expected
155       */
156 <    public void testWeakCompareAndSet(){
156 >    public void testWeakCompareAndSet() {
157          AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
158          try {
159              a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
# Line 161 | Line 161 | public class AtomicLongFieldUpdaterTest
161              return;
162          }
163          x = 1;
164 <        while(!a.weakCompareAndSet(this,1,2));
165 <        while(!a.weakCompareAndSet(this,2,-4));
164 >        while (!a.weakCompareAndSet(this,1,2));
165 >        while (!a.weakCompareAndSet(this,2,-4));
166          assertEquals(-4,a.get(this));
167 <        while(!a.weakCompareAndSet(this,-4,7));
167 >        while (!a.weakCompareAndSet(this,-4,7));
168          assertEquals(7,a.get(this));
169      }
170  
171      /**
172       *  getAndSet returns previous value and sets to given value
173       */
174 <    public void testGetAndSet(){
174 >    public void testGetAndSet() {
175          AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
176          try {
177              a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
# Line 187 | Line 187 | public class AtomicLongFieldUpdaterTest
187      /**
188       * getAndAdd returns previous value and adds given value
189       */
190 <    public void testGetAndAdd(){
190 >    public void testGetAndAdd() {
191          AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
192          try {
193              a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
# Line 204 | Line 204 | public class AtomicLongFieldUpdaterTest
204      /**
205       * getAndDecrement returns previous value and decrements
206       */
207 <    public void testGetAndDecrement(){
207 >    public void testGetAndDecrement() {
208          AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
209          try {
210              a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
# Line 220 | Line 220 | public class AtomicLongFieldUpdaterTest
220      /**
221       * getAndIncrement returns previous value and increments
222       */
223 <    public void testGetAndIncrement(){
223 >    public void testGetAndIncrement() {
224          AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
225          try {
226              a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
# Line 240 | Line 240 | public class AtomicLongFieldUpdaterTest
240      /**
241       * addAndGet adds given value to current, and returns current value
242       */
243 <    public void testAddAndGet(){
243 >    public void testAddAndGet() {
244          AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
245          try {
246              a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
# Line 257 | Line 257 | public class AtomicLongFieldUpdaterTest
257      /**
258       *  decrementAndGet decrements and returns current value
259       */
260 <    public void testDecrementAndGet(){
260 >    public void testDecrementAndGet() {
261          AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
262          try {
263              a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
# Line 274 | Line 274 | public class AtomicLongFieldUpdaterTest
274      /**
275       * incrementAndGet increments and returns current value
276       */
277 <    public void testIncrementAndGet(){
277 >    public void testIncrementAndGet() {
278          AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
279          try {
280              a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines