Skip to content

Commit

Permalink
Merge pull request #135 from tsdeng/add_unit_test_for_trait_using_self
Browse files Browse the repository at this point in the history
add unit test for serde trait with reference of self
  • Loading branch information
johnynek committed Sep 25, 2013
2 parents 7a23720 + 54e7ded commit 97bb9f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
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

0 comments on commit 97bb9f5

Please sign in to comment.