This repository has been archived by the owner on Feb 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from scala/ctor-params-no-getter
Deal with constructor parameters properly
- Loading branch information
Showing
5 changed files
with
168 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package scala.pickling.test.ctorparams | ||
|
||
import org.scalatest.FunSuite | ||
import scala.pickling._ | ||
import json._ | ||
|
||
class Partitioner(numParts: Int) { | ||
def numPartitions = numParts | ||
override def toString = s"Partitioner($numParts)" | ||
} | ||
|
||
class Partitioner2(numParts: Int, val other: String) { | ||
def numPartitions = numParts | ||
override def toString = s"Partitioner2($numParts,$other)" | ||
} | ||
|
||
class CtorParamsTest extends FunSuite { | ||
test("runtime pickler") { | ||
val par: Any = new Partitioner(8) | ||
val p: JSONPickle = par.pickle | ||
val up = p.unpickle[Any] | ||
assert(par.toString == up.toString) | ||
} | ||
|
||
test("static pickler") { | ||
val par = new Partitioner(8) | ||
val p: JSONPickle = par.pickle | ||
val up = p.unpickle[Partitioner] | ||
assert(par.toString == up.toString) | ||
} | ||
|
||
test("ctor param and public getter") { | ||
val par = new Partitioner2(8, "test") | ||
val p: JSONPickle = par.pickle | ||
val up = p.unpickle[Partitioner2] | ||
assert(par.toString == up.toString) | ||
} | ||
} |