Skip to content

Commit a353720

Browse files
Scala version bump to the stable LTS 3.3.0
1 parent a80a9b0 commit a353720

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// based on http://caryrobbins.com/dev/sbt-publishing/
22

3-
val _scalaVersion = "3.3.0-RC3"
3+
val _scalaVersion = "3.3.0"
44

55
organization := "io.github.makingthematrix"
66
sonatypeProfileName := "io.github.makingthematrix"

src/test/scala/io/github/makingthematrix/signals3/generators/GeneratorSignalSpec.scala

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,35 @@ class GeneratorSignalSpec extends munit.FunSuite:
126126
assert(timePassed2 - timePassed1 >= 200, timePassed2)
127127
assert(pausedOn > 0L)
128128
}
129+
130+
test("Close the generator signal automatically") {
131+
import scala.util.Using
132+
val arr = mutable.ArrayBuilder.make[Int]
133+
Using(GeneratorSignal.counter(200.millis)) { sig =>
134+
sig.foreach(n => arr.addOne(n))
135+
Thread.sleep(500L)
136+
}
137+
val res1 = arr.result().toSeq
138+
assert(res1.nonEmpty)
139+
// the generator itself is not available here anymore (as it should be)
140+
// so to check if it's closed we wait a little and see if a new value was generated (it shouldn't be)
141+
Thread.sleep(500L)
142+
val res2 = arr.result().toSeq
143+
assertEquals(res1, res2)
144+
}
145+
146+
test("Close the generator stream automatically") {
147+
import scala.util.Using
148+
val arr = mutable.ArrayBuilder.make[Int]
149+
Using(GeneratorStream.repeat(1, 200.millis)) { stream =>
150+
stream.foreach(n => arr.addOne(n))
151+
Thread.sleep(500L)
152+
}
153+
val res1 = arr.result().toSeq
154+
assert(res1.nonEmpty)
155+
// the generator itself is not available here anymore (as it should be)
156+
// so to check if it's closed we wait a little and see if a new value was generated (it shouldn't be)
157+
Thread.sleep(500L)
158+
val res2 = arr.result().toSeq
159+
assertEquals(res1, res2)
160+
}

0 commit comments

Comments
 (0)