aboutsummaryrefslogtreecommitdiff
path: root/tests/pending/run/t4813.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-05-12 18:30:53 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-05-12 18:30:53 +0200
commit89bacb9c25a58454ff1878e67f7ea07ffc8c269f (patch)
tree51f1ff6c66aebe1b6109b1cffcc2bb8e4cf760a3 /tests/pending/run/t4813.scala
parenta0fa33deafbea1bf53edc068c5ed9db5592822f9 (diff)
downloaddotty-89bacb9c25a58454ff1878e67f7ea07ffc8c269f.tar.gz
dotty-89bacb9c25a58454ff1878e67f7ea07ffc8c269f.tar.bz2
dotty-89bacb9c25a58454ff1878e67f7ea07ffc8c269f.zip
Run tests as they were in scala.
Diffstat (limited to 'tests/pending/run/t4813.scala')
-rw-r--r--tests/pending/run/t4813.scala37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/pending/run/t4813.scala b/tests/pending/run/t4813.scala
new file mode 100644
index 000000000..6d48ca875
--- /dev/null
+++ b/tests/pending/run/t4813.scala
@@ -0,0 +1,37 @@
+import collection.mutable._
+import reflect._
+
+
+object Test extends App {
+ def runTest[T, U](col: T)(clone: T => U)(mod: T => Unit)(implicit ct: ClassTag[T]): Unit = {
+ val cloned = clone(col)
+ assert(cloned == col, s"cloned should be equal to original. $cloned != $col")
+ mod(col)
+ assert(cloned != col, s"cloned should not modify when original does: $ct")
+ }
+
+ // Seqs
+ runTest(ArrayBuffer(1,2,3))(_.clone) { buf => buf transform (_ + 1) }
+ runTest(ArraySeq(1,2,3))(_.clone) { buf => buf transform (_ + 1) }
+ runTest(Buffer(1,2,3))(_.clone) { buf => buf transform (_ + 1) }
+ runTest(DoubleLinkedList(1,2,3))(_.clone) { buf => buf transform (_ + 1) }
+ runTest(IndexedSeq(1,2,3))(_.clone) { buf => buf transform (_ + 1) }
+ runTest(LinearSeq(1,2,3))(_.clone) { buf => buf transform (_ + 1) }
+ runTest(LinkedList(1,2,3))(_.clone) { buf => buf transform (_ + 1) }
+ runTest(ListBuffer(1,2,3))(_.clone) { buf => buf transform (_ + 1) }
+ runTest(MutableList(1,2,3))(_.clone) { buf => buf transform (_ + 1) }
+ runTest(Queue(1,2,3))(_.clone) { buf => buf transform (_ + 1) }
+ runTest(Stack(1,2,3))(_.clone) { buf => buf transform (_ + 1) }
+
+ // Sets
+ runTest(BitSet(1,2,3))(_.clone) { buf => buf add 4 }
+ runTest(HashSet(1,2,3))(_.clone) { buf => buf add 4 }
+ runTest(Set(1,2,3))(_.clone) { buf => buf add 4 }
+ runTest(SortedSet(1,2,3))(_.clone) { buf => buf add 4 }
+ runTest(TreeSet(1,2,3))(_.clone) { buf => buf add 4 }
+
+ // Maps
+ runTest(HashMap(1->1,2->2,3->3))(_.clone) { buf => buf put (4,4) }
+ runTest(WeakHashMap(1->1,2->2,3->3))(_.clone) { buf => buf put (4,4) }
+}
+