Skip to content

Commit 96cb545

Browse files
committed
add tests for macros with new classes
1 parent 2a705be commit 96cb545

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

lib/src/test/scala/code/winitzki/jc/BlockingMoleculesSpec.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,42 @@ class BlockingMoleculesSpec extends FlatSpec with Matchers with TimeLimitedTests
8484

8585
behavior of "syntax of blocking molecules with unit values / replies"
8686

87+
it should "allow non-unit values and non-unit replies" in {
88+
val f = new B[Int,Int]("f")
89+
site(tp0)( _go { case f(x, r) if x == 123 => r(456) })
90+
f(123) shouldEqual 456
91+
}
92+
93+
it should "allow non-unit values and non-unit replies with timeout" in {
94+
val f = new B[Int,Int]("f")
95+
site(tp0)( _go { case f(x, r) if x != 123 => r(456) })
96+
f.timeout(200 millis)(123) shouldEqual None
97+
}
98+
8799
it should "allow non-unit values and unit replies" in {
88100
val f = new BE[Int]("f")
89101
site(tp0)( _go { case f(x, r) if x == 123 => r() })
90102
f(123) shouldEqual (())
91103
}
92104

105+
it should "allow non-unit values and unit replies with timeout" in {
106+
val f = new BE[Int]("f")
107+
site(tp0)( _go { case f(x, r) if x != 123 => r() })
108+
f.timeout(200 millis)(123) shouldEqual None
109+
}
110+
93111
it should "allow unit values and unit replies" in {
94112
val f = new EE("f")
95113
site(tp0)( _go { case f(x, r) if x == (()) => r() })
96114
f() shouldEqual (())
97115
}
98116

117+
it should "allow unit values and unit replies with timeout" in {
118+
val f = new EE("f")
119+
site(tp0)( _go { case f(x, r) if x != (()) => r() })
120+
f.timeout(200 millis)() shouldEqual None
121+
}
122+
99123
behavior of "reaction sites with invalid replies"
100124

101125
it should "use the first reply when a reaction attempts to reply twice" in {

macros/src/test/scala/code/winitzki/jc/MacrosSpec.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@ class MacrosSpec extends FlatSpec with Matchers with BeforeAndAfterEach {
3434
s.toString shouldEqual "s/B"
3535
}
3636

37+
it should "create an emitter of class E for m[Unit]" in {
38+
val a = m[Unit]
39+
a.isInstanceOf[E] shouldEqual true
40+
}
41+
42+
it should "create an emitter of class BE[Int] for b[Int, Unit]" in {
43+
val a = b[Int, Unit]
44+
a.isInstanceOf[BE[Int]] shouldEqual true
45+
}
46+
47+
it should "create an emitter of class EB[Int] for b[Unit, Int]" in {
48+
val a = b[Unit, Int]
49+
a.isInstanceOf[EB[Int]] shouldEqual true
50+
}
51+
52+
it should "create an emitter of class EE for b[Unit, Unit]" in {
53+
val a = b[Unit, Unit]
54+
a.isInstanceOf[EE] shouldEqual true
55+
}
56+
3757
behavior of "macros for inspecting a reaction body"
3858

3959

0 commit comments

Comments
 (0)