From 71a1460bb07beae312a2cb19f4327063755e13e8 Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Sun, 26 Dec 2021 00:24:33 -0800 Subject: [PATCH] Add an ignored test to reproduce the bug when rethrowing an exception --- .../thoughtworks/dsl/domains/taskSpec.scala | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/domains-task/.jvm/src/test/scala/com/thoughtworks/dsl/domains/taskSpec.scala b/domains-task/.jvm/src/test/scala/com/thoughtworks/dsl/domains/taskSpec.scala index da40c9432..969eb88a1 100644 --- a/domains-task/.jvm/src/test/scala/com/thoughtworks/dsl/domains/taskSpec.scala +++ b/domains-task/.jvm/src/test/scala/com/thoughtworks/dsl/domains/taskSpec.scala @@ -47,6 +47,32 @@ final class taskSpec extends AsyncFreeSpec with Matchers { }) + // TODO: Port the fix from 2.x + "rethrow" ignore Task.toFuture(Task { + class MyException extends Exception + val task1: Task[Int] = Task { + throw new MyException + } + + val task2 = Task { + val v = + try { + try { + !Shift(task1) + "no exception" + } catch { + case myException: MyException => + throw myException + } + } catch { + case myException: MyException => + "my exception" + } + s"try: $v" + } + !Shift(task2) should be("try: my exception") + }) + "try" in Task.toFuture(Task.apply { class MyException extends Exception val task1: Task[Int] = Task.apply {