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

Comparing jsr166/src/test/tck/Atomic8Test.java (file contents):
Revision 1.8 by jsr166, Sat Sep 24 18:38:13 2016 UTC vs.
Revision 1.10 by jsr166, Fri Feb 22 19:27:47 2019 UTC

# Line 289 | Line 289 | public class Atomic8Test extends JSR166T
289       * result of supplied function
290       */
291      public void testReferenceArrayGetAndUpdate() {
292 <        AtomicReferenceArray<Integer> a = new AtomicReferenceArray<Integer>(1);
292 >        AtomicReferenceArray<Integer> a = new AtomicReferenceArray<>(1);
293          a.set(0, one);
294          assertEquals((Integer) 1, a.getAndUpdate(0, Atomic8Test::addInteger17));
295          assertEquals((Integer) 18, a.getAndUpdate(0, Atomic8Test::addInteger17));
# Line 301 | Line 301 | public class Atomic8Test extends JSR166T
301       * returns result.
302       */
303      public void testReferenceArrayUpdateAndGet() {
304 <        AtomicReferenceArray<Integer> a = new AtomicReferenceArray<Integer>(1);
304 >        AtomicReferenceArray<Integer> a = new AtomicReferenceArray<>(1);
305          a.set(0, one);
306          assertEquals((Integer) 18, a.updateAndGet(0, Atomic8Test::addInteger17));
307          assertEquals((Integer) 35, a.updateAndGet(0, Atomic8Test::addInteger17));
# Line 312 | Line 312 | public class Atomic8Test extends JSR166T
312       * with supplied function.
313       */
314      public void testReferenceArrayGetAndAccumulate() {
315 <        AtomicReferenceArray<Integer> a = new AtomicReferenceArray<Integer>(1);
315 >        AtomicReferenceArray<Integer> a = new AtomicReferenceArray<>(1);
316          a.set(0, one);
317          assertEquals((Integer) 1, a.getAndAccumulate(0, 2, Atomic8Test::sumInteger));
318          assertEquals((Integer) 3, a.getAndAccumulate(0, 3, Atomic8Test::sumInteger));
# Line 324 | Line 324 | public class Atomic8Test extends JSR166T
324       * returns result.
325       */
326      public void testReferenceArrayAccumulateAndGet() {
327 <        AtomicReferenceArray<Integer> a = new AtomicReferenceArray<Integer>(1);
327 >        AtomicReferenceArray<Integer> a = new AtomicReferenceArray<>(1);
328          a.set(0, one);
329          assertEquals((Integer) 7, a.accumulateAndGet(0, 6, Atomic8Test::sumInteger));
330          assertEquals((Integer) 10, a.accumulateAndGet(0, 3, Atomic8Test::sumInteger));
# Line 491 | Line 491 | public class Atomic8Test extends JSR166T
491       * null function argument
492       */
493      public void testGetAndUpdateNPE() {
494 <        Runnable[] throwingActions = {
494 >        assertThrows(
495 >            NullPointerException.class,
496              () -> new AtomicLong().getAndUpdate(null),
497              () -> new AtomicInteger().getAndUpdate(null),
498              () -> new AtomicReference().getAndUpdate(null),
# Line 500 | Line 501 | public class Atomic8Test extends JSR166T
501              () -> new AtomicReferenceArray(1).getAndUpdate(0, null),
502              () -> aLongFieldUpdater().getAndUpdate(this, null),
503              () -> anIntFieldUpdater().getAndUpdate(this, null),
504 <            () -> anIntegerFieldUpdater().getAndUpdate(this, null),
504 <        };
505 <        assertThrows(NullPointerException.class, throwingActions);
504 >            () -> anIntegerFieldUpdater().getAndUpdate(this, null));
505      }
506  
507      /**
508       * All Atomic updateAndGet methods throw NullPointerException on null function argument
509       */
510      public void testUpdateAndGetNPE() {
511 <        Runnable[] throwingActions = {
511 >        assertThrows(
512 >            NullPointerException.class,
513              () -> new AtomicLong().updateAndGet(null),
514              () -> new AtomicInteger().updateAndGet(null),
515              () -> new AtomicReference().updateAndGet(null),
# Line 518 | Line 518 | public class Atomic8Test extends JSR166T
518              () -> new AtomicReferenceArray(1).updateAndGet(0, null),
519              () -> aLongFieldUpdater().updateAndGet(this, null),
520              () -> anIntFieldUpdater().updateAndGet(this, null),
521 <            () -> anIntegerFieldUpdater().updateAndGet(this, null),
522 <        };
523 <        assertThrows(NullPointerException.class, throwingActions);
521 >            () -> anIntegerFieldUpdater().updateAndGet(this, null));
522      }
523  
524      /**
# Line 528 | Line 526 | public class Atomic8Test extends JSR166T
526       * on null function argument
527       */
528      public void testGetAndAccumulateNPE() {
529 <        Runnable[] throwingActions = {
529 >        assertThrows(
530 >            NullPointerException.class,
531              () -> new AtomicLong().getAndAccumulate(1L, null),
532              () -> new AtomicInteger().getAndAccumulate(1, null),
533              () -> new AtomicReference().getAndAccumulate(one, null),
# Line 537 | Line 536 | public class Atomic8Test extends JSR166T
536              () -> new AtomicReferenceArray(1).getAndAccumulate(0, one, null),
537              () -> aLongFieldUpdater().getAndAccumulate(this, 1L, null),
538              () -> anIntFieldUpdater().getAndAccumulate(this, 1, null),
539 <            () -> anIntegerFieldUpdater().getAndAccumulate(this, one, null),
541 <        };
542 <        assertThrows(NullPointerException.class, throwingActions);
539 >            () -> anIntegerFieldUpdater().getAndAccumulate(this, one, null));
540      }
541  
542      /**
# Line 547 | Line 544 | public class Atomic8Test extends JSR166T
544       * on null function argument
545       */
546      public void testAccumulateAndGetNPE() {
547 <        Runnable[] throwingActions = {
547 >        assertThrows(
548 >            NullPointerException.class,
549              () -> new AtomicLong().accumulateAndGet(1L, null),
550              () -> new AtomicInteger().accumulateAndGet(1, null),
551              () -> new AtomicReference().accumulateAndGet(one, null),
# Line 556 | Line 554 | public class Atomic8Test extends JSR166T
554              () -> new AtomicReferenceArray(1).accumulateAndGet(0, one, null),
555              () -> aLongFieldUpdater().accumulateAndGet(this, 1L, null),
556              () -> anIntFieldUpdater().accumulateAndGet(this, 1, null),
557 <            () -> anIntegerFieldUpdater().accumulateAndGet(this, one, null),
560 <        };
561 <        assertThrows(NullPointerException.class, throwingActions);
557 >            () -> anIntegerFieldUpdater().accumulateAndGet(this, one, null));
558      }
559  
560      /**
# Line 571 | Line 567 | public class Atomic8Test extends JSR166T
567          final AtomicLongFieldUpdater longUpdater = aLongFieldUpdater();
568          final AtomicIntegerFieldUpdater intUpdater = anIntFieldUpdater();
569          final AtomicReferenceFieldUpdater refUpdater = anIntegerFieldUpdater();
574        final Object obj = new Object();
570          for (Object x : new Object[]{ new Object(), null }) {
571 <            Runnable[] throwingActions = {
571 >            assertThrows(
572 >                ClassCastException.class,
573                  () -> longUpdater.get(x),
574                  () -> intUpdater.get(x),
575                  () -> refUpdater.get(x),
# Line 591 | Line 587 | public class Atomic8Test extends JSR166T
587  
588                  () -> longUpdater.compareAndSet(x, 17L, 42L),
589                  () -> intUpdater.compareAndSet(x, 17, 42),
590 <                () -> refUpdater.compareAndSet(x, (Integer) 17, (Integer) 42),
595 <            };
596 <            assertThrows(ClassCastException.class, throwingActions);
590 >                () -> refUpdater.compareAndSet(x, (Integer) 17, (Integer) 42));
591          }
592      }
593  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines