-
-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested mutable examples not running with Scala 2.13 #757
Comments
Hi James, I'm on holidays at the moment for 10 more days. I will have a look at that when I come back and unfortunately I have no idea of what is wrong there (also kind of annoyed that the current test suite does not cover this case) |
Actually I couldn't resist having a quick look. It seems that changing |
Thanks @etorreborre! Please enjoy your holiday, don't let my problems get in your way :) |
To work around etorreborre/specs2#757.
Wow, I need further investigation but it seems that Scala 2.12 was actually buggy w.r.t the initialization of objects where the code in the body of an object would run twice and this would discover the spec fragments properly. Whereas in 2.13 the initialization of an object is done only once and now the code discovering the fragments is buggy. This can only encourage me to remove that complicated code which was only there to support a marginal feature. |
fix tests to be class instead of object (see etorreborre/specs2#757)
Scala 2.13's singleton body evaluation semantics have changed, leading to a failure to discover fragments inside a singleton spec (see etorreborre/specs2#757).
Scala 2.13's singleton body evaluation semantics have changed, leading to a failure to discover fragments inside a singleton spec (see etorreborre/specs2#757).
I'm closing this issue. The code which is causing this will disappear anyway in the next major version of specs2. |
maybe scala/scala#7270 ? ``` package example import scala.reflect.NameTransformer object A{ Main.a = 1 } object B{ Main.b = 1 } object Main { var a: Int = 0 var b: Int = 0 def initializeByConstructor(): Int = { this.a = 0 val List(constructor) = Class.forName("example.A$").getDeclaredConstructors.toList constructor.setAccessible(true) constructor.newInstance() val result = Main.a this.a = 0 result } def initializeByMODULE_field(): Int = { this.b = 0 Class.forName("example.B$").getDeclaredField(NameTransformer.MODULE_INSTANCE_NAME).get(null) val result = Main.b this.b = 0 result } def main(args: Array[String]): Unit = { println((A, B)) println(scala.util.Properties.versionString) println(initializeByConstructor()) println(initializeByMODULE_field()) } } ``` ``` [info] version 2.12.11 [info] 1 [info] 0 ``` ``` [info] version 2.13.2 [info] 0 [info] 0 ```
#826 🙏 |
maybe scala/scala#7270 ? ``` package example import scala.reflect.NameTransformer object A{ Main.a = 1 } object B{ Main.b = 1 } object Main { var a: Int = 0 var b: Int = 0 def initializeByConstructor(): Int = { this.a = 0 val List(constructor) = Class.forName("example.A$").getDeclaredConstructors.toList constructor.setAccessible(true) constructor.newInstance() val result = Main.a this.a = 0 result } def initializeByMODULE_field(): Int = { this.b = 0 Class.forName("example.B$").getDeclaredField(NameTransformer.MODULE_INSTANCE_NAME).get(null) val result = Main.b this.b = 0 result } def main(args: Array[String]): Unit = { println((A, B)) println(scala.util.Properties.versionString) println(initializeByConstructor()) println(initializeByMODULE_field()) } } ``` ``` [info] version 2.12.11 [info] 1 [info] 0 ``` ``` [info] version 2.13.2 [info] 0 [info] 0 ```
This spec here:
https://github.com/jroper/play-geojson/blob/master/src/test/scala/au/id/jazzy/play/geojson/ExampleSpec.scala
Has examples nested two deep (ie,
"foo" should { "do something" in { "bar" in { ... } } }
. Using specs 4.6.0, this runs fine with Scala 2.11 and 2.12, but with 2.13, it doesn't run at all, it's as if the specs aren't there. Not sure if this is a Scala issue, specs2 issue, or if it's by design with Scala 2.13 and I need to update my specs.The text was updated successfully, but these errors were encountered: