Skip to content

Commit e7eb7f7

Browse files
committed
Fix Scala 3 compilation.
1 parent c8d9c34 commit e7eb7f7

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

retry/src/test/scala/PolicySpec.scala

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
424424
implicit val success = Success.always
425425
val innerPolicy = Directly()
426426
val counter = new AtomicInteger(0)
427-
val future = FailFast(innerPolicy)(_ => false) {
427+
val future = FailFast(innerPolicy) {
428+
case _ => false
429+
} {
428430
counter.incrementAndGet()
429431
Future.successful("yay!")
430432
}
@@ -435,15 +437,19 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
435437
implicit val success = Success[Int](_ == 3)
436438
val tries = forwardCountingFutureStream().iterator
437439
val innerPolicy = Directly(3)
438-
val future = FailFast(innerPolicy)(_ => false)(tries.next)
440+
val future = FailFast(innerPolicy) {
441+
case _ => false
442+
} (tries.next)
439443
future.map(result => assert(success.predicate(result) === true))
440444
}
441445

442446
it("should fail when inner policy retries are exceeded") {
443447
implicit val success = Success.always
444448
val innerPolicy = Directly(3)
445449
val counter = new AtomicInteger(0)
446-
val future = FailFast(innerPolicy)(_ => false) {
450+
val future = FailFast(innerPolicy) {
451+
case _ => false
452+
} {
447453
counter.incrementAndGet()
448454
Future.failed(new RuntimeException("always failing"))
449455
}
@@ -457,7 +463,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
457463
implicit val success = Success.always
458464
val innerPolicy = Directly.forever
459465
val counter = new AtomicInteger(0)
460-
val future = FailFast(innerPolicy)(_ => true) {
466+
val future = FailFast(innerPolicy) {
467+
case _ => true
468+
} {
461469
counter.incrementAndGet()
462470
Future.failed(new RuntimeException("always failing"))
463471
}
@@ -470,7 +478,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
470478
implicit val success = Success.always
471479
val innerPolicy = Directly.forever
472480
val counter = new AtomicInteger(0)
473-
val future = FailFast(innerPolicy)(_.getMessage == "2") {
481+
val future = FailFast(innerPolicy) {
482+
case e => e.getMessage == "2"
483+
} {
474484
val counterValue = counter.getAndIncrement()
475485
Future.failed(new RuntimeException(counterValue.toString))
476486
}
@@ -491,7 +501,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
491501
Future(true)
492502
}
493503
val innerPolicy = Directly.forever
494-
val policy = FailFast(innerPolicy)(_ => false)
504+
val policy = FailFast(innerPolicy) {
505+
case _ => false
506+
}
495507
policy(run()).map { result =>
496508
assert(result === true)
497509
assert(retried.get() == 10000)
@@ -510,7 +522,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
510522
Future(true)
511523
}
512524
val innerPolicy = Pause.forever(1.millis)
513-
val policy = FailFast(innerPolicy)(_ => false)
525+
val policy = FailFast(innerPolicy) {
526+
case _ => false
527+
}
514528
policy(run()).map { result =>
515529
assert(result === true)
516530
assert(retried.get() == 1000)
@@ -529,7 +543,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
529543
Future(true)
530544
}
531545
val innerPolicy = Backoff.forever(1.millis)
532-
val policy = FailFast(innerPolicy)(_ => false)
546+
val policy = FailFast(innerPolicy) {
547+
case _ => false
548+
}
533549
policy(run()).map { result =>
534550
assert(result === true)
535551
assert(retried.get() == 5)
@@ -548,7 +564,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
548564
Future(true)
549565
}
550566
val innerPolicy = JitterBackoff.forever(1.millis)
551-
val policy = FailFast(innerPolicy)(_ => false)
567+
val policy = FailFast(innerPolicy) {
568+
case _ => false
569+
}
552570
policy(run()).map { result =>
553571
assert(result === true)
554572
assert(retried.get() == 10)
@@ -570,7 +588,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
570588
val innerPolicy = When {
571589
case _: MyException => Directly.forever
572590
}
573-
val policy = FailFast(innerPolicy)(_ => false)
591+
val policy = FailFast(innerPolicy) {
592+
case _ => false
593+
}
574594
policy(run()).map { result =>
575595
assert(result === true)
576596
assert(retried.get() == 10000)
@@ -588,7 +608,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
588608
val innerPolicy = When {
589609
case _: MyException => Directly.forever
590610
}
591-
val policy = FailFast(innerPolicy)(_ => true)
611+
val policy = FailFast(innerPolicy) {
612+
case _ => true
613+
}
592614
policy(run()).failed.map { t =>
593615
assert(t.getMessage === "my exception")
594616
assert(retried.get() == 1)

0 commit comments

Comments
 (0)