Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unit test for serde trait with reference of self #135

Merged
merged 3 commits into from
Sep 25, 2013
Merged
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
4 changes: 1 addition & 3 deletions chill-scala/src/main/scala/com/twitter/chill/KryoBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ class KryoBase extends Kryo {
super.newDefaultSerializer(klass) match {
case fs: FieldSerializer[_] =>
//Scala has a lot of synthetic fields that must be serialized:
if(classOf[scala.Serializable].isAssignableFrom(klass)) {
fs.setIgnoreSyntheticFields(false)
}
fs.setIgnoreSyntheticFields(false)
/**
* This breaks scalding, but something like this should be used when
* working with the repl.
Expand Down
10 changes: 10 additions & 0 deletions chill-scala/src/test/scala/com/twitter/chill/KryoSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ object WeekDay extends Enumeration {
val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value
}

trait ExampleUsingSelf { self =>
def count = 0
def addOne = new ExampleUsingSelf {override def count=self.count+1}
}

class KryoSpec extends Specification with BaseProperties {

noDetailedDiffs() //Fixes issue for scala 2.9
Expand Down Expand Up @@ -84,6 +89,11 @@ class KryoSpec extends Specification with BaseProperties {
serdeser must be_==(orig)
}
}
"handle trait with reference of self" in {
var a= new ExampleUsingSelf{}
var b=rt(a.addOne)
b.count must be_==(1)
}
"handle manifests" in {
rt(manifest[Int]) must be_==(manifest[Int])
rt(manifest[(Int,Int)]) must be_==(manifest[(Int,Int)])
Expand Down