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

Commit ad73c96

Browse files
committed
WIP, adding ability to version pickles
1 parent e61b4a2 commit ad73c96

24 files changed

+104
-33
lines changed

core/src/main/scala/pickling/Macros.scala

+13-13
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ trait PicklerMacros extends Macro with PickleMacros {
7777
(resOpt, resLst)
7878
}
7979
}
80+
8081
def unifiedPickle = { // NOTE: unified = the same code works for both primitives and objects
8182
val cir = newClassIR(tpe)
8283
// println(s"CIR for ${tpe.toString}: ${cir.fields.mkString(",")}")
@@ -88,15 +89,17 @@ trait PicklerMacros extends Macro with PickleMacros {
8889
val noNullTree = lst.foldLeft[Tree](Literal(Constant(true)))((acc, curr) => q"$acc && ($curr != null)")
8990
q"""
9091
if ($noNullTree) {
91-
val size = $tree + $typeNameLen + 4
92+
val size = $tree + $typeNameLen + 5
9293
builder.hintKnownSize(size)
9394
}
9495
"""
9596
}
97+
9698
val beginEntry = q"""
9799
$hintKnownSize
98100
builder.beginEntry(picklee)
99101
"""
102+
100103
val (nonLoopyFields, loopyFields) = cir.fields.partition(fir => !shouldBotherAboutLooping(fir.tpe))
101104
val putFields =
102105
if (tpe <:< typeOf[java.io.Externalizable]) {
@@ -383,28 +386,24 @@ trait PickleMacros extends Macro {
383386
import definitions._
384387

385388
def pickleTo[T: c.WeakTypeTag](output: c.Tree)(format: c.Tree): c.Tree = {
386-
val tpe = weakTypeOf[T]
387389
val q"${_}($pickleeArg)" = c.prefix.tree
388-
val endPickle = if (shouldBotherAboutCleaning(tpe)) q"clearPicklees()" else q"";
389-
q"""
390-
import scala.pickling._
391-
import scala.pickling.internal._
392-
val picklee: $tpe = $pickleeArg
393-
val builder = $format.createBuilder($output)
394-
picklee.pickleInto(builder)
395-
$endPickle
396-
"""
390+
pickleImpl[T](pickleeArg, q"$format.createBuilder($output)")
397391
}
398392

399393
def pickle[T: c.WeakTypeTag](format: c.Tree): c.Tree = {
400-
val tpe = weakTypeOf[T]
401394
val q"${_}($pickleeArg)" = c.prefix.tree
395+
pickleImpl[T](pickleeArg, q"$format.createBuilder()")
396+
}
397+
398+
def pickleImpl[T: c.WeakTypeTag](pickleeArg: c.Tree, mkBuilder: c.Tree): c.Tree = {
399+
val tpe = weakTypeOf[T]
402400
val endPickle = if (shouldBotherAboutCleaning(tpe)) q"clearPicklees()" else q"";
403401
q"""
404402
import scala.pickling._
405403
import scala.pickling.internal._
406404
val picklee: $tpe = $pickleeArg
407-
val builder = $format.createBuilder()
405+
val builder = $mkBuilder
406+
builder.beginPickle()
408407
picklee.pickleInto(builder)
409408
$endPickle
410409
builder.result()
@@ -542,6 +541,7 @@ trait UnpickleMacros extends Macro {
542541
val format = implicitly[PickleFormat]
543542
val pickle = $pickleArg.thePickle.asInstanceOf[format.PickleType]
544543
val $readerName = format.createReader(pickle, scala.pickling.internal.`package`.currentMirror)
544+
$readerName.beginPickle()
545545
$readerUnpickleTree
546546
"""
547547
}

core/src/main/scala/pickling/PBuilderReader.scala

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ trait Hintable {
1717
}
1818

1919
trait PBuilder extends Hintable {
20+
def beginPickle(): PBuilder
2021
def beginEntry(picklee: Any): PBuilder
2122
def putField(name: String, pickler: PBuilder => Unit): PBuilder
2223
def endEntry(): Unit
@@ -28,6 +29,7 @@ trait PBuilder extends Hintable {
2829

2930
trait PReader extends Hintable {
3031
def mirror: Mirror
32+
def beginPickle(): PReader
3133
def beginEntry(): FastTypeTag[_]
3234
def beginEntryNoTag(): String
3335
def beginEntryNoTagDebug(debugOn: Boolean): String

core/src/main/scala/pickling/PickleFormat.scala

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ trait PickleFormat {
1313
type PickleType <: Pickle
1414
type OutputType
1515

16+
val version: Int
17+
1618
def createBuilder(): PBuilder
1719
def createBuilder(out: OutputType): PBuilder
1820
def createReader(pickle: PickleType, mirror: Mirror): PReader

core/src/main/scala/pickling/binary/BinaryPickleFormat.scala

+36-1
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,25 @@ package binary {
5050

5151
private var output: ArrayOutput[Byte] = out
5252

53+
private var writeVersion = false
54+
5355
@inline private[this] def mkOutput(knownSize: Int): Unit =
54-
if (output == null)
56+
if (output == null) {
5557
output = if (knownSize != -1) new ByteArrayOutput(knownSize)
5658
else new ByteArrayBufferOutput
59+
if (writeVersion) {
60+
writeVersion = false
61+
Util.encodeByte(output, format.version.asInstanceOf[Byte])
62+
}
63+
} else if (writeVersion) {
64+
writeVersion = false
65+
Util.encodeByte(output, format.version.asInstanceOf[Byte])
66+
}
67+
68+
def beginPickle(): PBuilder = {
69+
writeVersion = true
70+
this
71+
}
5772

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

198213
var gla: Option[Byte] = None
199214

215+
def beginPickle(): PReader = {
216+
// read format version and check for mismatch
217+
val v = nextByte()
218+
if (v != format.version)
219+
throw new Exception(s"Incompatible pickle format version: read version $v, expected version ${format.version}")
220+
this
221+
}
222+
200223
def beginEntryNoTag(): String =
201224
beginEntryNoTagDebug(false)
202225

@@ -427,6 +450,15 @@ package binary {
427450

428451
private var pos = 0
429452

453+
def beginPickle(): PReader = {
454+
// read format version and check for mismatch
455+
val v = arr(pos)
456+
pos += 1
457+
if (v != format.version)
458+
throw new Exception(s"Incompatible pickle format version: read version $v, expected version ${format.version}")
459+
this
460+
}
461+
430462
def beginEntryNoTag(): String =
431463
beginEntryNoTagDebug(false)
432464

@@ -572,6 +604,9 @@ package binary {
572604
class BinaryPickleFormat extends PickleFormat with Constants {
573605
type PickleType = BinaryPickle
574606
type OutputType = ArrayOutput[Byte]
607+
608+
val version = 2
609+
575610
def createBuilder() = new BinaryPickleBuilder(this, null)
576611
def createBuilder(out: ArrayOutput[Byte]): PBuilder = new BinaryPickleBuilder(this, out)
577612
def createReader(pickle: PickleType, mirror: Mirror) = pickle.createReader(mirror, this)

core/src/main/scala/pickling/fastbinary/BinaryPickleFormat.scala

+17
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class BinaryPickleFormat extends PickleFormat with Constants {
1414
type PickleType = BinaryPickle
1515
type OutputType = FastArrayOutput
1616

17+
val version = 2
18+
1719
def createBuilder() = new BinaryPickleBuilder(this, null)
1820
def createBuilder(out: FastArrayOutput): PBuilder = new BinaryPickleBuilder(this, out)
1921

@@ -60,6 +62,11 @@ final class BinaryPickleBuilder(format: BinaryPickleFormat, out: FastArrayOutput
6062
if (out == null) new FastArrayOutput
6163
else out
6264

65+
def beginPickle(): PBuilder = {
66+
// TODO: write version of pickle format to pickle
67+
this
68+
}
69+
6370
@inline def beginEntry(picklee: Any): PBuilder = withHints { hints =>
6471
if (picklee == null) {
6572
Util.encodeByte(output, NULL_TAG)
@@ -200,6 +207,11 @@ final class BinaryPickleBuilder(format: BinaryPickleFormat, out: FastArrayOutput
200207

201208
var gla: Option[Byte] = None
202209

210+
def beginPickle(): PReader = {
211+
// TODO: read format version and check for mismatch
212+
this
213+
}
214+
203215
def beginEntryNoTag(): String =
204216
beginEntryNoTagDebug(false)
205217

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

431443
private var pos = 0
432444

445+
def beginPickle(): PReader = {
446+
// TODO: read format version and check for mismatch
447+
this
448+
}
449+
433450
def beginEntryNoTag(): String =
434451
beginEntryNoTagDebug(false)
435452

core/src/main/scala/pickling/json/JSONPickleFormat.scala

+14
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ package json {
2323
class JSONPickleFormat extends PickleFormat {
2424
type PickleType = JSONPickle
2525
type OutputType = Output[String]
26+
27+
val version = 2
28+
2629
def createBuilder() = new JSONPickleBuilder(this, new StringOutput)
2730
def createBuilder(out: Output[String]): PBuilder = new JSONPickleBuilder(this, out)
2831
def createReader(pickle: JSONPickle, mirror: Mirror) = {
@@ -96,6 +99,12 @@ package json {
9699
FastTypeTag.ArrayFloat.key -> ((picklee: Any) => pickleArray(picklee.asInstanceOf[Array[Float]], FastTypeTag.Float)),
97100
FastTypeTag.ArrayDouble.key -> ((picklee: Any) => pickleArray(picklee.asInstanceOf[Array[Double]], FastTypeTag.Double))
98101
)
102+
103+
def beginPickle(): PBuilder = {
104+
// write version of pickle format to pickle
105+
this
106+
}
107+
99108
def beginEntry(picklee: Any): PBuilder = withHints { hints =>
100109
indent()
101110
if (hints.oid != -1) {
@@ -198,6 +207,11 @@ package json {
198207
nested
199208
}
200209

210+
def beginPickle(): PReader = {
211+
// TODO: read format version and check for mismatch
212+
this
213+
}
214+
201215
def beginEntryNoTag(): String =
202216
beginEntryNoTagDebug(false)
203217

core/src/test/scala/pickling/run/array-binary.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ case class D(x: Int)
1111
class ArrayBinaryTest extends FunSuite {
1212
test("main") {
1313
val pickle = C(Array(1, 2, 3)).pickle
14-
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])")
14+
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])")
1515
assert(pickle.unpickle[C].toString === "C([1,2,3])")
1616
}
1717

core/src/test/scala/pickling/run/binary-array-int.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class BinaryArrayIntTest extends FunSuite {
1010
val ia = Array[Int](30, 31)
1111

1212
val pickle: BinaryPickle = ia.pickle
13-
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]")
13+
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]")
1414

1515
val readArr = pickle.unpickle[Array[Int]]
1616
assert(readArr.mkString("[", ",", "]") === "[30,31]")

core/src/test/scala/pickling/run/binary-case-class-int-string.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class BinaryCaseClassIntStringTest extends FunSuite {
1212
test("main") {
1313
val p = Person("Jim", 43)
1414
val pickle = p.pickle
15-
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]")
15+
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]")
1616
val up = pickle.unpickle[Person]
1717
assert(p === up)
1818
}

core/src/test/scala/pickling/run/binary-dpickler.scala

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class BinaryDPicklerTest extends FunSuite {
1515
val ff = Firefighter("Jim", 43, 30000)
1616

1717
val builder = pickleFormat.createBuilder()
18+
builder.beginPickle()
1819
dp.pickle(ff, builder)
1920
val pickle = builder.result()
2021
val up = pickle.unpickle[Person]

core/src/test/scala/pickling/run/binary-inputstream.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class BinaryInputStreamReaderTest extends FunSuite {
2626
val arr = Array[Int](30, 31)
2727

2828
val pickle: BinaryPickle = arr.pickle
29-
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]")
29+
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]")
3030

3131
val streamPickle = BinaryPickleStream(new ByteArrayInputStream(pickle.value))
3232
val readArr = streamPickle.unpickle[Array[Int]]

core/src/test/scala/pickling/run/binary-list-int-custom-pickler-implicitly-selection.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class BinaryListIntCustomTest extends FunSuite {
5656
}
5757

5858
val pickle = lst.pickle
59-
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])")
59+
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])")
6060
assert(pickle.unpickle[List[Int]] === List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
6161
}
6262
}

core/src/test/scala/pickling/run/binary-list-t-new.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import binary._
77
class BinaryListTNewTest extends FunSuite {
88
test("main") {
99
val pickle = List(1, 2, 3).pickle
10-
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])")
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,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])")
1111
assert(pickle.unpickle[List[Int]] === List(1, 2, 3))
1212
}
1313
}

core/src/test/scala/pickling/run/binary-non-primitive-field.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class BinaryNonPrimitiveFieldTest extends FunSuite {
1313
val p = Philipp(gudrun)
1414
val pckl = p.pickle
1515

16-
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]")
16+
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]")
1717
assert(pckl.unpickle[Philipp] === p)
1818
}
1919
}

core/src/test/scala/pickling/run/binary-non-primitive-fields.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class BinaryNonPrimitiveFieldsTest extends FunSuite {
1111
test("main") {
1212
val ph = new Philipp("German", true, new Person("Gudrun", 62))
1313
val pckl = ph.pickle
14-
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]")
14+
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]")
1515
assert(pckl.unpickle[Philipp] == ph)
1616
}
1717
}

core/src/test/scala/pickling/run/binary-simple-case-class.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class BinarySimpleCaseClassTest extends FunSuite {
1212
test("main") {
1313
val p = Person(43)
1414
val pickle = p.pickle
15-
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]")
15+
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]")
1616
assert(pickle.unpickle[Person] === p)
1717
}
1818
}

