From 704a54513f5520573d0cf8e50c50bc7a7145ed71 Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Mon, 14 Sep 2015 15:07:24 -0400 Subject: [PATCH 1/2] Fix compiler warning about non-exhaustive match src/test/scala/scala/xml/ReuseNodesTest.scala:86: match may not be exhaustive. It would fail on the following inputs: (List(_), Nil), (Nil, List(_)) (original.toList,transformed.toList) match { ^ one warning found --- src/test/scala/scala/xml/ReuseNodesTest.scala | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/test/scala/scala/xml/ReuseNodesTest.scala b/src/test/scala/scala/xml/ReuseNodesTest.scala index 5c61d0e3f..636de592b 100644 --- a/src/test/scala/scala/xml/ReuseNodesTest.scala +++ b/src/test/scala/scala/xml/ReuseNodesTest.scala @@ -9,11 +9,11 @@ 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 { @@ -83,13 +83,9 @@ 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 = { @@ -98,9 +94,9 @@ class ReuseNodesTest { 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 + // No need to check for children, node being immuatable + // children can't be different if parents are referentially equal } } } -} \ No newline at end of file +} From 713d2d998151d0ab7e0096fb051108a8ee07f1f7 Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Mon, 14 Sep 2015 15:27:54 -0400 Subject: [PATCH 2/2] Use JUnit's assertSame in scala.xml.ReuseNodesTest --- src/test/scala/scala/xml/ReuseNodesTest.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/scala/scala/xml/ReuseNodesTest.scala b/src/test/scala/scala/xml/ReuseNodesTest.scala index 636de592b..d3b05a338 100644 --- a/src/test/scala/scala/xml/ReuseNodesTest.scala +++ b/src/test/scala/scala/xml/ReuseNodesTest.scala @@ -4,6 +4,7 @@ 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 @@ -72,7 +73,7 @@ class ReuseNodesTest { def transformReferentialEquality(rt:RuleTransformer) = { val original =

val tranformed = rt.transform(original) - assertTrue(original eq tranformed) + assertSame(original, tranformed) } @Theory @@ -93,7 +94,7 @@ class ReuseNodesTest { case "changed" => // do nothing expect this node to be changed recursiveAssert(original.child,transformed.child) case _ => { - assertTrue(original eq transformed) + assertSame(original, transformed) // No need to check for children, node being immuatable // children can't be different if parents are referentially equal }