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

Versioning pickles #204

Open
wants to merge 1 commit into
base: 0.9.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions core/src/main/scala/pickling/Macros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ trait PicklerMacros extends Macro with PickleMacros {
(resOpt, resLst)
}
}

def unifiedPickle = { // NOTE: unified = the same code works for both primitives and objects
val cir = newClassIR(tpe)
// println(s"CIR for ${tpe.toString}: ${cir.fields.mkString(",")}")
Expand All @@ -88,15 +89,17 @@ trait PicklerMacros extends Macro with PickleMacros {
val noNullTree = lst.foldLeft[Tree](Literal(Constant(true)))((acc, curr) => q"$acc && ($curr != null)")
q"""
if ($noNullTree) {
val size = $tree + $typeNameLen + 4
val size = $tree + $typeNameLen + 5
builder.hintKnownSize(size)
}
"""
}

val beginEntry = q"""
$hintKnownSize
builder.beginEntry(picklee)
"""

val (nonLoopyFields, loopyFields) = cir.fields.partition(fir => !shouldBotherAboutLooping(fir.tpe))
val putFields =
if (tpe <:< typeOf[java.io.Externalizable]) {
Expand Down Expand Up @@ -383,28 +386,24 @@ trait PickleMacros extends Macro {
import definitions._

def pickleTo[T: c.WeakTypeTag](output: c.Tree)(format: c.Tree): c.Tree = {
val tpe = weakTypeOf[T]
val q"${_}($pickleeArg)" = c.prefix.tree
val endPickle = if (shouldBotherAboutCleaning(tpe)) q"clearPicklees()" else q"";
q"""
import scala.pickling._
import scala.pickling.internal._
val picklee: $tpe = $pickleeArg
val builder = $format.createBuilder($output)
picklee.pickleInto(builder)
$endPickle
"""
pickleImpl[T](pickleeArg, q"$format.createBuilder($output)")
}

def pickle[T: c.WeakTypeTag](format: c.Tree): c.Tree = {
val tpe = weakTypeOf[T]
val q"${_}($pickleeArg)" = c.prefix.tree
pickleImpl[T](pickleeArg, q"$format.createBuilder()")
}

def pickleImpl[T: c.WeakTypeTag](pickleeArg: c.Tree, mkBuilder: c.Tree): c.Tree = {
val tpe = weakTypeOf[T]
val endPickle = if (shouldBotherAboutCleaning(tpe)) q"clearPicklees()" else q"";
q"""
import scala.pickling._
import scala.pickling.internal._
val picklee: $tpe = $pickleeArg
val builder = $format.createBuilder()
val builder = $mkBuilder
builder.beginPickle()
picklee.pickleInto(builder)
$endPickle
builder.result()
Expand Down Expand Up @@ -542,6 +541,7 @@ trait UnpickleMacros extends Macro {
val format = implicitly[PickleFormat]
val pickle = $pickleArg.thePickle.asInstanceOf[format.PickleType]
val $readerName = format.createReader(pickle, scala.pickling.internal.`package`.currentMirror)
$readerName.beginPickle()
$readerUnpickleTree
"""
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/pickling/PBuilderReader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ trait Hintable {
}

trait PBuilder extends Hintable {
def beginPickle(): PBuilder
def beginEntry(picklee: Any): PBuilder
def putField(name: String, pickler: PBuilder => Unit): PBuilder
def endEntry(): Unit
Expand All @@ -28,6 +29,7 @@ trait PBuilder extends Hintable {

trait PReader extends Hintable {
def mirror: Mirror
def beginPickle(): PReader
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no endPickle?

def beginEntry(): FastTypeTag[_]
def beginEntryNoTag(): String
def beginEntryNoTagDebug(debugOn: Boolean): String
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/pickling/PickleFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ trait PickleFormat {
type PickleType <: Pickle
type OutputType

val version: Int

def createBuilder(): PBuilder
def createBuilder(out: OutputType): PBuilder
def createReader(pickle: PickleType, mirror: Mirror): PReader
Expand Down
37 changes: 36 additions & 1 deletion core/src/main/scala/pickling/binary/BinaryPickleFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,25 @@ package binary {

private var output: ArrayOutput[Byte] = out

private var writeVersion = false

@inline private[this] def mkOutput(knownSize: Int): Unit =
if (output == null)
if (output == null) {
output = if (knownSize != -1) new ByteArrayOutput(knownSize)
else new ByteArrayBufferOutput
if (writeVersion) {
writeVersion = false
Util.encodeByte(output, format.version.asInstanceOf[Byte])
}
} else if (writeVersion) {
writeVersion = false
Util.encodeByte(output, format.version.asInstanceOf[Byte])
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can avoid code duplication in this case.


def beginPickle(): PBuilder = {
writeVersion = true
this
}

@inline def beginEntry(picklee: Any): PBuilder = withHints { hints =>
mkOutput(hints.knownSize)
Expand Down Expand Up @@ -197,6 +212,14 @@ package binary {

var gla: Option[Byte] = None

def beginPickle(): PReader = {
// read format version and check for mismatch
val v = nextByte()
if (v != format.version)
throw new Exception(s"Incompatible pickle format version: read version $v, expected version ${format.version}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throw PicklingException instead?

this
}

def beginEntryNoTag(): String =
beginEntryNoTagDebug(false)

Expand Down Expand Up @@ -427,6 +450,15 @@ package binary {

private var pos = 0

def beginPickle(): PReader = {
// read format version and check for mismatch
val v = arr(pos)
pos += 1
if (v != format.version)
throw new Exception(s"Incompatible pickle format version: read version $v, expected version ${format.version}")
this
}

def beginEntryNoTag(): String =
beginEntryNoTagDebug(false)

Expand Down Expand Up @@ -572,6 +604,9 @@ package binary {
class BinaryPickleFormat extends PickleFormat with Constants {
type PickleType = BinaryPickle
type OutputType = ArrayOutput[Byte]

val version = 2

def createBuilder() = new BinaryPickleBuilder(this, null)
def createBuilder(out: ArrayOutput[Byte]): PBuilder = new BinaryPickleBuilder(this, out)
def createReader(pickle: PickleType, mirror: Mirror) = pickle.createReader(mirror, this)
Expand Down
17 changes: 17 additions & 0 deletions core/src/main/scala/pickling/fastbinary/BinaryPickleFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class BinaryPickleFormat extends PickleFormat with Constants {
type PickleType = BinaryPickle
type OutputType = FastArrayOutput

val version = 2

def createBuilder() = new BinaryPickleBuilder(this, null)
def createBuilder(out: FastArrayOutput): PBuilder = new BinaryPickleBuilder(this, out)

Expand Down Expand Up @@ -60,6 +62,11 @@ final class BinaryPickleBuilder(format: BinaryPickleFormat, out: FastArrayOutput
if (out == null) new FastArrayOutput
else out

def beginPickle(): PBuilder = {
// TODO: write version of pickle format to pickle
this
}

@inline def beginEntry(picklee: Any): PBuilder = withHints { hints =>
if (picklee == null) {
Util.encodeByte(output, NULL_TAG)
Expand Down Expand Up @@ -200,6 +207,11 @@ final class BinaryPickleBuilder(format: BinaryPickleFormat, out: FastArrayOutput

var gla: Option[Byte] = None

def beginPickle(): PReader = {
// TODO: read format version and check for mismatch
this
}

def beginEntryNoTag(): String =
beginEntryNoTagDebug(false)

Expand Down Expand Up @@ -430,6 +442,11 @@ final class BinaryPickleBuilder(format: BinaryPickleFormat, out: FastArrayOutput

private var pos = 0

def beginPickle(): PReader = {
// TODO: read format version and check for mismatch
this
}

def beginEntryNoTag(): String =
beginEntryNoTagDebug(false)

Expand Down
14 changes: 14 additions & 0 deletions core/src/main/scala/pickling/json/JSONPickleFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ package json {
class JSONPickleFormat extends PickleFormat {
type PickleType = JSONPickle
type OutputType = Output[String]

val version = 2

def createBuilder() = new JSONPickleBuilder(this, new StringOutput)
def createBuilder(out: Output[String]): PBuilder = new JSONPickleBuilder(this, out)
def createReader(pickle: JSONPickle, mirror: Mirror) = {
Expand Down Expand Up @@ -96,6 +99,12 @@ package json {
FastTypeTag.ArrayFloat.key -> ((picklee: Any) => pickleArray(picklee.asInstanceOf[Array[Float]], FastTypeTag.Float)),
FastTypeTag.ArrayDouble.key -> ((picklee: Any) => pickleArray(picklee.asInstanceOf[Array[Double]], FastTypeTag.Double))
)

def beginPickle(): PBuilder = {
// write version of pickle format to pickle
this
}

def beginEntry(picklee: Any): PBuilder = withHints { hints =>
indent()
if (hints.oid != -1) {
Expand Down Expand Up @@ -198,6 +207,11 @@ package json {
nested
}

def beginPickle(): PReader = {
// TODO: read format version and check for mismatch
this
}

def beginEntryNoTag(): String =
beginEntryNoTagDebug(false)

Expand Down
2 changes: 1 addition & 1 deletion core/src/test/scala/pickling/run/array-binary.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ case class D(x: Int)
class ArrayBinaryTest extends FunSuite {
test("main") {
val pickle = C(Array(1, 2, 3)).pickle
assert(pickle.toString === "BinaryPickle([0,0,0,29,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,97,114,114,97,121,46,98,105,110,97,114,121,46,67,0,0,0,3,1,0,0,0,2,0,0,0,3,0,0,0])")
assert(pickle.toString === "BinaryPickle([2,0,0,0,29,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,97,114,114,97,121,46,98,105,110,97,114,121,46,67,0,0,0,3,1,0,0,0,2,0,0,0,3,0,0,0])")
assert(pickle.unpickle[C].toString === "C([1,2,3])")
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/test/scala/pickling/run/binary-array-int.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class BinaryArrayIntTest extends FunSuite {
val ia = Array[Int](30, 31)

val pickle: BinaryPickle = ia.pickle
assert(pickle.value.mkString("[", ",", "]") === "[0,0,0,22,115,99,97,108,97,46,65,114,114,97,121,91,115,99,97,108,97,46,73,110,116,93,0,0,0,2,30,0,0,0,31,0,0,0]")
assert(pickle.value.mkString("[", ",", "]") === "[2,0,0,0,22,115,99,97,108,97,46,65,114,114,97,121,91,115,99,97,108,97,46,73,110,116,93,0,0,0,2,30,0,0,0,31,0,0,0]")

val readArr = pickle.unpickle[Array[Int]]
assert(readArr.mkString("[", ",", "]") === "[30,31]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BinaryCaseClassIntStringTest extends FunSuite {
test("main") {
val p = Person("Jim", 43)
val pickle = p.pickle
assert(pickle.value.mkString("[", ",", "]") === "[0,0,0,50,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,98,105,110,97,114,121,46,99,97,115,101,46,99,108,97,115,115,46,105,110,116,46,115,116,114,105,110,103,46,80,101,114,115,111,110,0,0,0,3,74,105,109,0,0,0,43]")
assert(pickle.value.mkString("[", ",", "]") === "[2,0,0,0,50,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,98,105,110,97,114,121,46,99,97,115,101,46,99,108,97,115,115,46,105,110,116,46,115,116,114,105,110,103,46,80,101,114,115,111,110,0,0,0,3,74,105,109,0,0,0,43]")
val up = pickle.unpickle[Person]
assert(p === up)
}
Expand Down
1 change: 1 addition & 0 deletions core/src/test/scala/pickling/run/binary-dpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class BinaryDPicklerTest extends FunSuite {
val ff = Firefighter("Jim", 43, 30000)

val builder = pickleFormat.createBuilder()
builder.beginPickle()
dp.pickle(ff, builder)
val pickle = builder.result()
val up = pickle.unpickle[Person]
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/scala/pickling/run/binary-inputstream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class BinaryInputStreamReaderTest extends FunSuite {
val arr = Array[Int](30, 31)

val pickle: BinaryPickle = arr.pickle
assert(pickle.value.mkString("[", ",", "]") === "[0,0,0,22,115,99,97,108,97,46,65,114,114,97,121,91,115,99,97,108,97,46,73,110,116,93,0,0,0,2,30,0,0,0,31,0,0,0]")
assert(pickle.value.mkString("[", ",", "]") === "[2,0,0,0,22,115,99,97,108,97,46,65,114,114,97,121,91,115,99,97,108,97,46,73,110,116,93,0,0,0,2,30,0,0,0,31,0,0,0]")

val streamPickle = BinaryPickleStream(new ByteArrayInputStream(pickle.value))
val readArr = streamPickle.unpickle[Array[Int]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class BinaryListIntCustomTest extends FunSuite {
}

val pickle = lst.pickle
assert(pickle.toString === "BinaryPickle([0,0,0,50,115,99,97,108,97,46,99,111,108,108,101,99,116,105,111,110,46,105,109,109,117,116,97,98,108,101,46,36,99,111,108,111,110,36,99,111,108,111,110,91,115,99,97,108,97,46,73,110,116,93,0,0,0,10,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0,10])")
assert(pickle.toString === "BinaryPickle([2,0,0,0,50,115,99,97,108,97,46,99,111,108,108,101,99,116,105,111,110,46,105,109,109,117,116,97,98,108,101,46,36,99,111,108,111,110,36,99,111,108,111,110,91,115,99,97,108,97,46,73,110,116,93,0,0,0,10,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0,10])")
assert(pickle.unpickle[List[Int]] === List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
}
}
2 changes: 1 addition & 1 deletion core/src/test/scala/pickling/run/binary-list-t-new.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import binary._
class BinaryListTNewTest extends FunSuite {
test("main") {
val pickle = List(1, 2, 3).pickle
assert(pickle.toString === "BinaryPickle([0,0,0,50,115,99,97,108,97,46,99,111,108,108,101,99,116,105,111,110,46,105,109,109,117,116,97,98,108,101,46,36,99,111,108,111,110,36,99,111,108,111,110,91,115,99,97,108,97,46,73,110,116,93,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])")
assert(pickle.toString === "BinaryPickle([2,0,0,0,50,115,99,97,108,97,46,99,111,108,108,101,99,116,105,111,110,46,105,109,109,117,116,97,98,108,101,46,36,99,111,108,111,110,36,99,111,108,111,110,91,115,99,97,108,97,46,73,110,116,93,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])")
assert(pickle.unpickle[List[Int]] === List(1, 2, 3))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BinaryNonPrimitiveFieldTest extends FunSuite {
val p = Philipp(gudrun)
val pckl = p.pickle

assert(pckl.value.mkString("[", ",", "]") === "[0,0,0,49,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,98,105,110,97,114,121,46,110,111,110,46,112,114,105,109,105,116,105,118,101,46,102,105,101,108,100,46,80,104,105,108,105,112,112,-5,0,0,0,6,71,117,100,114,117,110,0,0,0,62]")
assert(pckl.value.mkString("[", ",", "]") === "[2,0,0,0,49,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,98,105,110,97,114,121,46,110,111,110,46,112,114,105,109,105,116,105,118,101,46,102,105,101,108,100,46,80,104,105,108,105,112,112,-5,0,0,0,6,71,117,100,114,117,110,0,0,0,62]")
assert(pckl.unpickle[Philipp] === p)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BinaryNonPrimitiveFieldsTest extends FunSuite {
test("main") {
val ph = new Philipp("German", true, new Person("Gudrun", 62))
val pckl = ph.pickle
assert(pckl.value.mkString("[", ",", "]") === "[0,0,0,50,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,98,105,110,97,114,121,46,110,111,110,46,112,114,105,109,105,116,105,118,101,46,102,105,101,108,100,115,46,80,104,105,108,105,112,112,0,0,0,6,71,101,114,109,97,110,1,-5,0,0,0,6,71,117,100,114,117,110,0,0,0,62]")
assert(pckl.value.mkString("[", ",", "]") === "[2,0,0,0,50,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,98,105,110,97,114,121,46,110,111,110,46,112,114,105,109,105,116,105,118,101,46,102,105,101,108,100,115,46,80,104,105,108,105,112,112,0,0,0,6,71,101,114,109,97,110,1,-5,0,0,0,6,71,117,100,114,117,110,0,0,0,62]")
assert(pckl.unpickle[Philipp] == ph)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BinarySimpleCaseClassTest extends FunSuite {
test("main") {
val p = Person(43)
val pickle = p.pickle
assert(pickle.value.mkString("[", ",", "]") === "[0,0,0,46,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,98,105,110,97,114,121,46,115,105,109,112,108,101,46,99,97,115,101,46,99,108,97,115,115,46,80,101,114,115,111,110,0,0,0,43]")
assert(pickle.value.mkString("[", ",", "]") === "[2,0,0,0,46,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,98,105,110,97,114,121,46,115,105,109,112,108,101,46,99,97,115,101,46,99,108,97,115,115,46,80,101,114,115,111,110,0,0,0,43]")
assert(pickle.unpickle[Person] === p)
}
}
2 changes: 1 addition & 1 deletion core/src/test/scala/pickling/run/c-x-any-binary.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CXAnyBinaryTest extends FunSuite {
test("main") {
val c = new C(2)
val pckl = c.pickle
assert(pckl.toString === "BinaryPickle([0,0,0,31,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,99,46,120,46,97,110,121,46,98,105,110,97,114,121,46,67,0,0,0,9,115,99,97,108,97,46,73,110,116,0,0,0,2])")
assert(pckl.toString === "BinaryPickle([2,0,0,0,31,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,99,46,120,46,97,110,121,46,98,105,110,97,114,121,46,67,0,0,0,9,115,99,97,108,97,46,73,110,116,0,0,0,2])")
assert(pckl.unpickle[C] === c)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class CombinatorPickleIntoTest extends FunSuite {

val bart = new Person(2)
val pickle = bart.pickle
assert(pickle.value.mkString("[", ",", "]") === "[0,0,0,43,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,99,111,109,98,105,110,97,116,111,114,46,112,105,99,107,108,101,105,110,116,111,46,80,101,114,115,111,110,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]")
assert(pickle.value.mkString("[", ",", "]") === "[2,0,0,0,43,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,99,111,109,98,105,110,97,116,111,114,46,112,105,99,107,108,101,105,110,116,111,46,80,101,114,115,111,110,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]")

val p = pickle.unpickle[Person]
assert(p.toString === "Person(Bart, 45)")
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/scala/pickling/run/generics-tough.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class GenericsToughTest extends FunSuite {
test("main") {
val c: C[Int] = D(2)
val p = c.pickle
assert(p.toString === "BinaryPickle([0,0,0,42,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,103,101,110,101,114,105,99,115,46,116,111,117,103,104,46,68,91,115,99,97,108,97,46,73,110,116,93,0,0,0,2])")
assert(p.toString === "BinaryPickle([2,0,0,0,42,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,103,101,110,101,114,105,99,115,46,116,111,117,103,104,46,68,91,115,99,97,108,97,46,73,110,116,93,0,0,0,2])")
assert(p.unpickle[C[Int]] === c)
}
}
2 changes: 1 addition & 1 deletion core/src/test/scala/pickling/run/null-binary.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NullBinaryTest extends FunSuite {
test("main") {
val c = C(null, 0, null, null)
val pickle = c.pickle
assert(pickle.value.mkString("[", ",", "]") === "[0,0,0,28,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,110,117,108,108,46,98,105,110,97,114,121,46,67,-2,0,0,0,0,-2,-2]")
assert(pickle.value.mkString("[", ",", "]") === "[2,0,0,0,28,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,110,117,108,108,46,98,105,110,97,114,121,46,67,-2,0,0,0,0,-2,-2]")
assert(pickle.unpickle[C].toString === c.toString)
}
}
2 changes: 1 addition & 1 deletion core/src/test/scala/pickling/run/share-binary-any.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ShareBinaryAnyTest extends FunSuite {
import shareNothing._
c1.c = null
val pickle = (c3: Any).pickle
assert(pickle.toString === "BinaryPickle([0,0,0,33,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,115,104,97,114,101,46,98,105,110,97,114,121,46,97,110,121,46,67,0,0,0,2,99,51,0,0,0,4,100,101,115,99,0,0,0,33,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,115,104,97,114,101,46,98,105,110,97,114,121,46,97,110,121,46,67,0,0,0,2,99,50,0,0,0,4,100,101,115,99,0,0,0,33,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,115,104,97,114,101,46,98,105,110,97,114,121,46,97,110,121,46,67,0,0,0,2,99,49,0,0,0,4,100,101,115,99,-2,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0])")
assert(pickle.toString === "BinaryPickle([2,0,0,0,33,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,115,104,97,114,101,46,98,105,110,97,114,121,46,97,110,121,46,67,0,0,0,2,99,51,0,0,0,4,100,101,115,99,0,0,0,33,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,115,104,97,114,101,46,98,105,110,97,114,121,46,97,110,121,46,67,0,0,0,2,99,50,0,0,0,4,100,101,115,99,0,0,0,33,115,99,97,108,97,46,112,105,99,107,108,105,110,103,46,115,104,97,114,101,46,98,105,110,97,114,121,46,97,110,121,46,67,0,0,0,2,99,49,0,0,0,4,100,101,115,99,-2,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0])")
val c23 = pickle.unpickle[Any].asInstanceOf[C]
val c22 = c23.c
val c21 = c22.c
Expand Down
Loading