@@ -448,116 +448,6 @@ module Concurrent
448
448
expect ( counter . value ) . to eq -1
449
449
end
450
450
end
451
-
452
- describe '.none?' do
453
-
454
- it 'returns a new Promise' do
455
- composite = Promise . none? ( promise1 , promise2 , promise3 ) . execute
456
- expect ( composite ) . to be_a Concurrent ::Promise
457
- end
458
-
459
- it 'does not execute the returned Promise' do
460
- composite = Promise . none? ( promise1 , promise2 , promise3 )
461
- expect ( composite ) . to be_unscheduled
462
- end
463
-
464
- it 'executes the #then condition when all components fail' do
465
- counter = Concurrent ::AtomicFixnum . new ( 0 )
466
- latch = Concurrent ::CountDownLatch . new ( 1 )
467
-
468
- composite = Promise . none? ( rejected_subject , rejected_subject , rejected_subject , rejected_subject ) .
469
- then { counter . up ; latch . count_down } .
470
- rescue { counter . down ; latch . count_down } .
471
- execute
472
-
473
- latch . wait ( 1 )
474
-
475
- expect ( counter . value ) . to eq 1
476
- end
477
-
478
- it 'executes the #then condition when no promises are given' do
479
- counter = Concurrent ::AtomicFixnum . new ( 0 )
480
- latch = Concurrent ::CountDownLatch . new ( 1 )
481
-
482
- composite = Promise . none? .
483
- then { counter . up ; latch . count_down } .
484
- rescue { counter . down ; latch . count_down } .
485
- execute
486
-
487
- latch . wait ( 1 )
488
-
489
- expect ( counter . value ) . to eq 1
490
- end
491
-
492
- it 'executes the #rescue handler if even one component succeeds' do
493
- counter = Concurrent ::AtomicFixnum . new ( 0 )
494
- latch = Concurrent ::CountDownLatch . new ( 1 )
495
-
496
- composite = Promise . none? ( promise1 , promise2 , rejected_subject , promise3 ) .
497
- then { counter . up ; latch . count_down } .
498
- rescue { counter . down ; latch . count_down } .
499
- execute
500
-
501
- latch . wait ( 1 )
502
-
503
- expect ( counter . value ) . to eq -1
504
- end
505
- end
506
-
507
- describe '.one?' do
508
-
509
- it 'returns a new Promise' do
510
- composite = Promise . one? ( promise1 , promise2 , promise3 ) . execute
511
- expect ( composite ) . to be_a Concurrent ::Promise
512
- end
513
-
514
- it 'does not execute the returned Promise' do
515
- composite = Promise . one? ( promise1 , promise2 , promise3 )
516
- expect ( composite ) . to be_unscheduled
517
- end
518
-
519
- it 'executes the #then condition when only one component succeeds' do
520
- counter = Concurrent ::AtomicFixnum . new ( 0 )
521
- latch = Concurrent ::CountDownLatch . new ( 1 )
522
-
523
- composite = Promise . one? ( promise1 , rejected_subject , rejected_subject , rejected_subject ) .
524
- then { counter . up ; latch . count_down } .
525
- rescue { counter . down ; latch . count_down } .
526
- execute
527
-
528
- latch . wait ( 1 )
529
-
530
- expect ( counter . value ) . to eq 1
531
- end
532
-
533
- it 'executes the #then condition when no promises are given' do
534
- counter = Concurrent ::AtomicFixnum . new ( 0 )
535
- latch = Concurrent ::CountDownLatch . new ( 1 )
536
-
537
- composite = Promise . one? .
538
- then { counter . up ; latch . count_down } .
539
- rescue { counter . down ; latch . count_down } .
540
- execute
541
-
542
- latch . wait ( 1 )
543
-
544
- expect ( counter . value ) . to eq 1
545
- end
546
-
547
- it 'executes the #rescue handler if two or more components succeed' do
548
- counter = Concurrent ::AtomicFixnum . new ( 0 )
549
- latch = Concurrent ::CountDownLatch . new ( 1 )
550
-
551
- composite = Promise . one? ( promise1 , promise2 , rejected_subject , promise3 ) .
552
- then { counter . up ; latch . count_down } .
553
- rescue { counter . down ; latch . count_down } .
554
- execute
555
-
556
- latch . wait ( 1 )
557
-
558
- expect ( counter . value ) . to eq -1
559
- end
560
- end
561
451
end
562
452
563
453
context 'fulfillment' do
0 commit comments