From c17e46682a9b42eaf4d33d9f60b50c826ab4009e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 27 Mar 2011 19:46:12 +0000 Subject: Fix for linked lists closes #4080 and proves my... Fix for linked lists closes #4080 and proves my desire not to ship obviously broken code is even greater than my will to hold out for any help. I threw in a free fix for this which I noticed while in there. scala> scala.collection.mutable.LinkedList[Int]().head res0: Int = 0 Also was reminded how useless tests can be: val ten = DoubleLinkedList(1 to 10: _*) ten.insert(DoubleLinkedList(11)) // Post-insert position test require(ten.last == 11) Fortunately a test confirming buggy behavior still serves a purpose by breaking when you fix the bug which allowed it to pass, thus letting you fix the broken test too. Life's (very) little compensations. Linked list code should still be presumed broken. No review. --- test/files/run/bug4080.check | 1 + test/files/run/bug4080.scala | 12 ++++++++++++ test/files/run/t3361.scala | 6 ++---- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 test/files/run/bug4080.check create mode 100644 test/files/run/bug4080.scala (limited to 'test/files/run') diff --git a/test/files/run/bug4080.check b/test/files/run/bug4080.check new file mode 100644 index 0000000000..66ce31bb43 --- /dev/null +++ b/test/files/run/bug4080.check @@ -0,0 +1 @@ +LinkedList(1, 0, 2, 3) diff --git a/test/files/run/bug4080.scala b/test/files/run/bug4080.scala new file mode 100644 index 0000000000..92740ed776 --- /dev/null +++ b/test/files/run/bug4080.scala @@ -0,0 +1,12 @@ +import scala.collection.mutable.LinkedList + +object Test { + def main(args: Array[String]) { + val ll = LinkedList(1, 2, 3) + ll.insert(LinkedList(0)) + println(ll) + val ll2 = LinkedList[Int]() + try println(ll2.head) + catch { case _ => () } + } +} diff --git a/test/files/run/t3361.scala b/test/files/run/t3361.scala index 17af89a67c..892e36dbd9 100644 --- a/test/files/run/t3361.scala +++ b/test/files/run/t3361.scala @@ -39,10 +39,8 @@ object Test extends App { def insert_1 { val ten = DoubleLinkedList(1 to 10: _*) - ten.insert(DoubleLinkedList(11)) match { - case _: Unit => require(true) - case _ => require(false) - } + ten.append(DoubleLinkedList(11)) + // Post-insert size test require(11 == ten.size) // Post-insert data test -- cgit v1.2.3