From 8f1b87755ec4c9c1c5fe6f3fb4d9c782814975b2 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 | 25 +++++++++++++++++++ 1 file changed, 25 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 62308b43..b232663e 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 @@ -116,6 +116,31 @@ final class taskSpec extends AsyncFreeSpec with Matchers { a[MyException] should be thrownBy task1 } + "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 { class MyException extends Exception val task1: Task[Int] = Task {