From db94e06b1c11b9afdc0fd9a18e456e0774fabd80 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 29 Aug 2012 15:50:13 -0400 Subject: Fixed cloning a double-linked list. Still need to determine if this is a systemic issue and needs to be addressed higher in the linked list hierarchy. For now, just fixing the reported bug, with a note here for other maintainers. --- test/files/run/t6292.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/files/run/t6292.scala (limited to 'test/files/run/t6292.scala') diff --git a/test/files/run/t6292.scala b/test/files/run/t6292.scala new file mode 100644 index 0000000000..51e31f95fc --- /dev/null +++ b/test/files/run/t6292.scala @@ -0,0 +1,18 @@ + import scala.collection.mutable.DoubleLinkedList + +object Test { + def main(args: Array[String]): Unit = { + cloneAndtest(DoubleLinkedList[Int]()) + cloneAndtest(DoubleLinkedList[Int](1)) + cloneAndtest(DoubleLinkedList[Int](1,2,3,4)) + } + + def cloneAndtest(l: DoubleLinkedList[Int]): Unit = + testSame(l, l.clone.asInstanceOf[DoubleLinkedList[Int]]) + + def testSame(one: DoubleLinkedList[Int], two: DoubleLinkedList[Int]): Unit = { + def msg = s" for ${one} and ${two} !" + assert(one.size == two.size, s"Cloned sizes are not the same $msg!") + assert(one == two, s"Cloned lists are not equal $msg") + } +} -- cgit v1.2.3