Skip to content
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.

Commit

Permalink
Add facility to check Java pickling in negative test
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Feb 13, 2015
1 parent 217476b commit d0d6c91
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
4 changes: 4 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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: _*).
Expand Down
9 changes: 6 additions & 3 deletions core/src/test/scala/pickling/NegativeCompilation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
8 changes: 4 additions & 4 deletions core/src/test/scala/pickling/neg/java-field-fail.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
14 changes: 14 additions & 0 deletions test-util/src/test/java/pickling/FakeByte.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit d0d6c91

Please sign in to comment.