diff --git a/build.sbt b/build.sbt index 1272c5ef96..7f0be18c6e 100644 --- a/build.sbt +++ b/build.sbt @@ -51,6 +51,7 @@ lazy val root: Project = (project in file(".")). /** Scala Pickling code */ lazy val core: Project = (project in file("core")). + dependsOn(testUtil % "test->test"). settings(commonSettings: _*). settings( name := "scala-pickling", @@ -73,6 +74,9 @@ lazy val core: Project = (project in file("core")). } ) +lazy val testUtil: Project = (project in file("test-util")). + settings(commonSettings ++ noPublish: _*) + lazy val sandbox: Project = (project in file("sandbox")). dependsOn(core). settings(commonSettings ++ noPublish: _*). diff --git a/core/src/test/scala/pickling/NegativeCompilation.scala b/core/src/test/scala/pickling/NegativeCompilation.scala index c9811e48d5..dc048d65a8 100644 --- a/core/src/test/scala/pickling/NegativeCompilation.scala +++ b/core/src/test/scala/pickling/NegativeCompilation.scala @@ -61,9 +61,12 @@ object NegativeCompilation { } def toolboxClasspath = { - val f = new java.io.File(s"core/target/scala-${scalaBinaryVersion}/classes") - if (!f.exists) sys.error(s"output directory ${f.getAbsolutePath} does not exist.") - f.getAbsolutePath + val f0 = new java.io.File(s"core/target/scala-${scalaBinaryVersion}/classes") + val f1 = new java.io.File(s"test-util/target/scala-${scalaBinaryVersion}/test-classes") + val fs = Vector(f0, f1) + fs foreach { f => if (!f.exists) sys.error(s"output directory ${f.getAbsolutePath} does not exist.") } + val sep = sys.props("file.separator") + fs.map(_.getAbsolutePath).mkString(sep) } def quasiquotesJar: String = { diff --git a/core/src/test/scala/pickling/neg/java-field-fail.scala b/core/src/test/scala/pickling/neg/java-field-fail.scala index 3ae99fe05b..f20a1d61e1 100644 --- a/core/src/test/scala/pickling/neg/java-field-fail.scala +++ b/core/src/test/scala/pickling/neg/java-field-fail.scala @@ -5,16 +5,16 @@ import NegativeCompilation._ import org.scalatest.FunSuite class JavaFieldFailTest extends FunSuite { - test("main") { + test("x.pickle does not compile for FakeByte") { expectError("Cannot generate") { """import _root_.scala.pickling._ |import _root_.scala.pickling.Defaults._ |import _root_.scala.pickling.json._ |import _root_.scala.pickling.static._ + |import scala.pickling.javafieldfail.FakeByte | - |val x: java.lang.Byte = 10.toByte - | - |val p = x.pickle""".stripMargin + |val x: FakeByte = new FakeByte(10) + |val pkl = x.pickle""".stripMargin } } } diff --git a/test-util/src/test/java/pickling/FakeByte.java b/test-util/src/test/java/pickling/FakeByte.java new file mode 100644 index 0000000000..99af1e4ba0 --- /dev/null +++ b/test-util/src/test/java/pickling/FakeByte.java @@ -0,0 +1,14 @@ +package scala.pickling.javafieldfail; + +public final class FakeByte { + private static final long serialVersionUID = 1L; + private final byte value; + + public FakeByte(byte value) { + this.value = value; + } + + public byte byteValue() { + return value; + } +}