Skip to content

Commit

Permalink
Fix test("capture value in closure")
Browse files Browse the repository at this point in the history
The test broke with the update of scala 3.3.0 (typelevel#1225).
However the old while loop did *not* capture the var so always created
List(3,3,3). So it tested that the implementation is actually *wrong*.
I changed the test to now use a fixed List.
  • Loading branch information
froth committed Aug 1, 2023
1 parent 22f6d14 commit 97ffbb9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ lazy val jscienceVersion = "4.3.1"
lazy val apacheCommonsMath3Version = "3.6.1"

val Scala213 = "2.13.10"
val Scala3 = "3.2.2"
val Scala3 = "3.3.0"

Global / onChangedBuildSource := ReloadOnSourceChanges

Expand Down
8 changes: 1 addition & 7 deletions tests/shared/src/test/scala/spire/syntax/CforSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,7 @@ class CforSuite extends munit.FunSuite {
cfor(0)(_ < 3, _ + 1) { x =>
b1 += (() => x)
}
val b2 = collection.mutable.ArrayBuffer[() => Int]()
var i = 0
while (i < 3) {
b2 += (() => i)
i += 1
}
assertEquals(b1.map(_.apply()).toList, b2.map(_.apply()).toList)
assertEquals(b1.map(_.apply()).toList, List(0, 1, 2))
}

test("capture value in inner class") {
Expand Down

0 comments on commit 97ffbb9

Please sign in to comment.