Skip to content

Commit

Permalink
MixinSpec: also test on JS
Browse files Browse the repository at this point in the history
  • Loading branch information
durban committed Jan 12, 2025
1 parent bd72a8b commit 44b7b70
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ trait RxnAppMixin extends BaseMixin { this: IOApp =>
private[this] final val _asyncReactiveForIO: AsyncReactive[IO] =
new AsyncReactive.AsyncReactiveImpl[IO](this._mcasImpl)

implicit protected final def asyncReactiveForIO: AsyncReactive[IO] =
implicit protected[this] final def asyncReactiveForIO: AsyncReactive[IO] =
this._asyncReactiveForIO
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ trait TxnAppMixin extends BaseMixin { this: IOApp =>
private[this] final val _transactiveForIO: Transactive[IO] =
new Transactive.TransactiveImpl[IO](this._mcasImpl)

implicit protected final def transactiveForIO: Transactive[IO] =
implicit protected[this] final def transactiveForIO: Transactive[IO] =
this._transactiveForIO
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,38 @@ import cats.effect.{ IO, IOApp }

import stm.TRef

// TODO: fix running these tests on JS
final class MixinSpec extends munit.FunSuite {
final class MixinSpec extends munit.CatsEffectSuite {

test("RxnAppMixin") {
assertEquals(MainWithRxnAppMixin.globalInt.get(), 0)
MainWithRxnAppMixin.main(new Array[String](0))
assertEquals(MainWithRxnAppMixin.globalInt.get(), 43)
for {
_ <- IO(assertEquals(MainWithRxnAppMixin.globalInt.get(), 0))
_ <- MainWithRxnAppMixin.run(List.empty)
_ <- IO(assertEquals(MainWithRxnAppMixin.globalInt.get(), 43))
} yield ()
}

test("TxnAppMixin") {
assertEquals(MainWithTxnAppMixin.globalInt.get(), 0)
MainWithTxnAppMixin.main(new Array[String](0))
assertEquals(MainWithTxnAppMixin.globalInt.get(), 44)
for {
_ <- IO(assertEquals(MainWithTxnAppMixin.globalInt.get(), 0))
_ <- MainWithTxnAppMixin.run(List.empty)
_ <- IO(assertEquals(MainWithTxnAppMixin.globalInt.get(), 44))
} yield ()
}

test("Both (1)") {
assertEquals(MainWithBoth1.globalInt.get(), 0)
MainWithBoth1.main(new Array[String](0))
assertEquals(MainWithBoth1.globalInt.get(), 43 + 100)
for {
_ <- IO(assertEquals(MainWithBoth1.globalInt.get(), 0))
_ <- MainWithBoth1.run(List.empty)
_ <- IO(assertEquals(MainWithBoth1.globalInt.get(), 43 + 100))
} yield ()
}

test("Both (2)") {
assertEquals(MainWithBoth2.globalInt.get(), 0)
MainWithBoth2.main(new Array[String](0))
assertEquals(MainWithBoth2.globalInt.get(), 44 + 101)
for {
_ <- IO(assertEquals(MainWithBoth2.globalInt.get(), 0))
_ <- MainWithBoth2.run(List.empty)
_ <- IO(assertEquals(MainWithBoth2.globalInt.get(), 44 + 101))
} yield ()
}
}

Expand Down

0 comments on commit 44b7b70

Please sign in to comment.