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

Fix compiler warning about non-exhaustive match #83

Merged
merged 2 commits into from
Oct 18, 2016
Merged
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
25 changes: 11 additions & 14 deletions src/test/scala/scala/xml/ReuseNodesTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import scala.xml.transform._
import org.junit.Test
import org.junit.Assert.assertTrue
import org.junit.Assert.assertEquals
import org.junit.Assert.assertSame
import org.junit.experimental.theories.Theories
import org.junit.experimental.theories.Theory
import org.junit.experimental.theories.DataPoints
import org.junit.runner.RunWith
/**
* This test verify that after the tranform, the resultant xml node
* This test verifies that after the transform, the resultant xml node
* uses as many old nodes as possible.
*
* Three transformers class for case -
* One for orginal, one for modified, and one proposed which shows
* One for original, one for modified, and one proposed which shows
* all are equivalent when it comes to reusing as many nodes as possible
*/
object ReuseNodesTest {
Expand Down Expand Up @@ -72,7 +73,7 @@ class ReuseNodesTest {
def transformReferentialEquality(rt:RuleTransformer) = {
val original = <p><lost/></p>
val tranformed = rt.transform(original)
assertTrue(original eq tranformed)
assertSame(original, tranformed)
}

@Theory
Expand All @@ -83,24 +84,20 @@ class ReuseNodesTest {
}

def recursiveAssert(original:Seq[Node], transformed:Seq[Node]):Unit = {
(original.toList,transformed.toList) match {
case (Nil, Nil) => {}
case (x::xs,y::ys) => {
recursiveAssert(x,y)
recursiveAssert(xs,ys)
}
}
original zip transformed foreach {
case (x, y) => recursiveAssert(x, y)
}
}

def recursiveAssert(original:Node, transformed:Node):Unit = {
transformed.label match {
case "changed" => // do nothing expect this node to be changed
recursiveAssert(original.child,transformed.child)
case _ => {
assertTrue(original eq transformed)
// No need to check for childrens, node being immuatable
// childs can't be differnt if parents are refertially equal
assertSame(original, transformed)
// No need to check for children, node being immuatable
// children can't be different if parents are referentially equal
}
}
}
}
}