core/src/test/scala/pickling/run/c-x-any-binary.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class CXAnyBinaryTest extends FunSuite {
1010
test("main") {
1111
val c = new C(2)
1212
val pckl = c.pickle
13-
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])")
13+
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])")
1414
assert(pckl.unpickle[C] === c)
1515
}
1616
}

core/src/test/scala/pickling/run/combinator-pickleinto.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class CombinatorPickleIntoTest extends FunSuite {
6969

7070
val bart = new Person(2)
7171
val pickle = bart.pickle
72-
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]")
72+
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]")
7373

7474
val p = pickle.unpickle[Person]
7575
assert(p.toString === "Person(Bart, 45)")

core/src/test/scala/pickling/run/generics-tough.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class GenericsToughTest extends FunSuite {
1111
test("main") {
1212
val c: C[Int] = D(2)
1313
val p = c.pickle
14-
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])")
14+
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])")
1515
assert(p.unpickle[C[Int]] === c)
1616
}
1717
}

core/src/test/scala/pickling/run/null-binary.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class NullBinaryTest extends FunSuite {
1212
test("main") {
1313
val c = C(null, 0, null, null)
1414
val pickle = c.pickle
15-
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]")
15+
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]")
1616
assert(pickle.unpickle[C].toString === c.toString)
1717
}
1818
}

core/src/test/scala/pickling/run/share-binary-any.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class ShareBinaryAnyTest extends FunSuite {
6363
import shareNothing._
6464
c1.c = null
6565
val pickle = (c3: Any).pickle
66-
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])")
66+
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])")
6767
val c23 = pickle.unpickle[Any].asInstanceOf[C]
6868
val c22 = c23.c
6969
val c21 = c22.c

0 commit comments

Comments
 (0)