Skip to content

Commit

Permalink
Add DontSuspend option
Browse files Browse the repository at this point in the history
  • Loading branch information
Atry committed Dec 25, 2021
1 parent fa067f3 commit a640a70
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 130 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.thoughtworks.dsl
package domains

import com.thoughtworks.dsl.macros.Reset
import com.thoughtworks.dsl.macros.Reset.Default.*
import com.thoughtworks.dsl.Dsl.{!!}
import org.scalatest.Assertion
Expand Down Expand Up @@ -34,7 +35,7 @@ final class taskSpec extends AsyncFreeSpec with Matchers {
}
summon[
reified.type <:<
Typed[FlatMap[
Typed[Suspend[FlatMap[
Pure[n.type],
Match.WithIndex[(0), Pure[(0)]]
+:
Expand All @@ -45,7 +46,7 @@ final class taskSpec extends AsyncFreeSpec with Matchers {
FlatMap[Shift[Task.TaskDomain, Int], Pure[Int]]
]]
+: Nothing
], Int]
]], Int]
]
Task {

Expand All @@ -70,15 +71,12 @@ final class taskSpec extends AsyncFreeSpec with Matchers {
} else {
accumulator
})
summon[reified.type <:< Typed[
If[Pure[
Boolean
], Shift[
Task.TaskDomain,
Int
], Pure[Int]],
summon[reified.type <:< Typed[Suspend[If[Pure[
Boolean
], Shift[
Task.TaskDomain,
Int
]]
], Pure[Int]]], Int]]
Task {
if (i < 10000) {
!Shift(loop(i + 1, accumulator + i))
Expand Down Expand Up @@ -110,7 +108,10 @@ final class taskSpec extends AsyncFreeSpec with Matchers {

"*[Task] does not necessarily suspend or catch exceptions" in {
class MyException extends Exception
def task1: Task[Int] = *[Task] {
def task1: Task[Int] = new Reset {
type ShouldResetNestedFunctions = false
type DontSuspend = true
}.*[Task] {
throw new MyException
}
a[MyException] should be thrownBy task1
Expand Down
Loading

0 comments on commit a640a70

Please sign in to comment.